This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix create pending breakpoint handle extra_string issue if not parse_condition_and_thread


Hi,

I found that behavior is not right is create pending breakpoint handle extra_string issue if not parse_condition_and_thread.
This issue cannot be reproduce with normal interpreter command "b" because it create breakpoint with parse_condition_and_thread.
But mi command "-break-insert" have this issue, for example:
gdb/testsuite$ gdb -i mi gdb.base/pending
(gdb)
-break-insert -f -c k>0 "pendfunc1 if k == 0"
&"Function \"pendfunc1\" not defined.\n"
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="<PENDING>",pending="pendfunc1 if k == 0",cond="k>0",times="0",original-location="pendfunc1 if k == 0"}
(gdb)
info b
&"info b\n"
~"Num     Type           Disp Enb Address    What\n"
~"1       breakpoint     keep y   <PENDING>  pendfunc1 if k == 0\n"
~"\tstop only if k>0\n"
^done
(gdb)
r
&"r\n"
~"Starting program: /home/teawater/gdb/bgdbno/gdb/testsuite/gdb.base/pending \n"
=thread-group-started,id="i1",pid="7861"
=thread-created,id="1",group-id="i1"
^running
*running,thread-id="all"
=library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1"
(gdb)
=library-loaded,id="/home/teawater/gdb/bgdbno/gdb/testsuite/gdb.base/pendshr.sl",target-name="/home/teawater/gdb/bgdbno/gdb/testsuite/gdb.base/pendshr.sl",host-name="/home/teawater/gdb/bgdbno/gdb/testsuite/gdb.base/pendshr.sl",symbols-loaded="0",thread-group="i1"
=library-loaded,id="/lib/x86_64-linux-gnu/libc.so.6",target-name="/lib/x86_64-linux-gnu/libc.so.6",host-name="/lib/x86_64-linux-gnu/libc.so.6",symbols-loaded="0",thread-group="i1"
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00007ffff7bd8607",func="pendfunc1",file="../../../src/gdb/testsuite/gdb.base/pendshr.c",fullname="/home/teawater/gdb/src/gdb/testsuite/gdb.base/pendshr.c",line="22",thread-groups=["i1"],cond="k == 0",times="0",original-location="pendfunc1 if k == 0"}
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00007ffff7bd8607",func="pendfunc1",file="../../../src/gdb/testsuite/gdb.base/pendshr.c",fullname="/home/teawater/gdb/src/gdb/testsuite/gdb.base/pendshr.c",line="22",thread-groups=["i1"],cond="k == 0",times="1",original-location="pendfunc1 if k == 0"}
*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x00007ffff7bd8607",func="pendfunc1",args=[{name="x",value="3"}],file="../../../src/gdb/testsuite/gdb.base/pendshr.c",fullname="/home/teawater/gdb/src/gdb/testsuite/gdb.base/pendshr.c",line="22"},thread-id="1",stopped-threads="all",core="6"
info b
&"info b\n"
~"Num     Type           Disp Enb Address            What\n"
~"1       breakpoint     keep y   0x00007ffff7bd8607 in pendfunc1 at ../../../src/gdb/testsuite/gdb.base/pendshr.c:22\n"
~"\tstop only if k == 0\n"
~"\tbreakpoint already hit 1 time\n"
^done
(gdb)

With 2 "info b", you can found that condition "k>0" is overwrite by "k==0".

So I post a patch to fix this issue.
Please help me review it.

Best,
Hui

2013-03-24  Hui Zhu  <hui@codesourcery.com>

	* breakpoint.c (create_breakpoint): Handle extra_string if
	parse_condition_and_thread.
	(addr_string_to_sals): Add check for pending breakpoints.

--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9687,7 +9687,11 @@ create_breakpoint (struct gdbarch *gdbar
b->addr_string = copy_arg;
       if (parse_condition_and_thread)
-	b->cond_string = NULL;
+        {
+	  b->cond_string = NULL;
+	  b->extra_string = NULL;
+	  b->condition_not_parsed = 1;
+	}
       else
 	{
 	  /* Create a private copy of condition string.  */
@@ -9697,11 +9701,17 @@ create_breakpoint (struct gdbarch *gdbar
 	      make_cleanup (xfree, cond_string);
 	    }
 	  b->cond_string = cond_string;
+	  /* Create a private copy of extra string.  */
+	  if (extra_string)
+	    {
+	      extra_string = xstrdup (extra_string);
+	      make_cleanup (xfree, extra_string);
+	    }
+	  b->extra_string = extra_string;
+	  b->condition_not_parsed = 0;
 	}
-      b->extra_string = NULL;
       b->ignore_count = ignore_count;
       b->disposition = tempflag ? disp_del : disp_donttouch;
-      b->condition_not_parsed = 1;
       b->enable_state = enabled ? bp_enabled : bp_disabled;
       if ((type_wanted != bp_breakpoint
            && type_wanted != bp_hardware_breakpoint) || thread != -1)
@@ -14166,7 +14176,8 @@ addr_string_to_sals (struct breakpoint *
 	 breakpoint being disabled, and don't want to see more
 	 errors.  */
       if (e.error == NOT_FOUND_ERROR
-	  && (b->condition_not_parsed
+	  && (b->condition_not_parsed
+	      || (b->loc == NULL || b->loc->shlib_disabled)
 	      || (b->loc && b->loc->shlib_disabled)
 	      || (b->loc && b->loc->pspace->executing_startup)
 	      || b->enable_state == bp_disabled))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]