Skip to content

Commit

Permalink
kdb: Remove the misfeature 'KDBFLAGS'
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Wei Li <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[[email protected]: Make kdb_flags unsigned to avoid arithmetic
right shift]
Signed-off-by: Daniel Thompson <[email protected]>
  • Loading branch information
stkid authored and daniel-thompson committed Jun 2, 2020
1 parent 1b31003 commit c893de1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/linux/kdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions kernel/debug/kdb/kdb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit c893de1

Please sign in to comment.