[PATCH] xmon command for symbol lookups
Benjamin Herrenschmidt
benh at kernel.crashing.org
Wed Feb 25 09:46:54 EST 2004
On Wed, 2004-02-25 at 07:35, Olof Johansson wrote:
> One of the most crippling drawbacks (for me) with xmon is that you need
> a System.map to lookup all addresses in when you're digging through
> disassembly.
>
> The attached patch adds a new command, "n <address>" that will show the
> corresponding symbol in the same way that the "t" command does.
>
> It also fixes another thing that's irritated me before: xmon doesn't
> take values in 0x<hex> form, only <hex>.
Hrm... well... I have this on ppc32 already, but used different
commmands: la and ls (lookup address and lookup symbol), also I
have added the ability to use a symbol (preceded by the $) every
time you can enter a number (like you can use % with a register
name). What about making xmon in sync ? :)
Another _real cool_ feature is a dmesg in xmon btw :)
> 3:mon> t
> c00000007e4978b0 c00000000004d894 .xmon+0x15c/0x358
> c00000007e497a90 c00000000004d2e0 .sysrq_handle_xmon+0x5c/0x64
> c00000007e497b20 c00000000024d7c4 .__handle_sysrq_nolock+0xe0/0x184
> c00000007e497bd0 c00000000024d6c0 .handle_sysrq+0x70/0x94
> c00000007e497c60 c000000000102dd0 .write_sysrq_trigger+0x88/0xac
> c00000007e497cf0 c0000000000b4464 .vfs_write+0x10c/0x164
> c00000007e497d90 c0000000000b45a0 .sys_write+0x50/0x94
> c00000007e497e30 c0000000000119bc ret_from_syscall_1
> exception: c00 (System Call) regs c00000007e497ea0
> 000000000ff27b2c
> <Stack drops into userspace 00000000ffffe780>
> 3:mon> di c00000000024d6c0
> c00000000024d6c0 60000000 nop
> c00000000024d6c4 38210090 addi r1,r1,144
> c00000000024d6c8 e8010010 ld r0,16(r1)
> c00000000024d6cc ebe1fff8 ld r31,-8(r1)
> c00000000024d6d0 eb81ffe0 ld r28,-32(r1)
> c00000000024d6d4 eba1ffe8 ld r29,-24(r1)
> c00000000024d6d8 ebc1fff0 ld r30,-16(r1)
> c00000000024d6dc 7c0803a6 mtlr r0
> c00000000024d6e0 4bfffeac b 0xc00000000024d58c
> c00000000024d6e4 fbc1fff0 std r30,-16(r1)
> c00000000024d6e8 ebc2c5d8 ld r30,-14888(r2)
> c00000000024d6ec 7c0802a6 mflr r0
> c00000000024d6f0 fb41ffd0 std r26,-48(r1)
> c00000000024d6f4 fb61ffd8 std r27,-40(r1)
> c00000000024d6f8 7cba2b78 mr r26,r5
> c00000000024d6fc 7c9b2378 mr r27,r4
> 3:mon> n 0xc00000000024d58c
> c00000000024d58c: .__sysrq_unlock_table+0x0/0x30
> 3:mon>
>
>
>
>
>
> Another enhancement would be to simply print the symbol as a comment
> behind the address when doing disasm, but that would make the output
> wider than 80 characters. Does anyone have problems with that or should
> I add that as well?
>
>
> Thanks,
>
> Olof
>
> --
> Olof Johansson Office: 4F005/905
> pSeries Linux Development IBM Systems Group
> Email: olof at austin.ibm.com Phone: 512-838-9858
> All opinions are my own and not those of IBM
>
> ______________________________________________________________________
> ===== arch/ppc64/xmon/xmon.c 1.35 vs edited =====
> --- 1.35/arch/ppc64/xmon/xmon.c Sun Feb 15 15:23:37 2004
> +++ edited/arch/ppc64/xmon/xmon.c Tue Feb 24 14:25:34 2004
> @@ -83,6 +83,7 @@
> static void dump(void);
> static void prdump(unsigned long, long);
> static int ppc_inst_dump(unsigned long, long);
> +static void lookupsymbol(void);
> void print_address(unsigned long);
> static int getsp(void);
> static void backtrace(struct pt_regs *);
> @@ -167,6 +168,7 @@
> ml locate a block of memory\n\
> mz zero a block of memory\n\
> mi show information about memory allocation\n\
> + n lookup address -> symbol name\n\
> p show the task list\n\
> r print registers\n\
> s single step\n\
> @@ -537,6 +539,9 @@
> case 'd':
> dump();
> break;
> + case 'n':
> + lookupsymbol();
> + break;
> case 'r':
> if (excp != NULL)
> prregs(excp); /* print regs */
> @@ -1644,6 +1649,23 @@
> printf("0x%lx", addr);
> }
>
> +
> +void
> +lookupsymbol(void)
> +{
> + int c;
> +
> + c = inchar();
> + if (c == '\n')
> + termch = c;
> + scanhex((void *)&adrs);
> + if( termch != '\n')
> + termch = 0;
> + printf("%016lx: ", adrs);
> + xmon_print_symbol("%s\n", adrs);
> +}
> +
> +
> /*
> * Memory operations - move, set, print differences
> */
> @@ -1820,6 +1842,14 @@
> }
> printf("invalid register name '%%%s'\n", regname);
> return 0;
> + }
> +
> + /* skip leading "0x" if any */
> +
> + if (c == '0') {
> + c = inchar();
> + if (c == 'x')
> + c = inchar();
> }
>
> d = hexdigit(c);
--
Benjamin Herrenschmidt <benh at kernel.crashing.org>
** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/
More information about the Linuxppc64-dev
mailing list