gdbinit / Gdbinit

Gdbinit for OS X, iOS and others - x86, x86_64 and ARM
https://reverse.put.as
1.68k stars 459 forks source link

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

Open shibumi opened 10 years ago

shibumi commented 10 years ago

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

gdbinit commented 10 years ago

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.

shibumi commented 10 years ago

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?

gdbinit commented 10 years ago

I have no idea, probably some setting conflict.

shibumi commented 10 years ago

I got the setting conflict...

just uncomment the following lines:

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

This fixed it for me thx..

gdbinit commented 10 years ago

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.

kmlob commented 7 years ago

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