kdb: Remove the misfeature 'KDBFLAGS'
authorWei Li <liwei391@huawei.com>
Thu, 21 May 2020 07:21:25 +0000 (15:21 +0800)
committerDaniel Thompson <daniel.thompson@linaro.org>
Tue, 2 Jun 2020 14:15:46 +0000 (15:15 +0100)
Currently, 'KDBFLAGS' is an internal variable of kdb, it is combined
by 'KDBDEBUG' and state flags. It will be shown only when 'KDBDEBUG'
is set, and the user can define an environment variable named 'KDBFLAGS'
too. These are puzzling indeed.

After communication with Daniel, it seems that 'KDBFLAGS' is a misfeature.
So let's replace 'KDBFLAGS' with 'KDBDEBUG' to just show the value we
wrote into. After this modification, we can use `md4c1 kdb_flags` instead,
to observe the state flags.

Suggested-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Wei Li <liwei391@huawei.com>
Link: https://lore.kernel.org/r/20200521072125.21103-1-liwei391@huawei.com
[daniel.thompson@linaro.org: Make kdb_flags unsigned to avoid arithmetic
right shift]
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
include/linux/kdb.h
kernel/debug/kdb/kdb_main.c

index 24cd447659e0f68b859245b1a53722d8f0f6326c..0125a677b67fdcc4bc79472d62158353e9f4ddbc 100644 (file)
@@ -125,7 +125,7 @@ extern const char *kdb_diemsg;
 #define KDB_FLAG_NO_I8042      (1 << 7) /* No i8042 chip is available, do
                                          * not use keyboard */
 
-extern int kdb_flags;  /* Global flags, see kdb_state for per cpu state */
+extern unsigned int kdb_flags; /* Global flags, see kdb_state for per cpu state */
 
 extern void kdb_save_flags(void);
 extern void kdb_restore_flags(void);
index 6865a0f58d3831dee701b38cb577a8c137c5c624..ec190569f690a0c105555929ec6787e6604b5a1c 100644 (file)
@@ -62,7 +62,7 @@ int kdb_grep_trailing;
 /*
  * Kernel debugger state flags
  */
-int kdb_flags;
+unsigned int kdb_flags;
 
 /*
  * kdb_lock protects updates to kdb_initial_cpu.  Used to
@@ -418,8 +418,7 @@ int kdb_set(int argc, const char **argv)
                                    argv[2]);
                        return 0;
                }
-               kdb_flags = (kdb_flags &
-                            ~(KDB_DEBUG_FLAG_MASK << KDB_DEBUG_FLAG_SHIFT))
+               kdb_flags = (kdb_flags & ~KDB_DEBUG(MASK))
                        | (debugflags << KDB_DEBUG_FLAG_SHIFT);
 
                return 0;
@@ -2082,7 +2081,8 @@ static int kdb_env(int argc, const char **argv)
        }
 
        if (KDB_DEBUG(MASK))
-               kdb_printf("KDBFLAGS=0x%x\n", kdb_flags);
+               kdb_printf("KDBDEBUG=0x%x\n",
+                       (kdb_flags & KDB_DEBUG(MASK)) >> KDB_DEBUG_FLAG_SHIFT);
 
        return 0;
 }