This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] printcmd.c (ui_printf): make internalvar string can be printf and eval when inferior cannot alloc memory
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Hui Zhu <teawater at gmail dot com>
- Cc: Tom Tromey <tromey at redhat dot com>, gdb-patches ml <gdb-patches at sourceware dot org>
- Date: Wed, 7 Sep 2011 11:58:50 +0200
- Subject: Re: [PATCH] printcmd.c (ui_printf): make internalvar string can be printf and eval when inferior cannot alloc memory
- References: <m339hz1i9v.fsf@fleche.redhat.com> <CANFwon0wqsOirAz078-y+ti-WFNHGJ45F_-HfS89ViYM02UDFA@mail.gmail.com> <m3fwl2ebq1.fsf@fleche.redhat.com> <CANFwon1h3fytbmBB5DiXjLt=pa7nt_JTuFhuGDxbVjCS=7FwtQ@mail.gmail.com> <m3k4acaysh.fsf@fleche.redhat.com> <CANFwon3kjh4HBH59BXyM=R451iAozjJjJ1kACg=Jbv607PV6aA@mail.gmail.com> <m3k4a9lc8i.fsf@fleche.redhat.com> <CANFwon0=Trk5i-j4MRPOAXx0AeJaqsZk6Tg052n9_EUEiQ=LrQ@mail.gmail.com> <20110906085007.GA19880@host1.jankratochvil.net> <CANFwon35OBYsAnbEPewqo9-ussYkGq8WDxPeTKnb0Cu=LWxUfA@mail.gmail.com>
On Wed, 07 Sep 2011 04:55:32 +0200, Hui Zhu wrote:
> +#Test printing internal var values with printf
> +proc test_printf_with_internalvar {} {
> + gdb_test "set \$a={\'a\',\'b\'}" ""
Escaping of ' is redundant.
> + gdb_test "printf \"%s\\n\", \$a" "ab"
I would find easier { and } instead of " and " to prevent so many backslashes
but opinions differ on it, FYI:
gdb_test_no_output {set $a={'a','b'}}
gdb_test {printf "%s\n", $a} "ab"
Still this testcase FAILs for me:
printf "%s\n", $a^M
abX^M
(gdb) FAIL: gdb.base/printcmds.exp: printf "%s\n", $a
Where X is some binary unprintable garbage character, not sure which way you
plan to fix it (maybe some `error' call if there is no zero-terminator?).
Thanks,
Jan