From: Daniel Jacobowitz <dan@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Pedro Alves <pedro@codesourcery.com>, Doug Evans <dje@google.com>
Subject: [for discussion] Update inferior address spaces
Date: Mon, 01 Mar 2010 21:37:00 -0000 [thread overview]
Message-ID: <20100301213735.GA17815@caradoc.them.org> (raw)
I ran into the same problem that Doug reported recently, about
update_address_spaces. Pedro was kind enough to point me at the
problematic code. This patch updates all inferiors, which does stop
the wrong behavior... but I can see why Pedro described this to me as
a quick fix. It raises a question.
If I'm reading this right, there's no actual case of inf->aspace !=
inf->pspace->aspace in the GDB source code. The DICOS target manages
this by having all breakpoints transparently global. So the
inf->aspace pointer is redundant.
If I'm wrong, or if there's a patch I don't have which changes this
for DICOS, could you explain the relation of these three things to me?
There's a nice comment in progspace.h, but it doesn't answer this
question: if an inf->aspace != inf->pspace->aspace, what does that
mean for anything that looks at a program space's aspace pointer?
Also, I believe there's a double free in the existing code, fixed in
this patch. For the shared address space case.
This patch works around the bug, but I don't think it's right as-is.
--
Daniel Jacobowitz
CodeSourcery
2010-03-01 Daniel Jacobowitz <dan@codesourcery.com>
* progspace.c (update_address_spaces): Update inferior address spaces
also.
Index: progspace.c
===================================================================
--- progspace.c (revision 277420)
+++ progspace.c (working copy)
@@ -430,24 +430,30 @@ void
update_address_spaces (void)
{
int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch);
- struct address_space *aspace = NULL;
struct program_space *pspace;
+ struct inferior *inf;
+
+ for (inf = inferior_list; inf; inf = inf->next)
+ gdb_assert (inf->aspace == inf->pspace->aspace);
init_address_spaces ();
- ALL_PSPACES (pspace)
+ if (shared_aspace)
{
- free_address_space (pspace->aspace);
-
- if (shared_aspace)
- {
- if (aspace == NULL)
- aspace = new_address_space ();
- pspace->aspace = aspace;
- }
- else
- pspace->aspace = new_address_space ();
+ struct address_space *aspace = new_address_space ();
+ free_address_space (current_program_space->aspace);
+ ALL_PSPACES (pspace)
+ pspace->aspace = aspace;
}
+ else
+ ALL_PSPACES (pspace)
+ {
+ free_address_space (pspace->aspace);
+ pspace->aspace = new_address_space ();
+ }
+
+ for (inf = inferior_list; inf; inf = inf->next)
+ inf->aspace = inf->pspace->aspace;
}
/* Save the current program space so that it may be restored by a later
next reply other threads:[~2010-03-01 21:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-01 21:37 Daniel Jacobowitz [this message]
2010-03-02 17:16 ` Pedro Alves
2010-03-02 17:41 ` Daniel Jacobowitz
2010-03-02 17:52 ` Pedro Alves
2010-03-02 17:57 ` Daniel Jacobowitz
2010-03-02 18:51 ` Doug Evans
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=20100301213735.GA17815@caradoc.them.org \
--to=dan@codesourcery.com \
--cc=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@codesourcery.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