* Can't print in gdb
@ 2020-12-08 1:52 Olivia Nelson
2020-12-08 8:58 ` Andreas Schwab
2020-12-08 11:25 ` Shahab Vahedi
0 siblings, 2 replies; 3+ messages in thread
From: Olivia Nelson @ 2020-12-08 1:52 UTC (permalink / raw)
To: gdb
I'm trying to print with a prefix, how can I do that? I've tried to
use + or printf, none of them works:
(gdb) ptype substr
type = struct string {
uint8 *str;
int len;
}
(gdb) p substr
$1 = 0x111111 "xxx=0"
(gdb) printf "%s\n", substr
Value can't be converted to integer.
(gdb) p "a" + substr
A syntax error in expression, near `'.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Can't print in gdb
2020-12-08 1:52 Can't print in gdb Olivia Nelson
@ 2020-12-08 8:58 ` Andreas Schwab
2020-12-08 11:25 ` Shahab Vahedi
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2020-12-08 8:58 UTC (permalink / raw)
To: Olivia Nelson via Gdb
On Dez 08 2020, Olivia Nelson via Gdb wrote:
> I'm trying to print with a prefix, how can I do that? I've tried to
> use + or printf, none of them works:
You can use output to print a value without newline.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Can't print in gdb
2020-12-08 1:52 Can't print in gdb Olivia Nelson
2020-12-08 8:58 ` Andreas Schwab
@ 2020-12-08 11:25 ` Shahab Vahedi
1 sibling, 0 replies; 3+ messages in thread
From: Shahab Vahedi @ 2020-12-08 11:25 UTC (permalink / raw)
To: Olivia Nelson; +Cc: gdb
You will need either to typecast:
(gdb) printf "prefix:%s\n", (char *) substr
Or use the member variable:
(gdb) printf "prefix:%s\n", substr.str
Cheers,
Shahab
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-08 11:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 1:52 Can't print in gdb Olivia Nelson
2020-12-08 8:58 ` Andreas Schwab
2020-12-08 11:25 ` Shahab Vahedi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).