Gdbinit icon indicating copy to clipboard operation
Gdbinit copied to clipboard

x/c does not work and add \n to the ascii_char function?

Open shibumi opened this issue 11 years ago • 6 comments

Hey, Your gdbinit file is nice! Thx. But I have a problem with it:

gdb$ x/x 0x80484c0
0x80484c0:  0x6c6c6548
gdb$ x/s 0x80484c0
0x80484c0:  "Hello World!"
gdb$ x/c 0x80484c0
0x80484c0:  0x48
gdb$ x/12c 0x80484c0
0x80484c0:  0x48    0x65    0x6c    0x6c    0x6f    0x20    0x57    0x6f
0x80484c8:  0x72    0x6c    0x64    0x21

x/c 0x80484c0 should show: 0x48 'H' ... where is the char output? I can't find something about it in your config.

...........................................................................................................................

The second Issue:

gdb$ ascii_char 0x80484c0
Hgdb$ 
Hgdb$ 
Hgdb$ 

This is reallly ugly.. why no adding "\n"?

nice greetings from Germany and thx for your gdbinit :+1:

Chris

shibumi avatar Mar 17 '14 02:03 shibumi

x/c is internal gdb function and afaik it means only the length of the hex display and never displays the correspondent ascii character. ascii_char is an internal function used somewhere else that requires no newline.

gdbinit avatar Mar 17 '14 02:03 gdbinit

thx but why is gdb showing without your config the current ascii character?

(gdb) x/s 0x80484c0
0x80484c0:  "Hello World!"
(gdb) x/c 0x80484c0
0x80484c0:  72 'H'

I want the same behaviour with your config. How can I fix this?

shibumi avatar Mar 17 '14 02:03 shibumi

I have no idea, probably some setting conflict.

gdbinit avatar Mar 17 '14 02:03 gdbinit

I got the setting conflict...

just uncomment the following lines:

#set output-radix 0x10
#set input-radix 0x10

This fixed it for me thx..

shibumi avatar Mar 17 '14 15:03 shibumi

Ah, those would be my two strongest bets on the source of the problem. Not sure if I want to remove them because they mess a bit the calculations with decimal and hexadecimal values. Need to test it again.

gdbinit avatar Mar 25 '14 16:03 gdbinit

I can confirm it: With the .gdbinit config, x/c is same as x/x. Above proposal restores the original functionality with x/c.

I counldn't reproduce any problems with the hex/dec calculations:

gdb$ x/c 0x8048540
0x8048540:	68 'D'
gdb$ x/10c 0x8048540
0x8048540:	68 'D'	111 'o'	32 ' '	105 'i'	116 't'	0 '\000'	66 'B'	117 'u'
0x8048548:	102 'f'	102 'f'
gdb$ x/10x 0x8048540
0x8048540:	0x44	0x6f	0x20	0x69	0x74	0x00	0x42	0x75
0x8048548:	0x66	0x66
gdb$ p 0x44
$1 = 68
gdb$ p 68
$2 = 68
gdb$ p/x 68
$3 = 0x44
gdb$ p/x 0x10+0x10
$4 = 0x20
gdb$ p 0x10+0x10
$5 = 32

kmlob avatar Jan 19 '17 21:01 kmlob