Bug 14513

Summary: setting extended-prompt triggers spurious newline to be emitted
Product: gdb Reporter: Mike Frysinger <vapier>
Component: pythonAssignee: Phil Muldoon <pmuldoon>
Status: RESOLVED FIXED    
Severity: minor CC: pmuldoon, seb93250, tromey, tromey
Priority: P2    
Version: HEAD   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Mike Frysinger 2012-08-23 18:32:06 UTC
$ gdb -nx -q
(gdb) set extended-prompt (gdb-new) 

(gdb-new) 

what's with that newline after the set command ?  if i do the same thing with my .gdbinit:
set extended-prompt (gdb-new) 

when i launch gdb, i get:
$ gdb -q

(gdb-new) 

looking at the code, it appears to be coming from python/py-param.c's get_set_value:
  fprintf_filtered (gdb_stdout, "%s\n", set_doc_string);

the set_doc_string here is empty, so we just get an empty newline printed out.

i've never looked through the python code before to suggest a suitable fix ...
Comment 1 Tom Tromey 2012-08-24 18:20:11 UTC
That code seems bogus to me.
I don't understand why it ought to print anything at all.
Comment 2 Tom Tromey 2015-05-04 17:05:52 UTC
The discussion in late 2013 seems to have petered out.

I've been using this locally:

diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index 06b9ae9..b395f9d 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -387,8 +387,12 @@ get_set_value (char *args, int from_tty,
       set_doc_string  = get_doc_string (obj, set_doc_cst);
     }
 
+#if 0
+  /* See https://sourceware.org/bugzilla/show_bug.cgi?id=14513.
+     There's no reason to print anything here.  */
   make_cleanup (xfree, set_doc_string);
   fprintf_filtered (gdb_stdout, "%s\n", set_doc_string);
+#endif
 
   Py_XDECREF (set_doc_func);
   do_cleanups (cleanup);
Comment 3 Tom Tromey 2015-05-04 19:45:30 UTC
> +#if 0
> +  /* See https://sourceware.org/bugzilla/show_bug.cgi?id=14513.
> +     There's no reason to print anything here.  */
>    make_cleanup (xfree, set_doc_string);

Though of course the #if should come after making the cleanup.
Comment 4 Tom Tromey 2018-09-15 06:20:33 UTC
This was finally fixed by commit 984ee559a26e138d8bcc1f850c1cacb9eded2b1c.