Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
shibumi opened this issue Mar 17, 2014 · 6 comments
Open

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

shibumi opened this issue Mar 17, 2014 · 6 comments

Comments

@shibumi
Copy link

shibumi commented Mar 17, 2014

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 👍

Chris

@gdbinit
Copy link
Owner

gdbinit commented Mar 17, 2014

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
Copy link
Author

shibumi commented Mar 17, 2014

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
Copy link
Owner

gdbinit commented Mar 17, 2014

I have no idea, probably some setting conflict.

@shibumi
Copy link
Author

shibumi commented Mar 17, 2014

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
Copy link
Owner

gdbinit commented Mar 25, 2014

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
Copy link

kmlob commented Jan 19, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants