From: dwk <dwks42@gmail.com>
To: Paramjot Oberoi <paramjot@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: How to Read Program Architecture from GDB/MI?
Date: Mon, 25 Jul 2016 17:27:00 -0000 [thread overview]
Message-ID: <CAPkwjGvAT7Zdzij92BPms+LAWPN8dbsJYTzY6qq=CwxZLdw0tw@mail.gmail.com> (raw)
In-Reply-To: <CAAtmCDCsZ5KPt3wDjuYq56cFoMEm6g9ZA6VORNbhuDo678VPwg@mail.gmail.com>
This is a bug in gdb/cli/cli-setshow.c. The current code reads
647 /* FIXME: cagney/2005-02-10: Need to split this in half: code to
648 convert the value into a string (esentially the above); and
649 code to print the value out. For the latter there should be
650 MI and CLI specific versions. */
651
652 if (ui_out_is_mi_like_p (uiout))
653 ui_out_field_stream (uiout, "value", stb);
654 else
655 {
656 char *value = ui_file_xstrdup (stb, NULL);
657
658 make_cleanup (xfree, value);
659 if (c->show_value_func != NULL)
660 c->show_value_func (gdb_stdout, from_tty, c, value);
661 else
662 deprecated_show_value_hack (gdb_stdout, from_tty, c, value);
663 }
The if statement is a special case for GDB/MI. It seems to prepare to
generate a value but then never write anything. My guess is that this
code was supposed to generate a nicely parsable version of the string. In
the case of "-gdb-show architecture", there is a c->show_value_func
(show_architecture) to call which prints "unfriendly" output. I tried
playing with different code here but the simplest fix seems to be to
disable the if statement entirely (add 0&& to its test). Then your
"show architecture" command works correctly.
(gdb) interpreter-exec mi "-gdb-show architecture"
~"The target architecture is set automatically (currently i386)\n"
^done
(gdb)
I don't know what cagney was worrying about when this split occurred,
but given that it was in 2005 it may no longer be an issue. Perhaps
try disabling the if statement as I suggested and see if other problems
crop up.
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index eb17158..8d9b691 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -649,7 +649,7 @@ do_show_command (const char *arg, int from_tty,
struct cmd_list_element *c)
code to print the value out. For the latter there should be
MI and CLI specific versions. */
- if (ui_out_is_mi_like_p (uiout))
+ if (0 && ui_out_is_mi_like_p (uiout))
ui_out_field_stream (uiout, "value", stb);
else
{
Cheers.
~~ dwk
On Mon, Jul 25, 2016 at 1:30 AM, Paramjot Oberoi <paramjot@gmail.com> wrote:
> Hi all,
>
> I am attempting to get the CPU architecture of the currently debugged
> program via a GDB/MI command. I'm not sure what's I'm doing wrong:
>
> Console interpreter looks good:
> (gdb) show architecture
> The target architecture is set automatically (currently i386)
>
> MI interpreter succeeds without any data:
> (gdb) interpreter-exec mi "-gdb-show architecture"
> ^done
>
> If I set the arch to auto, then query with MI I get "auto" back...:
> (gdb) set arch auto
> The target architecture is set automatically (currently i386)
> (gdb) interpreter-exec mi "-gdb-show architecture"
> ^done,value="auto"
>
> Any advice on how I can query the architecture in GDB/MI mode? Thanks
> in advance, I appreciate it.
next prev parent reply other threads:[~2016-07-25 17:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-25 5:31 Paramjot Oberoi
2016-07-25 17:27 ` dwk [this message]
2016-07-26 6:27 ` Paramjot Oberoi
2016-07-26 8:09 ` Andrew Burgess
2016-07-26 18:36 ` Paramjot Oberoi
2016-07-26 23:22 ` Andrew Burgess
2016-07-28 5:32 ` Paramjot Oberoi
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='CAPkwjGvAT7Zdzij92BPms+LAWPN8dbsJYTzY6qq=CwxZLdw0tw@mail.gmail.com' \
--to=dwks42@gmail.com \
--cc=gdb@sourceware.org \
--cc=paramjot@gmail.com \
/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