diff options
author | Daniel Thompson <daniel.thompson@linaro.org> | 2022-04-13 16:20:53 +0100 |
---|---|---|
committer | Daniel Thompson <daniel.thompson@linaro.org> | 2022-04-13 17:22:53 +0100 |
commit | d11936e6dfeb5eb28f5be3f5fe80de0d47b8de6a (patch) | |
tree | 247d4d4790cd94858eb96d9049a789b5c0c25c21 | |
parent | 169ce1152ce2b13559814fa713c5b2a6ea8a4463 (diff) |
kdb: Add helpers to expose seq files as kdb commands
Currently kdb can display seq files using an internal helper function
but this is not very discoverable. Provide some helpers to allow
seq_operations to be trivially converted into kdb commands.
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
-rw-r--r-- | include/linux/kdb.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/linux/kdb.h b/include/linux/kdb.h index 5b401ed1753c..de2a9d03556b 100644 --- a/include/linux/kdb.h +++ b/include/linux/kdb.h @@ -211,6 +211,24 @@ static inline const char *kdb_walk_kallsyms(loff_t *pos) /* Dynamic kdb shell command registration */ extern int kdb_register(kdbtab_t *cmd); extern void kdb_unregister(kdbtab_t *cmd); + +#define DEFINE_KDB_SEQ_FILE(cname, chelp, seq_ops) \ + static int kdb_##cname(int argc, const char **argv) \ + { \ + return kdb_print_seq_file(seq_ops); \ + } \ + static int register_kdb_seq_file_##cname(void) \ + { \ + static kdbtab_t kdb_##cname##_cmd = { \ + .name = #cname, \ + .func = kdb_##cname, \ + .usage = "", \ + .help = chelp, \ + .flags = KDB_ENABLE_ALWAYS_SAFE, \ + }; \ + \ + return kdb_register(&kdb_##cname##_cmd); \ + } #else /* ! CONFIG_KGDB_KDB */ static inline __printf(1, 2) int kdb_printf(const char *fmt, ...) { return 0; } static inline int @@ -218,6 +236,12 @@ kdb_print_seq_file(const struct seq_operations *ops) { return 0; } static inline void kdb_init(int level) {} static inline int kdb_register(kdbtab_t *cmd) { return 0; } static inline void kdb_unregister(kdbtab_t *cmd) {} + +#define DEFINE_KDB_SEQ_FILE(cname, chelp, seq_ops) \ + static inline int register_kdb_seq_file_##cname(void) \ + { \ + return 0; \ + } #endif /* CONFIG_KGDB_KDB */ enum { KDB_NOT_INITIALIZED, |