For example: crash> rustfilt _RNvXsh_NtCskljHLvcz3xy_4core3fmteNtB5_7Display3fmt <str as core::fmt::Display>::fmt
Signed-off-by: Lianbo Jiang <[email protected]> --- defs.h | 2 ++ global_data.c | 1 + help.c | 10 ++++++++++ symbols.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+) diff --git a/defs.h b/defs.h index 4fecb8388229..156ac0232906 100644 --- a/defs.h +++ b/defs.h @@ -5508,6 +5508,7 @@ void cmd_s390dbf(void); #endif void cmd_map(void); /* kvmdump.c */ void cmd_ipcs(void); /* ipcs.c */ +void cmd_rustfilt(void); /* symbols.c */ /* * main.c @@ -6115,6 +6116,7 @@ extern char *help_wr[]; extern char *help_s390dbf[]; #endif extern char *help_map[]; +extern char *help_rustfilt[]; /* * task.c diff --git a/global_data.c b/global_data.c index f9bb7d079f51..889103d35f82 100644 --- a/global_data.c +++ b/global_data.c @@ -125,6 +125,7 @@ struct command_table_entry linux_command_table[] = { #if defined(S390) || defined(S390X) {"s390dbf", cmd_s390dbf, help_s390dbf, 0}, #endif + {"rustfilt", cmd_rustfilt, help_rustfilt, MINIMAL}, {(char *)NULL} }; diff --git a/help.c b/help.c index 5d61e0d57229..4f071e0bd0a0 100644 --- a/help.c +++ b/help.c @@ -8186,6 +8186,16 @@ char *help_net[] = { NULL }; +char *help_rustfilt[] = { +"rustfilt", +"demangle a mangled Rust symbol to human readable symbol", +"<symbol>", +" This command converts a mangled Rust symbol to human readable symbol.", +"\nEXAMPLES", +" crash> rustfilt _RNvNtCshc5sK6KjdJJ_6kernel5print11call_printk", +" kernel::print::call_printk", +NULL +}; char *help_waitq[] = { "waitq", diff --git a/symbols.c b/symbols.c index 794519ad4126..052196265be0 100644 --- a/symbols.c +++ b/symbols.c @@ -22,6 +22,7 @@ #include "config.h" #endif #include "bfd.h" +#include "demangle.h" static void store_symbols(bfd *, int, void *, long, unsigned int); static void store_sysmap_symbols(void); @@ -4887,6 +4888,38 @@ do_multiples: cmd_usage(pc->curcmd, SYNOPSIS); } +/* + * Demangle a mangled Rust symbol to human readable symbol + */ +void cmd_rustfilt(void) +{ + int c; + + while ((c = getopt(argcnt, args, "")) != EOF) { + switch(c) + { + default: + argerrs++; + break; + } + } + + if (argerrs) + cmd_usage(pc->curcmd, SYNOPSIS); + + if (args[optind]) { + char *buf; + + buf = rust_demangle(args[optind], DMGL_RUST); + if (buf) { + fprintf(fp, "%s", buf); + free(buf); + } else + fprintf(fp, "Not a rust symbol: \n%s", args[optind]); + } else + cmd_usage(pc->curcmd, SYNOPSIS); +} + /* * Common symbol display for cmd_sym(). */ -- 2.50.1 -- Crash-utility mailing list -- [email protected] To unsubscribe send an email to [email protected] https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/ Contribution Guidelines: https://github.com/crash-utility/crash/wiki
