You are not logged in.
Hi all,
i use the gdb to debug a simple C program and encounter a problem as blow.
this is the source i have wrote.
int funca(void) {
char sa[] = "Hello, funca";
char *da = 0;
da = GetNextWord(sa);
printf (DEBUGFMT "sa=%s da=%s\n", DEBUGARGS, sa, da);
return 0;
}
and i compile it with the command :
cc -g -Wall main.c funca.c -o main
then i use the gdb --annotate=3 main command to run gdb
and set breakpoint with the command
b funca
and start run with the command r
then use p sa to check the variable
but the result is
(gdb) p sa
$1 = "\000\000\000\000\000\000\000\000\265\a@\000\000"
i use the show charset command to check the charset encoding of my gdb
the result is :
(gdb) show charset
The host character set is "auto; currently UTF-8".
The target character set is "auto; currently UTF-8".
The target wide character set is "auto; currently UTF-32".
have anyone encounter the same problem and have some solution to
deal with it. hope someone can give me an advice and thanks in advance.
Last edited by realfirst (2011-04-27 08:47:08)
Offline
The variable sa is not initialized at the start of funca(). Use the `step' command to run the next statement, which assigns the address of the "Hello, funca" char array to sa. Using `p sa' afterwards should give the expected result.
Offline
thank you ber_t for you immediately reply.
i have done as you said and get the right result.
Offline