* Assertion failure because of missing inferior
@ 2010-12-04 19:11 Marc Khouzam
2010-12-07 18:54 ` Tom Tromey
0 siblings, 1 reply; 17+ messages in thread
From: Marc Khouzam @ 2010-12-04 19:11 UTC (permalink / raw)
To: gdb-patches
Hi,
it seems that GDB expects that there always will be a current inferior.
To make sure of this, the CLI command 'remove-inferior' rejects the removing
of the current inferior.
The problem is that the corresponding MI command '-remove-inferior' does not
have the same check. Please see the session below which makes GDB fail
on an assert.
Now, there is not MI command equivalent to 'inferior' to properly allow a frontend
to change the current inferior. I understand this as saying that the frontend should
not need to change the current inferior, but should instead always use the MI
--thread-group flag to indicate which inferior the command applies to.
That is fine with me.
So, I was thinking that since a frontend shouldn't care which inferior is
the current one, then '-remove-inferior' could change the current inferior to another
inferior, before doing the removal. This is pretty much what the frontend would have
to do anyway. Removing the very last inferior would not be allowed.
The patch below does this. What do you think of this approach?
Session showing error:
> ./gdb
GNU gdb (GDB) 7.2.0.20101112-cvs
(gdb) add-inferior
Added inferior 2
(gdb) inf inf
Num Description Executable
2 <null>
* 1 <null>
(gdb) remove-inferior 1
Can not remove current symbol inferior.
=== Not allowed to remove using CLI ===
(gdb) interpreter-exec mi "-remove-inferior i1"
^done
=== Allowed to remove using MI ===
(gdb) inf inf
Num Description Executable
2 <null>
=== No current inferior ===
(gdb) file a.out
Reading symbols from /home/lmckhou/testing/a.out...done.
(gdb) list
../../src/gdb/inferior.c:59: internal-error: set_current_inferior: Assertion `inf != NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y
2010-12-04 Marc Khouzam <marc.khouzam@ericsson.com>
* mi/mi-main.c (mi_cmd_remove_inferior): Don't delete last inferior.
(get_other_inferior): New.
### Eclipse Workspace Patch 1.0
#P src
Index: gdb/mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.182
diff -u -r1.182 mi-main.c
--- gdb/mi/mi-main.c 12 Nov 2010 18:46:42 -0000 1.182
+++ gdb/mi/mi-main.c 4 Dec 2010 19:01:02 -0000
@@ -1744,6 +1744,17 @@
ui_out_field_fmt (uiout, "inferior", "i%d", inf->num);
}
+/* Callback used to find the first inferior other than the
+ current one. */
+static int
+get_other_inferior (struct inferior *inf, void *arg)
+{
+ if (inf == current_inferior ())
+ return 0;
+
+ return 1;
+}
+
void
mi_cmd_remove_inferior (char *command, char **argv, int argc)
{
@@ -1760,6 +1771,15 @@
if (!inf)
error ("the specified thread group does not exist");
+ if (inf == current_inferior ())
+ {
+ struct inferior *new_inferior = iterate_over_inferiors (get_other_inferior, NULL);
+ if (new_inferior == NULL)
+ error ("Cannot remove last inferior");
+
+ set_current_inferior (new_inferior);
+ }
+
delete_inferior_1 (inf, 1 /* silent */);
}
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: Assertion failure because of missing inferior
2010-12-04 19:11 Assertion failure because of missing inferior Marc Khouzam
@ 2010-12-07 18:54 ` Tom Tromey
2010-12-08 1:38 ` Marc Khouzam
0 siblings, 1 reply; 17+ messages in thread
From: Tom Tromey @ 2010-12-07 18:54 UTC (permalink / raw)
To: Marc Khouzam; +Cc: gdb-patches
>>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:
Marc> So, I was thinking that since a frontend shouldn't care which
Marc> inferior is the current one, then '-remove-inferior' could change
Marc> the current inferior to another inferior, before doing the
Marc> removal. This is pretty much what the frontend would have to do
Marc> anyway. Removing the very last inferior would not be allowed.
Marc> The patch below does this. What do you think of this approach?
This makes sense to me.
Marc> +/* Callback used to find the first inferior other than the
Marc> + current one. */
Marc> +static int
Blank line between comment and function start.
Marc> + if (inf == current_inferior ())
Marc> + {
Marc> + struct inferior *new_inferior = iterate_over_inferiors (get_other_inferior, NULL);
This line should be broken somewhere, probably before the '='.
Marc> + if (new_inferior == NULL)
Marc> + error ("Cannot remove last inferior");
Need _() around the text.
Tom
^ permalink raw reply [flat|nested] 17+ messages in thread* RE: Assertion failure because of missing inferior
2010-12-07 18:54 ` Tom Tromey
@ 2010-12-08 1:38 ` Marc Khouzam
2010-12-10 19:59 ` Tom Tromey
0 siblings, 1 reply; 17+ messages in thread
From: Marc Khouzam @ 2010-12-08 1:38 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
From: Tom Tromey [tromey@redhat.com]
>>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:
Marc> So, I was thinking that since a frontend shouldn't care which
Marc> inferior is the current one, then '-remove-inferior' could change
Marc> the current inferior to another inferior, before doing the
Marc> removal. This is pretty much what the frontend would have to do
Marc> anyway. Removing the very last inferior would not be allowed.
Marc> The patch below does this. What do you think of this approach?
> This makes sense to me.
Marc> +/* Callback used to find the first inferior other than the
Marc> + current one. */
Marc> +static int
> Blank line between comment and function start.
Marc> + if (inf == current_inferior ())
Marc> + {
Marc> + struct inferior *new_inferior = iterate_over_inferiors (get_other_inferior, NULL);
> This line should be broken somewhere, probably before the '='.
Marc> + if (new_inferior == NULL)
Marc> + error ("Cannot remove last inferior");
> Need _() around the text.
Thanks for the review. Here is the updated patch.
2010-12-07 Marc Khouzam <marc.khouzam@ericsson.com>
* mi/mi-main.c (mi_cmd_remove_inferior): Don't delete last inferior.
(get_other_inferior): New.
### Eclipse Workspace Patch 1.0
#P src
Index: gdb/mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.178.2.3
diff -u -r1.178.2.3 mi-main.c
--- gdb/mi/mi-main.c 12 Nov 2010 19:04:45 -0000 1.178.2.3
+++ gdb/mi/mi-main.c 8 Dec 2010 01:35:48 -0000
@@ -1623,6 +1623,18 @@
ui_out_field_fmt (uiout, "inferior", "i%d", inf->num);
}
+/* Callback used to find the first inferior other than the
+ current one. */
+
+static int
+get_other_inferior (struct inferior *inf, void *arg)
+{
+ if (inf == current_inferior ())
+ return 0;
+
+ return 1;
+}
+
void
mi_cmd_remove_inferior (char *command, char **argv, int argc)
{
@@ -1639,6 +1651,16 @@
if (!inf)
error ("the specified thread group does not exist");
+ if (inf == current_inferior ())
+ {
+ struct inferior *new_inferior
+ = iterate_over_inferiors (get_other_inferior, NULL);
+ if (new_inferior == NULL)
+ error (_("Cannot remove last inferior"));
+
+ set_current_inferior (new_inferior);
+ }
+
delete_inferior_1 (inf, 1 /* silent */);
}
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: Assertion failure because of missing inferior
2010-12-08 1:38 ` Marc Khouzam
@ 2010-12-10 19:59 ` Tom Tromey
2010-12-10 20:21 ` Marc Khouzam
0 siblings, 1 reply; 17+ messages in thread
From: Tom Tromey @ 2010-12-10 19:59 UTC (permalink / raw)
To: Marc Khouzam; +Cc: gdb-patches
>>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:
Marc> 2010-12-07 Marc Khouzam <marc.khouzam@ericsson.com>
Marc> * mi/mi-main.c (mi_cmd_remove_inferior): Don't delete last inferior.
Marc> (get_other_inferior): New.
This is ok.
Tom
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: Assertion failure because of missing inferior
2010-12-10 19:59 ` Tom Tromey
@ 2010-12-10 20:21 ` Marc Khouzam
2010-12-10 21:01 ` Marc Khouzam
0 siblings, 1 reply; 17+ messages in thread
From: Marc Khouzam @ 2010-12-10 20:21 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
From: Tom Tromey [tromey@redhat.com]
>>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:
Marc> 2010-12-07 Marc Khouzam <marc.khouzam@ericsson.com>
Marc> * mi/mi-main.c (mi_cmd_remove_inferior): Don't delete last inferior.
Marc> (get_other_inferior): New.
I've been doing more testing and I found a problem with the patch.
It seems setting the inferior is not enough, I must also set a thread.
I will better mimic what the 'inferior' command does and submit a new
version.
Marc
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: Assertion failure because of missing inferior
2010-12-10 20:21 ` Marc Khouzam
@ 2010-12-10 21:01 ` Marc Khouzam
2010-12-10 21:38 ` Marc Khouzam
2010-12-14 14:49 ` Tom Tromey
0 siblings, 2 replies; 17+ messages in thread
From: Marc Khouzam @ 2010-12-10 21:01 UTC (permalink / raw)
To: Marc Khouzam, Tom Tromey; +Cc: gdb-patches
2010-12-07 Marc Khouzam <marc.khouzam@ericsson.com>
* mi/mi-main.c (mi_cmd_remove_inferior): Don't delete last inferior.
(get_other_inferior): New.
> I've been doing more testing and I found a problem with the patch.
> It seems setting the inferior is not enough, I must also set a thread.
> I will better mimic what the 'inferior' command does and submit a new
> version.
Below is a more complete solution, copying the code from:
mi_cmd_execute(). It basically sets a thread, after setting the inferior.
Sorry about missing it before.
Doing this lead me to another segfault. I confirmed that it is part
of 7.2 and not introduced by my patch. So, I'm posting this patch now,
but I will email and investigate about the new segfault. There is
not much point to this current patch until the segfault is fixed, but
they are still two different issues, which is why I'm still posting this
patch.
Thanks
Marc
2010-12-10 Marc Khouzam <marc.khouzam@ericsson.com>
* mi/mi-main.c (mi_cmd_remove_inferior): Don't delete current inferior.
(get_other_inferior): New.
### Eclipse Workspace Patch 1.0
#P src
Index: gdb/mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.178.2.4
diff -u -r1.178.2.4 mi-main.c
--- gdb/mi/mi-main.c 9 Dec 2010 19:22:59 -0000 1.178.2.4
+++ gdb/mi/mi-main.c 10 Dec 2010 20:45:44 -0000
@@ -1623,6 +1623,18 @@
ui_out_field_fmt (uiout, "inferior", "i%d", inf->num);
}
+/* Callback used to find the first inferior other than the
+ current one. */
+
+static int
+get_other_inferior (struct inferior *inf, void *arg)
+{
+ if (inf == current_inferior ())
+ return 0;
+
+ return 1;
+}
+
void
mi_cmd_remove_inferior (char *command, char **argv, int argc)
{
@@ -1639,6 +1651,22 @@
if (!inf)
error ("the specified thread group does not exist");
+ if (inf == current_inferior ())
+ {
+ struct thread_info *tp = 0;
+ struct inferior *new_inferior
+ = iterate_over_inferiors (get_other_inferior, NULL);
+
+ if (new_inferior == NULL)
+ error (_("Cannot remove last inferior"));
+
+ set_current_inferior (new_inferior);
+ if (new_inferior->pid != 0)
+ tp = any_thread_of_process (new_inferior->pid);
+ switch_to_thread (tp ? tp->ptid : null_ptid);
+ set_current_program_space (new_inferior->pspace);
+ }
+
delete_inferior_1 (inf, 1 /* silent */);
}
^ permalink raw reply [flat|nested] 17+ messages in thread* RE: Assertion failure because of missing inferior
2010-12-10 21:01 ` Marc Khouzam
@ 2010-12-10 21:38 ` Marc Khouzam
2010-12-14 14:50 ` Tom Tromey
2010-12-14 14:49 ` Tom Tromey
1 sibling, 1 reply; 17+ messages in thread
From: Marc Khouzam @ 2010-12-10 21:38 UTC (permalink / raw)
To: Marc Khouzam, Tom Tromey; +Cc: gdb-patches
> Below is a more complete solution, copying the code from:
> mi_cmd_execute(). It basically sets a thread, after setting the inferior.
> Sorry about missing it before.
>
> Doing this lead me to another segfault. I confirmed that it is part
> of 7.2 and not introduced by my patch. So, I'm posting this patch now,
> but I will email and investigate about the new segfault. There is
> not much point to this current patch until the segfault is fixed, but
> they are still two different issues, which is why I'm still posting this
> patch.
The segfault is caused by the fact that I removed the inferior while
it was still running. I posted a question about that, but I think it is not
a normal use case, and therefore, does not prevent the below patch
from adding value.
What do you think of the below for 7_2?
Thanks
Marc
2010-12-10 Marc Khouzam <marc.khouzam@ericsson.com>
* mi/mi-main.c (mi_cmd_remove_inferior): Don't delete current inferior.
(get_other_inferior): New.
### Eclipse Workspace Patch 1.0
#P src
Index: gdb/mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.178.2.4
diff -u -r1.178.2.4 mi-main.c
--- gdb/mi/mi-main.c 9 Dec 2010 19:22:59 -0000 1.178.2.4
+++ gdb/mi/mi-main.c 10 Dec 2010 20:45:44 -0000
@@ -1623,6 +1623,18 @@
ui_out_field_fmt (uiout, "inferior", "i%d", inf->num);
}
+/* Callback used to find the first inferior other than the
+ current one. */
+
+static int
+get_other_inferior (struct inferior *inf, void *arg)
+{
+ if (inf == current_inferior ())
+ return 0;
+
+ return 1;
+}
+
void
mi_cmd_remove_inferior (char *command, char **argv, int argc)
{
@@ -1639,6 +1651,22 @@
if (!inf)
error ("the specified thread group does not exist");
+ if (inf == current_inferior ())
+ {
+ struct thread_info *tp = 0;
+ struct inferior *new_inferior
+ = iterate_over_inferiors (get_other_inferior, NULL);
+
+ if (new_inferior == NULL)
+ error (_("Cannot remove last inferior"));
+
+ set_current_inferior (new_inferior);
+ if (new_inferior->pid != 0)
+ tp = any_thread_of_process (new_inferior->pid);
+ switch_to_thread (tp ? tp->ptid : null_ptid);
+ set_current_program_space (new_inferior->pspace);
+ }
+
delete_inferior_1 (inf, 1 /* silent */);
}
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: Assertion failure because of missing inferior
2010-12-10 21:38 ` Marc Khouzam
@ 2010-12-14 14:50 ` Tom Tromey
2010-12-14 15:04 ` Joel Brobecker
2010-12-18 2:19 ` Assertion failure because of missing inferior Marc Khouzam
0 siblings, 2 replies; 17+ messages in thread
From: Tom Tromey @ 2010-12-14 14:50 UTC (permalink / raw)
To: Marc Khouzam; +Cc: gdb-patches
>>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:
Marc> What do you think of the below for 7_2?
Marc> 2010-12-10 Marc Khouzam <marc.khouzam@ericsson.com>
Marc> * mi/mi-main.c (mi_cmd_remove_inferior): Don't delete current inferior.
Marc> (get_other_inferior): New.
I think this is ok for the 7.2 branch, assuming Joel didn't do the
release already :)
Tom
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Assertion failure because of missing inferior
2010-12-14 14:50 ` Tom Tromey
@ 2010-12-14 15:04 ` Joel Brobecker
2010-12-14 15:31 ` Pedro Alves
2010-12-14 20:00 ` Marc Khouzam
2010-12-18 2:19 ` Assertion failure because of missing inferior Marc Khouzam
1 sibling, 2 replies; 17+ messages in thread
From: Joel Brobecker @ 2010-12-14 15:04 UTC (permalink / raw)
To: Tom Tromey; +Cc: Marc Khouzam, gdb-patches
> Marc> 2010-12-10 Marc Khouzam <marc.khouzam@ericsson.com>
> Marc> * mi/mi-main.c (mi_cmd_remove_inferior): Don't delete current inferior.
> Marc> (get_other_inferior): New.
>
> I think this is ok for the 7.2 branch, assuming Joel didn't do the
> release already :)
I'll wait for the go ahead from you guys - I get confused with the
various emails...
There is also a watchpoint-related patch (from Pedro) which Jan pointed
out. It looks a little riskier than the typical patch, but it fixes
crashes and has been in HEAD for 4 months now. So I suggested the
possibility of maybe putting it in, if we don't know of any issue that
this patch caused since putting it in HEAD....
--
Joel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Assertion failure because of missing inferior
2010-12-14 15:04 ` Joel Brobecker
@ 2010-12-14 15:31 ` Pedro Alves
2010-12-15 5:12 ` Joel Brobecker
2010-12-14 20:00 ` Marc Khouzam
1 sibling, 1 reply; 17+ messages in thread
From: Pedro Alves @ 2010-12-14 15:31 UTC (permalink / raw)
To: gdb-patches; +Cc: Joel Brobecker, Tom Tromey, Marc Khouzam
On Tuesday 14 December 2010 15:04:30, Joel Brobecker wrote:
> > Marc> 2010-12-10 Marc Khouzam <marc.khouzam@ericsson.com>
> > Marc> * mi/mi-main.c (mi_cmd_remove_inferior): Don't delete current inferior.
> > Marc> (get_other_inferior): New.
> >
> > I think this is ok for the 7.2 branch, assuming Joel didn't do the
> > release already :)
>
> I'll wait for the go ahead from you guys - I get confused with the
> various emails...
>
> There is also a watchpoint-related patch (from Pedro) which Jan pointed
> out. It looks a little riskier than the typical patch, but it fixes
> crashes and has been in HEAD for 4 months now. So I suggested the
> possibility of maybe putting it in, if we don't know of any issue that
> this patch caused since putting it in HEAD....
I don't recall of any. It's fine with me to backport it, assuming
the backport doesn't bring in half of 7.3 into the branch. :-)
--
Pedro Alves
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: Assertion failure because of missing inferior
2010-12-14 15:04 ` Joel Brobecker
2010-12-14 15:31 ` Pedro Alves
@ 2010-12-14 20:00 ` Marc Khouzam
2010-12-15 15:57 ` [Python] Segfault when clearing pspace (was: RE: Assertion failure because of missing inferior) Marc Khouzam
1 sibling, 1 reply; 17+ messages in thread
From: Marc Khouzam @ 2010-12-14 20:00 UTC (permalink / raw)
To: 'Joel Brobecker', 'Tom Tromey'
Cc: 'gdb-patches@sourceware.org'
> -----Original Message-----
> From: gdb-patches-owner@sourceware.org
> [mailto:gdb-patches-owner@sourceware.org] On Behalf Of Joel Brobecker
> Sent: Tuesday, December 14, 2010 10:05 AM
> To: Tom Tromey
> Cc: Marc Khouzam; gdb-patches@sourceware.org
> Subject: Re: Assertion failure because of missing inferior
>
> > Marc> 2010-12-10 Marc Khouzam <marc.khouzam@ericsson.com>
> > Marc> * mi/mi-main.c (mi_cmd_remove_inferior): Don't
> delete current inferior.
> > Marc> (get_other_inferior): New.
> >
> > I think this is ok for the 7.2 branch, assuming Joel didn't do the
> > release already :)
>
> I'll wait for the go ahead from you guys - I get confused with the
> various emails...
So, although I feel that this patch is good, it seems to be
only a first step in getting 'remove-inferior' to work. Once
I have this patch applied, I'm getting further but hitting
another crash. I'm still working on a patch for that. I don't
think the current patch is going to help 7.2.1 unless the other
crash is also fixed, so I'll wait before committing it.
I guess I have just a little more time, until the issue below
(watchpoint-related patch) is ready, to try to fix the latest
crash. I'll do my best.
Thanks
Marc
> There is also a watchpoint-related patch (from Pedro) which
> Jan pointed
> out. It looks a little riskier than the typical patch, but it fixes
> crashes and has been in HEAD for 4 months now. So I suggested the
> possibility of maybe putting it in, if we don't know of any issue that
> this patch caused since putting it in HEAD....
>
> --
> Joel
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Python] Segfault when clearing pspace (was: RE: Assertion failure because of missing inferior)
2010-12-14 20:00 ` Marc Khouzam
@ 2010-12-15 15:57 ` Marc Khouzam
2010-12-16 21:26 ` [Python] Segfault when clearing pspace Tom Tromey
0 siblings, 1 reply; 17+ messages in thread
From: Marc Khouzam @ 2010-12-15 15:57 UTC (permalink / raw)
To: 'Joel Brobecker', 'Tom Tromey'
Cc: 'gdb-patches@sourceware.org'
> -----Original Message-----
> From: gdb-patches-owner@sourceware.org
> [mailto:gdb-patches-owner@sourceware.org] On Behalf Of Marc Khouzam
> Sent: Tuesday, December 14, 2010 3:00 PM
> To: 'Joel Brobecker'; 'Tom Tromey'
> Cc: 'gdb-patches@sourceware.org'
> Subject: RE: Assertion failure because of missing inferior
>
> > -----Original Message-----
> > From: gdb-patches-owner@sourceware.org
> > [mailto:gdb-patches-owner@sourceware.org] On Behalf Of Joel
> Brobecker
> > Sent: Tuesday, December 14, 2010 10:05 AM
> > To: Tom Tromey
> > Cc: Marc Khouzam; gdb-patches@sourceware.org
> > Subject: Re: Assertion failure because of missing inferior
> >
> > > Marc> 2010-12-10 Marc Khouzam <marc.khouzam@ericsson.com>
> > > Marc> * mi/mi-main.c (mi_cmd_remove_inferior): Don't
> > delete current inferior.
> > > Marc> (get_other_inferior): New.
> > >
> > > I think this is ok for the 7.2 branch, assuming Joel didn't do the
> > > release already :)
> >
> > I'll wait for the go ahead from you guys - I get confused with the
> > various emails...
>
> So, although I feel that this patch is good, it seems to be
> only a first step in getting 'remove-inferior' to work. Once
> I have this patch applied, I'm getting further but hitting
> another crash. I'm still working on a patch for that. I don't
> think the current patch is going to help 7.2.1 unless the other
> crash is also fixed, so I'll wait before committing it.
I tracked down the crash when removing an inferior to the python
cleanup method: py_free_pspace(). This method tries to obtain
the gdbarch from pspace->symfile_object_file, but that pointer
has already been cleaned. The patch below uses gdb_current_arch()
instead and that fixes the crash. I don't know
if I'm allowed to use this method in this context and if it
returns the same arch as what was part of the pspace that is
being cleaned.
The existing FIXME comment about how to get the arch seems to
confirm that something should be fixed there.
Below the patch is a session that shows how to reproduce
the crash.
What do you think?
Marc
### Eclipse Workspace Patch 1.0
#P src
Index: gdb/python/py-progspace.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-progspace.c,v
retrieving revision 1.3
diff -u -r1.3 py-progspace.c
--- gdb/python/py-progspace.c 17 May 2010 21:23:25 -0000 1.3
+++ gdb/python/py-progspace.c 15 Dec 2010 15:00:01 -0000
@@ -23,6 +23,7 @@
#include "progspace.h"
#include "objfiles.h"
#include "language.h"
+#include "arch-utils.h"
typedef struct
{
@@ -136,7 +137,7 @@
pspace_object *object = datum;
/* FIXME: What's the right way to get a program space's arch?
There may be multiple. */
- struct gdbarch *arch = get_objfile_arch (pspace->symfile_object_file);
+ struct gdbarch *arch = get_current_arch ();
cleanup = ensure_python_env (arch, current_language);
object->pspace = NULL;
===================
> gdb.7.2
GNU gdb (GDB) 7.2
(gdb) file /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSFTestApp
Reading symbols from /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSFTestApp...done.
(gdb) start
Temporary breakpoint 1 at 0x80489f4: file ../src/DSFTestApp.cpp, line 1155.
Starting program: /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSFTestApp
[Thread debugging using libthread_db enabled]
Temporary breakpoint 1, main (argc=1, argv=0xbffff7e4) at ../src/DSFTestApp.cpp:1155
1155 int de = 99;
(gdb) add-inferior
Added inferior 2
(gdb) inferior 2
[Switching to inferior 2 [process 0] (<noexec>)]
(gdb) file /home/lmckhou/testing/a.out
Reading symbols from /home/lmckhou/testing/a.out...done.
(gdb) start
Temporary breakpoint 2 at 0x80484a9: file a.cc, line 9.
Starting program: /home/lmckhou/testing/a.out
Temporary breakpoint 2, main () at a.cc:9
9 f();
(gdb) inf inf
Num Description Executable
* 2 process 8158 /home/lmckhou/testing/a.out
1 process 8154 /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSFTestApp
(gdb) detach inferior 1
(gdb) inf inf
Num Description Executable
2 process 8158 /home/lmckhou/testing/a.out
* 1 <null> /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSFTestApp
(gdb) inferior 2
[Switching to inferior 2 [process 8158] (/home/lmckhou/testing/a.out)]
[Switching to thread 2 (process 8158)]
#0 main () at a.cc:9
9 f();
(gdb) inf inf
Num Description Executable
* 2 process 8158 /home/lmckhou/testing/a.out
1 <null> /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSFTestApp
(gdb) remove-inferior 1
(gdb) inf inf
Num Description Executable
* 2 process 8158 /home/lmckhou/testing/a.out
(gdb) n
10 return 1;
Segmentation fault
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [Python] Segfault when clearing pspace
2010-12-15 15:57 ` [Python] Segfault when clearing pspace (was: RE: Assertion failure because of missing inferior) Marc Khouzam
@ 2010-12-16 21:26 ` Tom Tromey
2010-12-18 2:13 ` Marc Khouzam
0 siblings, 1 reply; 17+ messages in thread
From: Tom Tromey @ 2010-12-16 21:26 UTC (permalink / raw)
To: Marc Khouzam
Cc: 'Joel Brobecker', 'gdb-patches@sourceware.org'
>>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:
Marc> The existing FIXME comment about how to get the arch seems to
Marc> confirm that something should be fixed there.
Marc> Below the patch is a session that shows how to reproduce
Marc> the crash.
Marc> What do you think?
Please remove the FIXME comment.
This is ok with that change plus a ChangeLog entry.
thanks
Tom
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: [Python] Segfault when clearing pspace
2010-12-16 21:26 ` [Python] Segfault when clearing pspace Tom Tromey
@ 2010-12-18 2:13 ` Marc Khouzam
0 siblings, 0 replies; 17+ messages in thread
From: Marc Khouzam @ 2010-12-18 2:13 UTC (permalink / raw)
To: Tom Tromey; +Cc: 'Joel Brobecker', 'gdb-patches@sourceware.org'
From: gdb-patches-owner@sourceware.org [gdb-patches-owner@sourceware.org] On Behalf Of Tom Tromey [tromey@redhat.com]
>>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:
Marc> The existing FIXME comment about how to get the arch seems to
Marc> confirm that something should be fixed there.
Marc> Below the patch is a session that shows how to reproduce
Marc> the crash.
Marc> What do you think?
> Please remove the FIXME comment.
> This is ok with that change plus a ChangeLog entry.
I committed the following to HEAD and 7_2.
Thanks Tom!
Marc
2010-12-17 Marc Khouzam <marc.khouzam@ericsson.com>
* python/py-progspace.c (py_free_pspace): Obtain arch another
way to avoid dereferencing a null pointer.
### Eclipse Workspace Patch 1.0
#P src
Index: gdb/python/py-progspace.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-progspace.c,v
retrieving revision 1.3
diff -u -r1.3 py-progspace.c
--- gdb/python/py-progspace.c 17 May 2010 21:23:25 -0000 1.3
+++ gdb/python/py-progspace.c 18 Dec 2010 01:26:51 -0000
@@ -23,6 +23,7 @@
#include "progspace.h"
#include "objfiles.h"
#include "language.h"
+#include "arch-utils.h"
typedef struct
{
@@ -134,9 +135,7 @@
{
struct cleanup *cleanup;
pspace_object *object = datum;
- /* FIXME: What's the right way to get a program space's arch?
- There may be multiple. */
- struct gdbarch *arch = get_objfile_arch (pspace->symfile_object_file);
+ struct gdbarch *arch = get_current_arch ();
cleanup = ensure_python_env (arch, current_language);
object->pspace = NULL;
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: Assertion failure because of missing inferior
2010-12-14 14:50 ` Tom Tromey
2010-12-14 15:04 ` Joel Brobecker
@ 2010-12-18 2:19 ` Marc Khouzam
1 sibling, 0 replies; 17+ messages in thread
From: Marc Khouzam @ 2010-12-18 2:19 UTC (permalink / raw)
To: Tom Tromey, brobecker; +Cc: gdb-patches
From: Tom Tromey [tromey@redhat.com]
>>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:
Marc> What do you think of the below for 7_2?
Marc> 2010-12-10 Marc Khouzam <marc.khouzam@ericsson.com>
Marc> * mi/mi-main.c (mi_cmd_remove_inferior): Don't delete current inferior.
Marc> (get_other_inferior): New.
> I think this is ok for the 7.2 branch, assuming Joel didn't do the
> release already :)
Now that all issues seem to be fixed when removing an inferior using CLI,
I committed the below to HEAD and 7_2.
Thanks for delaying 7.2.1 to wait for these fixes. It will be really useful for Eclipse.
I'm gonna submit another patch for
http://sourceware.org/ml/gdb/2010-12/msg00039.html
(missing check to prevent removing a running inferior)
but that is not important for 7_2 (unless you guys want it there),
so, from my side, there are no more issues for 7.2.1.
Thanks again.
Marc
2010-12-17 Marc Khouzam <marc.khouzam@ericsson.com>
* mi/mi-main.c (mi_cmd_remove_inferior): Don't delete current inferior.
(get_other_inferior): New.
### Eclipse Workspace Patch 1.0
#P src
Index: gdb/mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.178.2.4
diff -u -r1.178.2.4 mi-main.c
--- gdb/mi/mi-main.c 9 Dec 2010 19:22:59 -0000 1.178.2.4
+++ gdb/mi/mi-main.c 18 Dec 2010 01:54:10 -0000
@@ -1623,6 +1623,18 @@
ui_out_field_fmt (uiout, "inferior", "i%d", inf->num);
}
+/* Callback used to find the first inferior other than the
+ current one. */
+
+static int
+get_other_inferior (struct inferior *inf, void *arg)
+{
+ if (inf == current_inferior ())
+ return 0;
+
+ return 1;
+}
+
void
mi_cmd_remove_inferior (char *command, char **argv, int argc)
{
@@ -1639,6 +1651,22 @@
if (!inf)
error ("the specified thread group does not exist");
+ if (inf == current_inferior ())
+ {
+ struct thread_info *tp = 0;
+ struct inferior *new_inferior
+ = iterate_over_inferiors (get_other_inferior, NULL);
+
+ if (new_inferior == NULL)
+ error (_("Cannot remove last inferior"));
+
+ set_current_inferior (new_inferior);
+ if (new_inferior->pid != 0)
+ tp = any_thread_of_process (new_inferior->pid);
+ switch_to_thread (tp ? tp->ptid : null_ptid);
+ set_current_program_space (new_inferior->pspace);
+ }
+
delete_inferior_1 (inf, 1 /* silent */);
}
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Assertion failure because of missing inferior
2010-12-10 21:01 ` Marc Khouzam
2010-12-10 21:38 ` Marc Khouzam
@ 2010-12-14 14:49 ` Tom Tromey
1 sibling, 0 replies; 17+ messages in thread
From: Tom Tromey @ 2010-12-14 14:49 UTC (permalink / raw)
To: Marc Khouzam; +Cc: gdb-patches
>>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:
Marc> Below is a more complete solution, copying the code from:
Marc> mi_cmd_execute(). It basically sets a thread, after setting the inferior.
Thanks, this is ok.
Marc> Sorry about missing it before.
No problem.
Tom
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2010-12-18 2:19 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-04 19:11 Assertion failure because of missing inferior Marc Khouzam
2010-12-07 18:54 ` Tom Tromey
2010-12-08 1:38 ` Marc Khouzam
2010-12-10 19:59 ` Tom Tromey
2010-12-10 20:21 ` Marc Khouzam
2010-12-10 21:01 ` Marc Khouzam
2010-12-10 21:38 ` Marc Khouzam
2010-12-14 14:50 ` Tom Tromey
2010-12-14 15:04 ` Joel Brobecker
2010-12-14 15:31 ` Pedro Alves
2010-12-15 5:12 ` Joel Brobecker
2010-12-14 20:00 ` Marc Khouzam
2010-12-15 15:57 ` [Python] Segfault when clearing pspace (was: RE: Assertion failure because of missing inferior) Marc Khouzam
2010-12-16 21:26 ` [Python] Segfault when clearing pspace Tom Tromey
2010-12-18 2:13 ` Marc Khouzam
2010-12-18 2:19 ` Assertion failure because of missing inferior Marc Khouzam
2010-12-14 14:49 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox