public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "marc.khouzam at ericsson dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug breakpoints/18742] New: In MI, breakpoint commands produce MI output instead of CLI
Date: Thu, 30 Jul 2015 14:58:00 -0000	[thread overview]
Message-ID: <bug-18742-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=18742

            Bug ID: 18742
           Summary: In MI, breakpoint commands produce MI output instead
                    of CLI
           Product: gdb
           Version: 7.9
            Status: NEW
          Severity: normal
          Priority: P2
         Component: breakpoints
          Assignee: unassigned at sourceware dot org
          Reporter: marc.khouzam at ericsson dot com
  Target Milestone: ---

Understandably, breakpoint commands can only be in CLI format.  This makes
sense to me as bp commands are something that the user creates, and therefore
are created in CLI format.

One would expect those CLI bp commands to always output in CLI format, but when
GDB is in MI mode, the output of bp commands is in MI format, which does not
make sense to a user.

I believe GDB should know it is running bp commands and therefore should force
them to be run in a CLI interpreter, even when the global interpreter is MI.

Below is cleaned up example of the problem:

> gdb.master -i mi testing/loopfirst
~"GNU gdb (GDB) 7.10.50.20150730-cvs\n"
(gdb) l
&"l\n"
~"1\t#include <unistd.h>\n"
~"2\t#include <stdio.h>\n"
~"3\t\n"
~"4\tint j = 0;\n"
~"5\t\n"
~"6\tint main() {\n"
~"7\t    int max = 900;\n"
~"8\t    for (int i=0;i<max;i++) {\n"
~"9\t        printf(\"i is %d\\n\",i);\n"
~"10\t        sleep(1);\n"
~"11\t    }\n"
~"12\t    return 0;\n"
~"13\t}\n"
^done
(gdb) 
-break-insert 10
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000400570",func="main()",file="loopfirst.cc",fullname="/home/lmckhou/testing/loopfirst.cc",line="10",thread-groups=["i1"],times="0",original-location="/home/lmckhou/testing/loopfirst.cc:10"}
(gdb) 
-break-commands 1 "i b"
^done
(gdb)i b
&"i b\n"
~"Num     Type           Disp Enb Address            What\n"
~"1       breakpoint     keep y   0x0000000000400570 in main() at
loopfirst.cc:10\n"
~"        i b\n"
^done
(gdb)
run
&"run\n"
~"Starting program: /home/lmckhou/testing/loopfirst \n"
=thread-group-started,id="i1",pid="7764"
=thread-created,id="1",group-id="i1"
=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"
^running
*running,thread-id="all"
(gdb) 
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000400570",func="main()",file="loopfirst.cc",fullname="/home/lmckhou/testing/loopfirst.cc",line="10",thread-groups=["i1"],times="1",script={"i
b"},original-location="/home/lmckhou/testing/loopfirst.cc:10"}
~"\nBreakpoint "
~"1, main () at loopfirst.cc:10\n"
~"10\t        sleep(1);\n"
*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x0000000000400570",func="main",args=[],file="loopfirst.cc",fullname="/home/lmckhou/testing/loopfirst.cc",line="10"},thread-id="1",stopped-threads="all",core="3"
(gdb) 

========> Notice no CLI printout for 'i b' when the bp is hit

========> I then simply press <enter> and below I get the output 
========> of 'i b' but in MI format!

&"\n"
^done,BreakpointTable={nr_rows="1",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="18",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000400570",func="main()",file="loopfirst.cc",fullname="/home/lmckhou/testing/loopfirst.cc",line="10",thread-groups=["i1"],times="1",script={"i
b"},original-location="/home/lmckhou/testing/loopfirst.cc:10"}]}
(gdb) 

======> Interestingly if I force the bp command to use a CLI interpreter
======> by wrapping it in "interpreter-exec console", things work

(gdb) 
-break-commands 1 "interpreter-exec console \"i b\""
^done
(gdb) 
i b
&"i b\n"
~"Num     Type           Disp Enb Address            What\n"
~"1       breakpoint     keep y   0x0000000000400570 in main() at
loopfirst.cc:10\n"
~"        interpreter-exec console \"i b\"\n"
^done
(gdb) 
c
&"c\n"
~"Continuing.\n"
^running
*running,thread-id="all"
(gdb) 
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000000400570",func="main()",file="loopfirst.cc",fullname="/home/lmckhou/testing/loopfirst.cc",line="10",thread-groups=["i1"],times="2",script={"interpreter-exec
console \"i b\""},original-location="/home/lmckhou/testing/loopfirst.cc:10"}
~"\nBreakpoint "
~"1, main () at loopfirst.cc:10\n"
~"10\t        sleep(1);\n"
*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x0000000000400570",func="main",args=[],file="loopfirst.cc",fullname="/home/lmckhou/testing/loopfirst.cc",line="10"},thread-id="1",stopped-threads="all",core="3"
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000000000400570 in main() at loopfirst.cc:10
        breakpoint already hit 2 times
        interpreter-exec console "i b"
~"(gdb) "
(gdb) 

======> Above we can see the CLI output of 'i b' when the bp is hit.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


             reply	other threads:[~2015-07-30 14:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-30 14:58 marc.khouzam at ericsson dot com [this message]
2015-07-30 14:59 ` [Bug breakpoints/18742] " marc.khouzam at ericsson dot com
2022-08-12 18:09 ` tromey at sourceware dot org

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=bug-18742-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).