Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: Re: [rfc] Set a breakpoint's type before adjusting its address
Date: Thu, 03 May 2007 00:15:00 -0000	[thread overview]
Message-ID: <20070502171549.05134b10@ironwood.lan> (raw)
In-Reply-To: <20070428214510.GA12239@caradoc.them.org>

On Sat, 28 Apr 2007 17:45:10 -0400
Daniel Jacobowitz <drow@false.org> wrote:

> This happens because the breakpoint's location is already on the
> location chain, right?

Right.

> Alternatively, we could move that from the end
> of allocate_bp_location to the end of set_raw_breakpoint, and avoid
> the inconsistency.

If we can do it, I think it'd be nice to keep the code which allocates
the location together with the code which adds the newly allocated
location to the chain.

I agree that my earlier patch is not very nice in that
adjust_breakpoint_address() was being called with an only partially
initialized location on the location chain.  That patch was a band-aid
in that it initialized those bits which a particular function
(read_memory_nobpt) cared about, but who knows what else might break
if some other function were called.

Appended below is a new patch which calls adjust_breakpoint_address()
prior to allocating the breakoint's location.  What do you think of
this approach?

Kevin

	* breakpoint.c (set_raw_breakpoint): Adjust breakpoint's address
	prior to allocating its location.

Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.246
diff -u -p -r1.246 breakpoint.c
--- breakpoint.c	13 Apr 2007 13:50:32 -0000	1.246
+++ breakpoint.c	2 May 2007 23:57:06 -0000
@@ -4189,13 +4189,23 @@ struct breakpoint *
 set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype)
 {
   struct breakpoint *b, *b1;
+  CORE_ADDR adjusted_address;
 
   b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
   memset (b, 0, sizeof (*b));
+
+  /* Adjust the breakpoint's address prior to allocating a location.
+     Once we call allocate_bp_location(), that mostly uninitialized
+     location will be placed on the location chain.  Adjustment of the
+     breakpoint may cause read_memory_nobpt() to be called and we do
+     not want its scan of the location chain to find a breakpoint and
+     location that's only been partially initialized.  */
+  adjusted_address = adjust_breakpoint_address (sal.pc, bptype);
+
   b->loc = allocate_bp_location (b, bptype);
   b->loc->requested_address = sal.pc;
-  b->loc->address = adjust_breakpoint_address (b->loc->requested_address,
-                                               bptype);
+  b->loc->address = adjusted_address;
+
   if (sal.symtab == NULL)
     b->source_file = NULL;
   else


  reply	other threads:[~2007-05-03  0:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-27 22:25 Kevin Buettner
2007-04-28 21:54 ` Daniel Jacobowitz
2007-05-03  0:15   ` Kevin Buettner [this message]
2007-05-03  2:38     ` Daniel Jacobowitz
2007-05-03 17:44       ` Kevin Buettner

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=20070502171549.05134b10@ironwood.lan \
    --to=kevinb@redhat.com \
    --cc=gdb-patches@sources.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