This is the mail archive of the 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]

Re: [PATCH] Fix MI dprintf-insert not printing when a location is pending.

On 03/26/2015 03:10 PM, Keith Seitz wrote:
On 03/26/2015 09:47 AM, Antoine Tremblay wrote:

    PR breakpoints/16465
    * breakpoint.c (create_breakpoint): Fix missing extra_string.

This is a real nit, so please don't go making any changes here unless a
maintainer requests it, but this changelog entry doesn't really explain
the change you've made. ["Save `extra_string' for pending breakpoints."
is much more descriptive/helpful.]

Indeed why not :)

@@ -9783,10 +9786,16 @@ create_breakpoint (struct gdbarch *gdbarch,
            cond_string = xstrdup (cond_string);
            make_cleanup (xfree, cond_string);
+      /* Create a private copy of any extra string.  */
+      if (extra_string)

We explicitly test against NULL for pointers. [I know there are quite a
few violations of this in this function. All are awaiting an
easy/obvious separate cleanup. :-)]

Yes, it will look weird to just change the one I added though...
That's what I did anyway so that the others can be part of a cleanup patch.

+        {
+          extra_string = xstrdup (extra_string);
+          make_cleanup (xfree, extra_string);
+        }
        b->cond_string = cond_string;
+      b->extra_string = extra_string;
        b->thread = thread;
-      b->extra_string = NULL;
        b->ignore_count = ignore_count;
        b->disposition = tempflag ? disp_del : disp_donttouch;
        b->condition_not_parsed = 1;

FWIW, I have pretty much an identical change in my locations API
refactor, where I ran across this problem (and more) during testing.

:) Glad it can remove unrelated stuff from your patch

diff --git a/gdb/testsuite/gdb.mi/mi-dprintf-pending.exp
new file mode 100644
index 0000000..6832f1d
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-dprintf-pending.exp
@@ -0,0 +1,77 @@
+if {[skip_shlib_tests]} {
+if [get_compiler_info] {
+if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != "" } {
+if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable
$exec_opts] != ""} {

This is a /big/ nitpick, but it's something that consistently irritates
me: compare the coding style of the four statements above. While there
is no "rule" governing which is most correct/desired, I always use the
first. I would ask you to choose one style and be consistent, but I am
not asking you to make any changes right now. Just please keep this in
mind in future patches.

I really had not noticed that, thanks for making me notice! I must confess I do a lot of copy & paste when writing a test. The if {[func]} seems indeed the one used in all the tcl docs so I'll use that.

+# Set pending dprintf via MI.
+mi_gdb_test "-dprintf-insert -f pendfunc1 \"hello\"" \
+    "mi set dprintf"
+mi_gdb_test "-break-insert $bp_location1" ".*" "mi insert breakpoint

Is it possible to use mi_make_breakpoint for these tests?

Unfortunately for the dprintf one mi_make_breakpoint doesn't support pending breakpoints, it creates something like :

But with pending funcs it should be pending= ...

It could be the subject of another patch to add that support.

I used mi_create_breakpoint for the other breakpoint now

+set msg "mi dprintf"
+gdb_expect {
+    -re ".*~\"hello\"" {
+    pass $msg
+    }
+    -re ".*$mi_gdb_prompt$" {
+    fail $msg
+    }
+    timeout {
+    fail $msg
+    }

This a pretty common test suite idiom, I think. Can mi_gdb_test be used
instead of gdb_expect?

That I can't since mi_gdb_test requires a command and in this case I'm just doing expect on that comes after mi_run_cmd, there's no command associated with it..

+mi_expect_stop ".*" ".*" ".*" ".*" ".*" "" "$msg stop"
diff --git a/gdb/testsuite/gdb.mi/mi-dprintf-pendshr.c
new file mode 100644
index 0000000..fe49a8d
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-dprintf-pendshr.c
@@ -0,0 +1,27 @@
+/* This testcase is part of GDB, the GNU debugger.
+   Copyright 2015 Free Software Foundation, Inc.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   GNU General Public License for more details.
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see
<>.  */
+pendfunc1 ()
+pendfunc ()
+  pendfunc1();

IIRC, we are now requiring test case conformance to the coding standard.
[At least, that's what I've been told in the past.] So, "(void)" in the
function decls and spaces between function names and '('. [I don't think
we're requiring function comments for trivial stuff like this, though.]

Indeed that's really my old habits dying hard... fixed sorry about that.

Thanks for the review ! , Patch v2 is coming up in a minute as a separate email...


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