* [PATCH] breakpoint.c: Fix advance/until and multiple locations
@ 2020-08-26 15:06 紀重禕
2020-08-27 2:03 ` Simon Marchi
0 siblings, 1 reply; 5+ messages in thread
From: 紀重禕 @ 2020-08-26 15:06 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 173 bytes --]
Fix bug 26524 <https://sourceware.org/bugzilla/show_bug.cgi?id=26524> ,
iterate the sals variable to insert a breakpoint for each <location>
--
Best regards,
Chung-Yi Chi
[-- Attachment #2: 0001-gdb-gdb-Fix-advance-until-and-multiple-locations.patch --]
[-- Type: text/x-patch, Size: 5783 bytes --]
From 37ff521c6cd8ac6fbac642d1daece57f1e1ce460 Mon Sep 17 00:00:00 2001
From: Chungyi Chi <demonic@csie.io>
Date: Wed, 26 Aug 2020 22:08:43 +0800
Subject: [PATCH] gdb/gdb: Fix advance/until and multiple locations
Assume <location> is able to expand to multiple ones and insert a
breakpoint for each one.
---
gdb/ChangeLog | 5 +++
gdb/breakpoint.c | 108 +++++++++++++++++++++++------------------------
2 files changed, 58 insertions(+), 55 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ceff808d82..86827ca7d7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-08-26 Chungyi Chi <ianchi@andestech.com>
+
+ * breakpoint.c (until_break_command): Assume <location> is able to
+ expand to multiple ones and insert a breakpoint for each one.
+
2020-08-25 Shahab Vahedi <shahab@synopsys.com>
* MAINTAINERS: Add ARC target and maintainer.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index ef8e54f634..645bd11b30 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -11023,74 +11023,72 @@ until_break_command (const char *arg, int from_tty, int anywhere)
: decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE,
NULL, NULL, 0));
- if (sals.size () != 1)
- error (_("Couldn't get information on specified line."));
-
- symtab_and_line &sal = sals[0];
-
if (*arg)
error (_("Junk at end of arguments."));
- resolve_sal_pc (&sal);
-
- tp = inferior_thread ();
- thread = tp->global_num;
-
- /* Note linespec handling above invalidates the frame chain.
- Installing a breakpoint also invalidates the frame chain (as it
- may need to switch threads), so do any frame handling before
- that. */
-
- frame = get_selected_frame (NULL);
- frame_gdbarch = get_frame_arch (frame);
- stack_frame_id = get_stack_frame_id (frame);
- caller_frame_id = frame_unwind_caller_id (frame);
+ for (size_t i = 0; i < sals.size (); i++)
+ {
+ symtab_and_line &sal = sals[i];
+ resolve_sal_pc (&sal);
+ tp = inferior_thread ();
+ thread = tp->global_num;
- /* Keep within the current frame, or in frames called by the current
- one. */
+ /* Note linespec handling above invalidates the frame chain.
+ Installing a breakpoint also invalidates the frame chain (as it
+ may need to switch threads), so do any frame handling before
+ that. */
- breakpoint_up caller_breakpoint;
+ frame = get_selected_frame (NULL);
+ frame_gdbarch = get_frame_arch (frame);
+ stack_frame_id = get_stack_frame_id (frame);
+ caller_frame_id = frame_unwind_caller_id (frame);
- gdb::optional<delete_longjmp_breakpoint_cleanup> lj_deleter;
+ /* Keep within the current frame, or in frames called by the current
+ one. */
- if (frame_id_p (caller_frame_id))
- {
- struct symtab_and_line sal2;
- struct gdbarch *caller_gdbarch;
+ breakpoint_up caller_breakpoint;
- sal2 = find_pc_line (frame_unwind_caller_pc (frame), 0);
- sal2.pc = frame_unwind_caller_pc (frame);
- caller_gdbarch = frame_unwind_caller_arch (frame);
- caller_breakpoint = set_momentary_breakpoint (caller_gdbarch,
- sal2,
- caller_frame_id,
- bp_until);
+ gdb::optional<delete_longjmp_breakpoint_cleanup> lj_deleter;
- set_longjmp_breakpoint (tp, caller_frame_id);
- lj_deleter.emplace (thread);
- }
+ if (frame_id_p (caller_frame_id))
+ {
+ struct symtab_and_line sal2;
+ struct gdbarch *caller_gdbarch;
+
+ sal2 = find_pc_line (frame_unwind_caller_pc (frame), 0);
+ sal2.pc = frame_unwind_caller_pc (frame);
+ caller_gdbarch = frame_unwind_caller_arch (frame);
+ caller_breakpoint = set_momentary_breakpoint (caller_gdbarch,
+ sal2,
+ caller_frame_id,
+ bp_until);
+
+ set_longjmp_breakpoint (tp, caller_frame_id);
+ lj_deleter.emplace (thread);
+ }
- /* set_momentary_breakpoint could invalidate FRAME. */
- frame = NULL;
+ /* set_momentary_breakpoint could invalidate FRAME. */
+ frame = NULL;
- breakpoint_up location_breakpoint;
- if (anywhere)
- /* If the user told us to continue until a specified location,
- we don't specify a frame at which we need to stop. */
- location_breakpoint = set_momentary_breakpoint (frame_gdbarch, sal,
- null_frame_id, bp_until);
- else
- /* Otherwise, specify the selected frame, because we want to stop
- only at the very same frame. */
- location_breakpoint = set_momentary_breakpoint (frame_gdbarch, sal,
- stack_frame_id, bp_until);
+ breakpoint_up location_breakpoint;
+ if (anywhere)
+ /* If the user told us to continue until a specified location,
+ we don't specify a frame at which we need to stop. */
+ location_breakpoint = set_momentary_breakpoint (frame_gdbarch, sal,
+ null_frame_id, bp_until);
+ else
+ /* Otherwise, specify the selected frame, because we want to stop
+ only at the very same frame. */
+ location_breakpoint = set_momentary_breakpoint (frame_gdbarch, sal,
+ stack_frame_id, bp_until);
- tp->thread_fsm = new until_break_fsm (command_interp (), tp->global_num,
- std::move (location_breakpoint),
- std::move (caller_breakpoint));
+ tp->thread_fsm = new until_break_fsm (command_interp (), tp->global_num,
+ std::move (location_breakpoint),
+ std::move (caller_breakpoint));
- if (lj_deleter)
- lj_deleter->release ();
+ if (lj_deleter)
+ lj_deleter->release ();
+ }
proceed (-1, GDB_SIGNAL_DEFAULT);
}
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] breakpoint.c: Fix advance/until and multiple locations
2020-08-26 15:06 [PATCH] breakpoint.c: Fix advance/until and multiple locations 紀重禕
@ 2020-08-27 2:03 ` Simon Marchi
2020-08-27 2:17 ` 紀重禕
0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2020-08-27 2:03 UTC (permalink / raw)
To: 紀重禕, gdb-patches
On 2020-08-26 11:06 a.m., 紀重禕 wrote:
> Fix bug 26524 <https://sourceware.org/bugzilla/show_bug.cgi?id=26524> ,
> iterate the sals variable to insert a breakpoint for each <location>
>
> --
> Best regards,
> Chung-Yi Chi
>
Hi,
I'm not sure the approach is right, since you end up creating multiple until_break_fsm
objects (one for each sal) and overwriting them.
Pedro Alves posted some patches fixing the same problem here:
https://sourceware.org/pipermail/gdb-patches/2020-August/171427.html
which look good to me. Could you please take a look at those?
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] breakpoint.c: Fix advance/until and multiple locations
2020-08-27 2:03 ` Simon Marchi
@ 2020-08-27 2:17 ` 紀重禕
2020-08-27 2:22 ` Simon Marchi
2020-08-27 20:27 ` Pedro Alves
0 siblings, 2 replies; 5+ messages in thread
From: 紀重禕 @ 2020-08-27 2:17 UTC (permalink / raw)
To: simark; +Cc: gdb-patches
Hi Simon,
Pedro Alves actually did a better and complete patch! Sorry to take up your
time.
Simon Marchi <simark@simark.ca> 於 2020年8月27日 週四 上午10:03寫道:
> On 2020-08-26 11:06 a.m., 紀重禕 wrote:
> > Fix bug 26524 <https://sourceware.org/bugzilla/show_bug.cgi?id=26524> ,
> > iterate the sals variable to insert a breakpoint for each <location>
> >
> > --
> > Best regards,
> > Chung-Yi Chi
> >
>
> Hi,
>
> I'm not sure the approach is right, since you end up creating multiple
> until_break_fsm
> objects (one for each sal) and overwriting them.
>
> Pedro Alves posted some patches fixing the same problem here:
>
> https://sourceware.org/pipermail/gdb-patches/2020-August/171427.html
>
> which look good to me. Could you please take a look at those?
>
> Simon
>
--
Best regards,
Chung-Yi Chi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] breakpoint.c: Fix advance/until and multiple locations
2020-08-27 2:17 ` 紀重禕
@ 2020-08-27 2:22 ` Simon Marchi
2020-08-27 20:27 ` Pedro Alves
1 sibling, 0 replies; 5+ messages in thread
From: Simon Marchi @ 2020-08-27 2:22 UTC (permalink / raw)
To: 紀重禕; +Cc: gdb-patches
On 2020-08-26 10:17 p.m., 紀重禕 wrote:
> Hi Simon,
>
> Pedro Alves actually did a better and complete patch! Sorry to take up your time.
No worries, thanks for taking the time to send a patch.
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] breakpoint.c: Fix advance/until and multiple locations
2020-08-27 2:17 ` 紀重禕
2020-08-27 2:22 ` Simon Marchi
@ 2020-08-27 20:27 ` Pedro Alves
1 sibling, 0 replies; 5+ messages in thread
From: Pedro Alves @ 2020-08-27 20:27 UTC (permalink / raw)
To: 紀重禕, simark; +Cc: gdb-patches
On 8/27/20 3:17 AM, 紀重禕 wrote:
> Hi Simon,
>
> Pedro Alves actually did a better and complete patch! Sorry to take up your
> time.
I was the one who created the bug reports and I already had
the fixes written before I created them.
I'm very sorry that I didn't say so in the bug reports, which
would have avoided you the work! I'll keep this in mind for
the next time.
I never imagined that someone else would run into the bug and
write a patch so quickly! What a coincidence.
Thanks for contributing. Please don't be shy about fixing
more bugs and posting more patches! :-)
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-08-27 20:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26 15:06 [PATCH] breakpoint.c: Fix advance/until and multiple locations 紀重禕
2020-08-27 2:03 ` Simon Marchi
2020-08-27 2:17 ` 紀重禕
2020-08-27 2:22 ` Simon Marchi
2020-08-27 20:27 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox