From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Subject: [RFA] Add option to skip prologue in "break FILE:LINENO" (take 2)
Date: Thu, 10 Jan 2008 15:13:00 -0000 [thread overview]
Message-ID: <20080110151312.GC13181@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1606 bytes --]
Hello,
Following a request for comments regarding a proposed change of behavior
when inserting a breakpoint on a specific line number, we received a
variety of comments, and it appears very clearly that the proposal
was at the very least controversial.
So, here is a new proposal where the existing behavior is preserved.
A new set/show command is introduced to allow the user to configure
GDB to activate the new proposed behavior:
(gdb) set/show breakpoint skip-prologue
The help text for this command explains the purpose of this option:
Set the debugger behavior when inserting a breakpoint on a specific line.
When inserting a breakpoint on a specific line number that corresponds
to the prologue of a function, the debugger will automatically adjust
its location to the first line past the prologue if this option is set.
By default, this option is OFF, preserving the current behavior.
I think this should take care of all the objections I read so far.
2008-01-10 Joel Brobecker <brobecker@adacore.com>
* breakpoint.c (breakpoint_skip_prologue_p): New static global.
(show_breakpoint_skip_prologue): New function.
(skip_prologue_sal): New function.
(resolve_sal_pc): Adjust SAL past prologue if the SAL was computed
from a line number and breakpoint_skip_prologue_p is set.
(_initialize_breakpoint): Add new set/show break skip-prologue
command.
Tested on x86-linux, no regression.
A new testcase, a NEWs entry, and proper documentation will be submitted
later if the patch is approved.
OK to commit?
Thanks,
--
Joel
[-- Attachment #2: skip-prologue.diff --]
[-- Type: text/plain, Size: 3049 bytes --]
Index: breakpoint.c
===================================================================
--- breakpoint.c (revision 117)
+++ breakpoint.c (revision 124)
@@ -246,6 +246,20 @@ Automatic usage of hardware breakpoints
value);
}
+/* When a user inserts a breakpoint on a specific line that corresponds
+ to a function prologue, GDB should automatically adjust the location
+ to the first line past the prologue if BREAKPOINT_SKIP_PROLOGUE_P
+ is non-zero. */
+static int breakpoint_skip_prologue_p = 0;
+static void
+show_breakpoint_skip_prologue (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("\
+When breaking on a specific line, automatic adjustment of the breakpoint\n\
+location past the function prologue is %s.\n"),
+ value);
+}
void _initialize_breakpoint (void);
@@ -5446,6 +5460,25 @@ gdb_breakpoint (char *address, char *con
0);
}
+/* Adjust SAL to the first instruction past the function prologue.
+ The end of the prologue is determined using the line table from
+ the debugging information.
+
+ If SAL is already past the prologue, then do nothing. */
+
+static void
+skip_prologue_sal (struct symtab_and_line *sal)
+{
+ struct symbol *sym = find_pc_function (sal->pc);
+ struct symtab_and_line start_sal;
+
+ if (sym == NULL)
+ return;
+
+ start_sal = find_function_start_sal (sym, 1);
+ if (sal->pc < start_sal.pc)
+ *sal = start_sal;
+}
/* Helper function for break_command_1 and disassemble_command. */
@@ -5460,6 +5493,13 @@ resolve_sal_pc (struct symtab_and_line *
error (_("No line %d in file \"%s\"."),
sal->line, sal->symtab->filename);
sal->pc = pc;
+
+ /* If this SAL corresponds to a breakpoint inserted using
+ a line number, and the debugger is configured to skip
+ function prologues in that case, then adjust the SAL
+ if necessary. */
+ if (sal->explicit_line && breakpoint_skip_prologue_p)
+ skip_prologue_sal (sal);
}
if (sal->section == 0 && sal->symtab != NULL)
@@ -8282,6 +8322,18 @@ a warning will be emitted for such break
show_automatic_hardware_breakpoints,
&breakpoint_set_cmdlist,
&breakpoint_show_cmdlist);
-
+
+ add_setshow_boolean_cmd ("skip-prologue", class_breakpoint,
+ &breakpoint_skip_prologue_p, _("\
+Set the debugger behavior when inserting a breakpoint on a specific line."),
+ _("\
+Show the debugger behavior when inserting a breakpoint on a specific line."),
+ _("\
+When inserting a breakpoint on a specific line number that corresponds\n\
+to the prologue of a function, the debugger will automatically adjust\n\
+its location to the first line past the prologue if this option is set."),
+ NULL, show_breakpoint_skip_prologue,
+ &breakpoint_set_cmdlist, &breakpoint_show_cmdlist);
+
automatic_hardware_breakpoints = 1;
}
next reply other threads:[~2008-01-10 15:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-10 15:13 Joel Brobecker [this message]
2008-01-10 17:25 ` Jim Blandy
2008-01-10 21:52 ` Michael Snyder
2008-01-10 22:15 ` Jim Blandy
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=20080110151312.GC13181@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@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