86
Chapter 10. Examining Data
We can use the
show charset
command to see what character sets gdb is currently using to interpret
and display characters and strings:
(gdb) show charset
The current host and target character set is ‘ISO-8859-1’.
(gdb)
For the sake of printing this manual, let’s use ascii as our initial character set:
(gdb) set charset ASCII
(gdb) show charset
The current host and target character set is ‘ASCII’.
(gdb)
Let’s assume that ascii is indeed the correct character set for our host system -- in other words, let’s as-
sume that if gdb prints characters using the ascii character set, our terminal will display them properly.
Since our current target character set is also ascii, the contents of
ascii_hello
print legibly:
(gdb) print ascii_hello
$1 = 0x401698 "Hello, world!\n"
(gdb) print ascii_hello[0]
$2 = 72 ’H’
(gdb)
gdb uses the target character set for character and string literals you use in expressions:
(gdb) print ’+’
$3 = 43 ’+’
(gdb)
The ascii character set uses the number 43 to encode the
+
character.
gdb relies on the user to tell it which character set the target program uses. If we print
ibm1047_hello
while our target character set is still ascii, we get jibberish:
(gdb) print ibm1047_hello
$4 = 0x4016a8 "\310\205\223\223\226k@\246\226\231\223\204Z%"
(gdb) print ibm1047_hello[0]
$5 = 200 ’\310’
(gdb)
If we invoke the
set target-charset
followed by [TAB][TAB], gdb tells us the character sets it
supports:
(gdb) set target-charset
ASCII
EBCDIC-US
IBM1047
ISO-8859-1
(gdb) set target-charset
Содержание ENTERPRISE LINUX 4 - DEVELOPER TOOLS GUIDE
Страница 1: ...Red Hat Enterprise Linux 4 Debugging with gdb ...
Страница 12: ...2 Chapter 1 Debugging with gdb ...
Страница 28: ...18 Chapter 4 Getting In and Out of gdb ...
Страница 34: ...24 Chapter 5 gdb Commands ...
Страница 44: ...34 Chapter 6 Running Programs Under gdb ...
Страница 68: ...58 Chapter 8 Examining the Stack ...
Страница 98: ...88 Chapter 10 Examining Data ...
Страница 112: ...102 Chapter 12 Tracepoints ...
Страница 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Страница 138: ...128 Chapter 14 Using gdb with Different Languages ...
Страница 144: ...134 Chapter 15 Examining the Symbol Table ...
Страница 170: ...160 Chapter 19 Debugging remote programs ...
Страница 198: ...188 Chapter 21 Controlling gdb ...
Страница 204: ...194 Chapter 22 Canned Sequences of Commands ...
Страница 206: ...196 Chapter 23 Command Interpreters ...
Страница 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Страница 296: ...286 Chapter 27 gdb Annotations ...
Страница 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Страница 322: ...312 Chapter 30 Using History Interactively ...
Страница 362: ...352 Appendix D gdb Remote Serial Protocol ...
Страница 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Страница 386: ...376 Appendix G GNU Free Documentation License ...
Страница 410: ......