Bug 16465 - -dprintf-insert does not store the string for pending dprintf
Summary: -dprintf-insert does not store the string for pending dprintf
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: breakpoints (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Antoine Tremblay
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-18 22:29 UTC by Marc Khouzam
Modified: 2015-06-12 12:53 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Khouzam 2014-01-18 22:29:52 UTC
Bug 15292 fixed pending dprintf for the CLI, but it seems they don't work properly for the MI interface.   What seems to happen is that the string to print does not get stored so when the dprintf gets activated, it has nothing to print.

Below is a session that compares pending dprintf using the CLI vs MI interfaces:

> gdb.7.7 ~/runtime-TestDSF/myapp/Debug/myapp.exe
GNU gdb (GDB) 7.7.50.20140110-cvs
(gdb)  interpreter-exec mi "-dprintf-insert -f mydll.c:1 \"hello\""
&"No source file named mydll.c.\n"
^done,bkpt={number="1",type="dprintf",disp="keep",enabled="y",addr="<PENDING>",pending="mydll.c:1",times="0",original-location="mydll.c:1"}
(gdb) dprintf mydll.c:2,"hello"
No source file named mydll.c.
Make dprintf pending on future shared library load? (y or [n]) y
Dprintf 2 (mydll.c:2,"hello") pending.
(gdb) info b
Num     Type           Disp Enb Address    What
1       dprintf        keep y   <PENDING>  mydll.c:1
2       dprintf        keep y   <PENDING>  mydll.c:2,"hello"
(gdb) b 18
Breakpoint 3 at 0x400754: file ../src/myapp.c, line 18.
(gdb) r
Starting program: /home/lmckhou/runtime-TestDSF/myapp/Debug/myapp.exe 

Breakpoint 3, main () at ../src/myapp.c:18
18           handle = dlopen("/home/lmckhou/runtime-TestDSF/myLinuxDll/Debug/libmyLinuxDll", RTLD_LAZY);
(gdb) n
Error in re-setting breakpoint 1: Format string required
19           if (!handle) {
(gdb) inf b
Num     Type           Disp Enb Address            What
1       dprintf        keep y   0x00007ffff7633560 in foo at ../src/mydll.c:1
2       dprintf        keep y   0x00007ffff7633560 in foo at ../src/mydll.c:2
        printf "hello"
3       breakpoint     keep y   0x0000000000400754 in main at ../src/myapp.c:18
        breakpoint already hit 1 time
Comment 1 Sourceware Commits 2015-06-12 12:48:58 UTC
The master branch has been updated by Antoine Tremblay <hexa@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=98aa42ee02c56378cecb737d01c27adca36bf48f

commit 98aa42ee02c56378cecb737d01c27adca36bf48f
Author: Antoine Tremblay <antoine.tremblay@ericsson.com>
Date:   Fri Jun 12 07:58:47 2015 -0400

    Fix MI dprintf-insert not printing on a resolved pending location.
    
    This patch fixes the "Format string required" error when trying to print
    a dprintf on a now resolved, pending location when set via the MI interface
    even if the format string is entered correctly.
    
    This patch also adds a test case to check that issue called
    mi-dprintf-pending.exp.
    
    gdb/ChangeLog:
    
    	PR breakpoints/16465
    	* breakpoint.c (create_breakpoint): Save extra_string for
    	pending breakpoints.
    
    gdb/testsuite/ChangeLog:
    
    	PR breakpoints/16465
    	* gdb.mi/mi-dprintf-pending.c: New file.
    	* gdb.mi/mi-dprintf-pending.exp: New test.
    	* gdb.mi/mi-dprintf-pendshr.c: New file.
Comment 2 Antoine Tremblay 2015-06-12 12:53:04 UTC
Fixed by above commit