Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Hui Zhu <teawater@gmail.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Tom Tromey <tromey@redhat.com>,
	gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: [PATCH] printcmd.c (ui_printf): make internalvar string can be printf and eval when inferior cannot alloc memory
Date: Fri, 09 Sep 2011 07:59:00 -0000	[thread overview]
Message-ID: <CANFwon17PEDOEe7JSTfne_ONgsD1n5DW-5cRhLxHayfFkAZDTA@mail.gmail.com> (raw)
In-Reply-To: <20110907095850.GA25473@host1.jankratochvil.net>

[-- Attachment #1: Type: text/plain, Size: 1300 bytes --]

On Wed, Sep 7, 2011 at 17:58, Jan Kratochvil <jan.kratochvil@redhat.com> wrote:
> 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"
>

Thanks for your help Jan.

I make a new patch according to it.  And I add more
test_printf_with_internalvar in the end of test because I think it can
test this issue after the inferior exec.
>
> 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?).

I didn't got this issue.  Could you post more info about this issue?

>
>
> Thanks,
> Jan
>

Best,
Hui

2011-09-07  Hui Zhu  <teawater@gmail.com>

	* gdb.base/printcmds.exp: Add test for printing internal var
	values with printf.

[-- Attachment #2: test-v-string.txt --]
[-- Type: text/plain, Size: 965 bytes --]

---
 testsuite/gdb.base/printcmds.exp |    9 +++++++++
 1 file changed, 9 insertions(+)

--- a/testsuite/gdb.base/printcmds.exp
+++ b/testsuite/gdb.base/printcmds.exp
@@ -775,6 +775,12 @@ proc test_printf_with_dfp {} {
     gdb_test "printf \"%DDf\\n\",1.2E6144dl" "1.200000000000000000000000000000000E\\+6144"
 }
 
+#Test printing internal var values with printf
+proc test_printf_with_internalvar {} {
+    gdb_test_no_output {set $a={'a','b'}}
+    gdb_test {printf "%s\n", $a} "ab"
+}
+
 # Escape a left curly brace to prevent it from being interpreted as 
 # the beginning of a bound
 proc gdb_test_escape_braces { args } {
@@ -816,6 +822,8 @@ if { [test_compiler_info "armcc-*"] } {
 }
 gdb_test "p ctable1\[120\]" "120 'x'" "p ctable1\[120\] #1"
 
+test_printf_with_internalvar
+
 gdb_load ${binfile}
 
 if ![runto_main] then {
@@ -842,3 +850,4 @@ test_print_array_constants
 test_print_enums
 test_printf
 test_printf_with_dfp
+test_printf_with_internalvar

  reply	other threads:[~2011-09-09  7:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-20 10:37 Hui Zhu
2011-07-21 20:43 ` Tom Tromey
2011-08-14 15:10   ` Hui Zhu
2011-08-15 19:06     ` Tom Tromey
2011-08-16  4:58       ` Hui Zhu
2011-08-17 14:38         ` Tom Tromey
2011-08-18  2:54           ` Hui Zhu
2011-08-19 14:15             ` Tom Tromey
2011-09-06  8:50               ` Hui Zhu
2011-09-06 13:44                 ` Jan Kratochvil
2011-09-07  9:27                   ` Hui Zhu
2011-09-07 10:02                     ` Jan Kratochvil
2011-09-09  7:59                       ` Hui Zhu [this message]
2011-09-09 12:32                         ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANFwon17PEDOEe7JSTfne_ONgsD1n5DW-5cRhLxHayfFkAZDTA@mail.gmail.com \
    --to=teawater@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox