From: teawater <teawater@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: tromey@redhat.com, dje@google.com, pedro@codesourcery.com,
drow@false.org, gdb-patches@sourceware.org
Subject: Re: [RFC] disassemble-next-line
Date: Mon, 16 Mar 2009 07:59:00 -0000 [thread overview]
Message-ID: <daef60380903152351n71100aecp8fbe3210f5e32a95@mail.gmail.com> (raw)
In-Reply-To: <ubps5sqmf.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1521 bytes --]
Hi Eli,
I had make the patches for code and doc.
Please help me review it.
Thanks,
Hui
On Fri, Mar 13, 2009 at 17:45, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Fri, 13 Mar 2009 07:55:59 +0800
>> From: teawater <teawater@gmail.com>
>> Cc: Pedro Alves <pedro@codesourcery.com>, Daniel Jacobowitz <drow@false.org>,
>> "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
>>
>> + add_setshow_enum_cmd ("disassemble-next-line", class_run,
>> + disassemble_next_line_enum,
>> + &disassemble_next_line, _("\
>> +Set debugger's willingness to use disassemble-next-line."), _("\
>> +Show debugger's willingness to use disassemble-next-line."), _("\
>
> This self-referential doc string is confusing. I suggest to change to
> something like this:
>
> Set whether to disassemble next source line when execution stops.
>
> and similarly for Show.
>
>> +If ON, GDB will disassemble the next source line when execution\n\
>> +stops.\n\
>
> If ON, GDB will display disassembly of the next source line when\n\
> execution of the program being debugged stops.\n\
>
>> +If AUTO (which is the default) or the next source line cannot be\n\
>> +ascertained, the next instruction will be disassembled instead."),
>
> What does it mean ``the next source line cannot be ascertained''?
>
> In any case, instead of ``the next instruction will be disassembled
> instead'', I suggest ``display disassembly of the next instruction
> instead.''
>
[-- Attachment #2: disassemble-next-line.txt --]
[-- Type: text/plain, Size: 3882 bytes --]
---
stack.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
--- a/stack.c
+++ b/stack.c
@@ -45,6 +45,7 @@
#include "valprint.h"
#include "gdbthread.h"
#include "cp-support.h"
+#include "disasm.h"
#include "gdb_assert.h"
#include <ctype.h>
@@ -456,6 +457,58 @@ set_current_sal_from_frame (struct frame
}
}
+/* If ON, GDB will display disassembly of the next source line when
+ execution of the program being debugged stops.
+ If AUTO (which is the default) or the next source line cannot be
+ ascertained, display disassembly of the next instruction
+ instead. */
+
+static enum auto_boolean disassemble_next_line;
+
+static void
+show_disassemble_next_line (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c,
+ const char *value)
+{
+ fprintf_filtered (file, _("\
+Debugger's willingness to use disassemble-next-line is %s.\n"),
+ value);
+}
+
+/* Show assembly codes; stub for catch_errors. */
+
+struct gdb_disassembly_stub_args
+{
+ int how_many;
+ CORE_ADDR low;
+ CORE_ADDR high;
+};
+
+static void
+gdb_disassembly_stub (void *args)
+{
+ struct gdb_disassembly_stub_args *p = args;
+ gdb_disassembly (uiout, 0, 0, p->how_many, p->low, p->high);
+}
+
+/* Use TRY_CATCH to catch the exception from the gdb_disassembly
+ because it will be broken by filter sometime. */
+
+static void
+do_gdb_disassembly (int how_many, CORE_ADDR low, CORE_ADDR high)
+{
+ volatile struct gdb_exception exception;
+ struct gdb_disassembly_stub_args args;
+
+ args.how_many = how_many;
+ args.low = low;
+ args.high = high;
+ TRY_CATCH (exception, RETURN_MASK_ALL)
+ {
+ gdb_disassembly_stub (&args);
+ }
+}
+
/* Print information about frame FRAME. The output is format according
to PRINT_LEVEL and PRINT_WHAT and PRINT ARGS. The meaning of
PRINT_WHAT is:
@@ -533,6 +586,13 @@ print_frame_info (struct frame_info *fra
source_print = (print_what == SRC_LINE || print_what == SRC_AND_LOC);
+ /* If disassemble-next-line is set to auto or on and doesn't have
+ the line debug messages for $pc, output current instructions. */
+ if ((disassemble_next_line == AUTO_BOOLEAN_AUTO
+ || disassemble_next_line == AUTO_BOOLEAN_TRUE)
+ && source_print && !sal.symtab)
+ do_gdb_disassembly (1, get_frame_pc (frame), get_frame_pc (frame) + 1);
+
if (source_print && sal.symtab)
{
int done = 0;
@@ -569,6 +629,11 @@ print_frame_info (struct frame_info *fra
print_source_lines (sal.symtab, sal.line, sal.line + 1, 0);
}
}
+
+ /* If disassemble-next-line is set to on and there is line
+ messages, output assembly codes for next line. */
+ if (disassemble_next_line == AUTO_BOOLEAN_TRUE)
+ do_gdb_disassembly (-1, get_frame_pc (frame), sal.end);
}
if (print_what != LOCATION)
@@ -2071,6 +2136,20 @@ Usage: func <name>\n"));
_("Show printing of non-scalar frame arguments"),
NULL, NULL, NULL, &setprintlist, &showprintlist);
+ add_setshow_auto_boolean_cmd ("disassemble-next-line", class_stack,
+ &disassemble_next_line, _("\
+Set whether to disassemble next source line when execution stops."), _("\
+Show whether to disassemble next source line when execution stops."), _("\
+If ON, GDB will display disassembly of the next source line when\n\
+execution of the program being debugged stops.\n\
+If AUTO (which is the default) or the next source line cannot be\n\
+ascertained, display disassembly of the next instruction\n\
+instead."),
+ NULL,
+ show_disassemble_next_line,
+ &setlist, &showlist);
+ disassemble_next_line = AUTO_BOOLEAN_AUTO;
+
#if 0
add_cmd ("backtrace-limit", class_stack, set_backtrace_limit_command, _(\
"Specify maximum number of frames for \"backtrace\" to print by default."),
[-- Attachment #3: disassemble-next-line-doc.txt --]
[-- Type: text/plain, Size: 1458 bytes --]
---
doc/gdb.texinfo | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
--- a/doc/gdb.texinfo
+++ b/doc/gdb.texinfo
@@ -5910,7 +5910,9 @@ directories in one command.
You can use the command @code{info line} to map source lines to program
addresses (and vice versa), and the command @code{disassemble} to display
-a range of addresses as machine instructions. When run under @sc{gnu} Emacs
+a range of addresses as machine instructions. You can use the command
+@code{set disassemble-next-line} to set whether to disassemble next
+source line when execution stops. When run under @sc{gnu} Emacs
mode, the @code{info line} command causes the arrow to point to the
line specified. Also, @code{info line} prints addresses in symbolic form as
well as hex.
@@ -6040,6 +6042,19 @@ assemblers for x86-based targets.
Show the current setting of the disassembly flavor.
@end table
+@table @code
+@kindex set disassemble-next-line
+@kindex show disassemble-next-line
+@item set disassemble-next-line
+@itemx show disassemble-next-line
+Control whether or not @value{GDBN} will disassemble next source line
+when execution stops. If ON, GDB will display disassembly of the next
+source line when execution of the program being debugged stops.
+If AUTO (which is the default) or the next source line cannot be
+ascertained, display disassembly of the next instruction
+instead.
+@end table
+
@node Data
@chapter Examining Data
next prev parent reply other threads:[~2009-03-16 6:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-08 5:34 teawater
2009-03-09 15:29 ` Tom Tromey
2009-03-09 19:41 ` Eli Zaretskii
2009-03-10 2:45 ` Doug Evans
2009-03-11 8:32 ` teawater
2009-03-12 23:57 ` teawater
2009-03-13 0:50 ` Pedro Alves
2009-03-13 5:54 ` teawater
2009-03-13 9:53 ` Eli Zaretskii
2009-03-16 7:59 ` teawater [this message]
2009-03-16 19:22 ` Eli Zaretskii
2009-03-16 19:40 ` Doug Evans
2009-03-16 19:54 ` Eli Zaretskii
2009-03-17 3:15 ` teawater
2009-03-17 4:52 ` Eli Zaretskii
2009-03-17 5:30 ` teawater
2009-03-17 6:21 ` teawater
2009-03-17 19:03 ` Eli Zaretskii
2009-03-17 23:26 ` teawater
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=daef60380903152351n71100aecp8fbe3210f5e32a95@mail.gmail.com \
--to=teawater@gmail.com \
--cc=dje@google.com \
--cc=drow@false.org \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=pedro@codesourcery.com \
--cc=tromey@redhat.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