Re: The return address of strtok is out of bounds in gdb

Andreas Schwab <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
Yao Qi <[email protected]> writes:

> In your case, I suspect GDB prepares the incorrect arguments for
> function strtok due to lack of debugging information, so you'll see
> the error.

Probably just the unknown return type, which defaults to int, so you get
truncation to 32 bits.

> You can get your libc debug info installed, or wrap up strktok like
> this in your program,
>
> char *
> my_strtok(char *str, const char *delim)
> {
>   return strtok (str, delim);
> }
>
> and in gdb,
>
> (gdb) p p1 = my_strtok(a0, se)

Or add a cast to the expected type:

(gdb) p p1 = ((char *(*)())strtok)(a0, se)

Andreas.

-- 
Andreas Schwab, SUSE Labs, [email protected]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.