From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jim Blandy To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: RFA: fix GDB casts when pointers are not addresses Date: Fri, 06 Jul 2001 16:28:00 -0000 Message-id: References: <20010628225704.9AB635E9CB@zwingli.cygnus.com> <3B43F7F6.3080902@cygnus.com> <3B44C964.6050805@cygnus.com> <3B4555B0.3000108@cygnus.com> X-SW-Source: 2001-07/msg00169.html Andrew Cagney writes: > This only leaves ``x/...''. How does that behavour compare? Yes, the commands you gave above still work; see below. There are no new regressions on the test suite, other than those I mentioned in my original I-hate-the-D10V patch, so I assume the data commands still work, too. Michael Snyder asked privately about whether assigning values to $pc still worked (he's thinking of a bug someone reported internal to Red Hat). The transcript below shows that that still works, too. > The most > important thing was that given: > > (gdb) print main > $1 = {int ()} 0x101405c
> (gdb) print/x &main > > things like: > > (gdb) x/i main > disassembled
> (gdb) x/i 0x101405c > disassembled
> (gdb) x/b 0x101405c > hex dump of main > > and > > (gdb) disassemble main > disassembled
> (gdb) disassemble 0x101405c > > continued to work (assuming that they did before :-/). Similar for data > values. Here's the demo: $ $DD10v/gdb/gdb pointer GNU gdb 2001-07-06-cvs (MI_OUT) Copyright 2001 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "--host=i686-pc-linux-gnu --target=d10v-elf"... (gdb) x/3i main 0x101405c
: st r11, @-sp -> st r13, @-sp 0x1014060 : mv r11, sp || nop 0x1014064 : ldi.l r0, 0x4 (These are the correct instructions, according to objdump -d.) (gdb) x/3i 0x101405c 0x101405c
: st r11, @-sp -> st r13, @-sp 0x1014060 : mv r11, sp || nop 0x1014064 : ldi.l r0, 0x4 (gdb) x/4b 0x101405c 0x101405c
: 0x76 0xbf 0xed 0xbf (Those are the correct bytes, according to objdump -d.) (gdb) disassemble main Dump of assembler code for function main: 0x101405c
: st r11, @-sp -> st r13, @-sp 0x1014060 : mv r11, sp || nop 0x1014064 : ldi.l r0, 0x4 0x1014068 : ldi.s r1, 0x2 || nop 0x101406c : bl.l 0x1014130 0x1014070 : ldi.l r0, 0x1c 0x1014074 : ldi.s r1, 0x2 || nop 0x1014078 : bl.l 0x1014130 0x101407c : ldi.l r0, 0x39 0x1014080 : ldi.l r1, 0x5017 0x1014084 : bl.l 0x1014130 0x1014088 : add3 sp, r11, 0x0 0x101408c : ld r13, @sp+ -> ld r11, @sp+ 0x1014090 : jmp r13 || nop End of assembler dump. (gdb) disassemble 0x101405c Dump of assembler code for function main: 0x101405c
: st r11, @-sp -> st r13, @-sp 0x1014060 : mv r11, sp || nop 0x1014064 : ldi.l r0, 0x4 0x1014068 : ldi.s r1, 0x2 || nop 0x101406c : bl.l 0x1014130 0x1014070 : ldi.l r0, 0x1c 0x1014074 : ldi.s r1, 0x2 || nop 0x1014078 : bl.l 0x1014130 0x101407c : ldi.l r0, 0x39 0x1014080 : ldi.l r1, 0x5017 0x1014084 : bl.l 0x1014130 0x1014088 : add3 sp, r11, 0x0 0x101408c : ld r13, @sp+ -> ld r11, @sp+ 0x1014090 : jmp r13 || nop End of assembler dump. (gdb) break main Breakpoint 1 at 0x1014064: file pointer.c, line 10. (gdb) target sim Connected to the simulator. (gdb) load Loading section .rodata, size 0x26a lma 0x2000004 Loading section .data, size 0x3cc lma 0x2000270 Loading section .text, size 0x8990 lma 0x1014000 Start address 0x1014000 Transfer rate: 294448 bits in <1 sec. (gdb) run Starting program: /home/jimb/d10v/play/pointer Breakpoint 1, main () at pointer.c:10 10 EXPR (sizeof (void *)); (gdb) p/x $pc $1 = 0x1014064 (gdb) x/3i $pc 0x1014064 : ldi.l r0, 0x4 0x1014068 : ldi.s r1, 0x2 || nop 0x101406c : bl.l 0x1014130 (gdb) set $pc = 0x1014070 (gdb) p/x $pc $2 = 0x1014070 (gdb)