Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfc] Do not inherit to_open and to_close
@ 2008-09-04  1:44 Ulrich Weigand
  2008-09-04 12:16 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2008-09-04  1:44 UTC (permalink / raw)
  To: gdb-patches

Hello,

I've run into a problem where the pop_all_targets_above (file_stratum, 0)
call in target_preopen actually removed the exec target -- even though
it is explicitly supposed to leave it present.

This turned out to be the case because the exec_close routine had been
inherited by one of the targets higher on the stack -- so the target_close
routine called on that higher target would actually close the exec target!

It seems to me that the to_close method simply must never be inherited
(and likewise it does not make sense to inherit the to_open method).

The following patch implements this change.

Tested on powerpc-linux, powerpc64-linux and spu-elf with no regressions.

Any comments?  Am I overlooking something here?

Bye,
Ulrich


ChangeLog:

	* target.c (update_current_target): Do not inherit t_open
	or to_close.
	(pop_target): Call target_close on target_stack instead
	of current_target.
	(pop_all_targets_above): Likewise.


diff -urNp gdb-orig/gdb/target.c gdb-head/gdb/target.c
--- gdb-orig/gdb/target.c	2008-09-02 23:19:50.000000000 +0200
+++ gdb-head/gdb/target.c	2008-09-04 03:13:11.973736135 +0200
@@ -385,8 +385,8 @@ update_current_target (void)
       INHERIT (to_shortname, t);
       INHERIT (to_longname, t);
       INHERIT (to_doc, t);
-      INHERIT (to_open, t);
-      INHERIT (to_close, t);
+      /* Do not inherit to_open.  */
+      /* Do not inherit to_close.  */
       INHERIT (to_attach, t);
       INHERIT (to_post_attach, t);
       INHERIT (to_attach_no_wait, t);
@@ -784,7 +784,7 @@ unpush_target (struct target_ops *t)
 void
 pop_target (void)
 {
-  target_close (&current_target, 0);	/* Let it clean up */
+  target_close (target_stack, 0);	/* Let it clean up */
   if (unpush_target (target_stack) == 1)
     return;
 
@@ -799,12 +799,12 @@ pop_all_targets_above (enum strata above
 {
   while ((int) (current_target.to_stratum) > (int) above_stratum)
     {
-      target_close (&current_target, quitting);
+      target_close (target_stack, quitting);
       if (!unpush_target (target_stack))
 	{
 	  fprintf_unfiltered (gdb_stderr,
 			      "pop_all_targets couldn't find target %s\n",
-			      current_target.to_shortname);
+			      target_stack->to_shortname);
 	  internal_error (__FILE__, __LINE__,
 			  _("failed internal consistency check"));
 	  break;
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [rfc] Do not inherit to_open and to_close
  2008-09-04  1:44 [rfc] Do not inherit to_open and to_close Ulrich Weigand
@ 2008-09-04 12:16 ` Daniel Jacobowitz
  2008-09-05 11:53   ` Ulrich Weigand
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2008-09-04 12:16 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: gdb-patches

On Thu, Sep 04, 2008 at 03:44:03AM +0200, Ulrich Weigand wrote:
> 	* target.c (update_current_target): Do not inherit t_open
> 	or to_close.
> 	(pop_target): Call target_close on target_stack instead
> 	of current_target.
> 	(pop_all_targets_above): Likewise.

This looks right to me.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [rfc] Do not inherit to_open and to_close
  2008-09-04 12:16 ` Daniel Jacobowitz
@ 2008-09-05 11:53   ` Ulrich Weigand
  0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Weigand @ 2008-09-05 11:53 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel Jacobowitz wrote:
> On Thu, Sep 04, 2008 at 03:44:03AM +0200, Ulrich Weigand wrote:
> > 	* target.c (update_current_target): Do not inherit t_open
> > 	or to_close.
> > 	(pop_target): Call target_close on target_stack instead
> > 	of current_target.
> > 	(pop_all_targets_above): Likewise.
> 
> This looks right to me.

Checked in as well.

Thanks,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-09-05 11:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-04  1:44 [rfc] Do not inherit to_open and to_close Ulrich Weigand
2008-09-04 12:16 ` Daniel Jacobowitz
2008-09-05 11:53   ` Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox