Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: dje@google.com (Doug Evans)
To: gdb-patches@sourceware.org
Subject: [RFA] call_function_by_hand dummy_addr cleanup
Date: Thu, 04 Dec 2008 20:44:00 -0000	[thread overview]
Message-ID: <20081204204324.6D9CD1C7A10@localhost> (raw)

Hi. Some minor cleanup.
Effort is made, especially in the ON_STACK case, to compute dummy_addr,
but the value is never used.

Ok to check in?

The patch itself is actually rather trivial, most of the size
is due to some re-indentation.
Appended at the end is the same patch produced with cvs diff -b
to improve the S/N ratio.

2008-12-04  Doug Evans  <dje@google.com>

	* infcall.c (call_function_by_hand): Clean up use of local dummy_addr.

Index: infcall.c
===================================================================
RCS file: /cvs/src/src/gdb/infcall.c,v
retrieving revision 1.106
diff -u -p -r1.106 infcall.c
--- infcall.c	18 Nov 2008 00:13:02 -0000	1.106
+++ infcall.c	4 Dec 2008 20:38:11 -0000
@@ -310,7 +310,6 @@ struct value *
 call_function_by_hand (struct value *function, int nargs, struct value **args)
 {
   CORE_ADDR sp;
-  CORE_ADDR dummy_addr;
   struct type *values_type, *target_values_type;
   unsigned char struct_return = 0, lang_struct_return = 0;
   CORE_ADDR struct_addr = 0;
@@ -471,35 +470,26 @@ call_function_by_hand (struct value *fun
   switch (gdbarch_call_dummy_location (gdbarch))
     {
     case ON_STACK:
-      /* "dummy_addr" is here just to keep old targets happy.  New
-	 targets return that same information via "sp" and "bp_addr".  */
-      if (gdbarch_inner_than (gdbarch, 1, 2))
-	{
-	  sp = push_dummy_code (gdbarch, sp, funaddr,
+      sp = push_dummy_code (gdbarch, sp, funaddr,
 				args, nargs, target_values_type,
 				&real_pc, &bp_addr, get_current_regcache ());
-	  dummy_addr = sp;
-	}
-      else
-	{
-	  dummy_addr = sp;
-	  sp = push_dummy_code (gdbarch, sp, funaddr,
-				args, nargs, target_values_type,
-				&real_pc, &bp_addr, get_current_regcache ());
-	}
       break;
     case AT_ENTRY_POINT:
-      real_pc = funaddr;
-      dummy_addr = entry_point_address ();
-      /* Make certain that the address points at real code, and not a
-         function descriptor.  */
-      dummy_addr = gdbarch_convert_from_func_ptr_addr (gdbarch,
-						       dummy_addr,
-						       &current_target);
-      /* A call dummy always consists of just a single breakpoint, so
-         it's address is the same as the address of the dummy.  */
-      bp_addr = dummy_addr;
-      break;
+      {
+	CORE_ADDR dummy_addr;
+
+	real_pc = funaddr;
+	dummy_addr = entry_point_address ();
+	/* Make certain that the address points at real code, and not a
+	   function descriptor.  */
+	dummy_addr = gdbarch_convert_from_func_ptr_addr (gdbarch,
+							 dummy_addr,
+							 &current_target);
+	/* A call dummy always consists of just a single breakpoint, so
+	   its address is the same as the address of the dummy.  */
+	bp_addr = dummy_addr;
+	break;
+      }
     case AT_SYMBOL:
       /* Some executables define a symbol __CALL_DUMMY_ADDRESS whose
 	 address is the location where the breakpoint should be
@@ -507,6 +497,7 @@ call_function_by_hand (struct value *fun
 	 this can be deleted - ON_STACK is a better option.  */
       {
 	struct minimal_symbol *sym;
+	CORE_ADDR dummy_addr;
 
 	sym = lookup_minimal_symbol ("__CALL_DUMMY_ADDRESS", NULL, NULL);
 	real_pc = funaddr;



---

Same patch with -b:

Index: infcall.c
===================================================================
RCS file: /cvs/src/src/gdb/infcall.c,v
retrieving revision 1.106
diff -u -p -b -r1.106 infcall.c
--- infcall.c	18 Nov 2008 00:13:02 -0000	1.106
+++ infcall.c	4 Dec 2008 20:38:29 -0000
@@ -310,7 +310,6 @@ struct value *
 call_function_by_hand (struct value *function, int nargs, struct value **args)
 {
   CORE_ADDR sp;
-  CORE_ADDR dummy_addr;
   struct type *values_type, *target_values_type;
   unsigned char struct_return = 0, lang_struct_return = 0;
   CORE_ADDR struct_addr = 0;
@@ -471,24 +470,14 @@ call_function_by_hand (struct value *fun
   switch (gdbarch_call_dummy_location (gdbarch))
     {
     case ON_STACK:
-      /* "dummy_addr" is here just to keep old targets happy.  New
-	 targets return that same information via "sp" and "bp_addr".  */
-      if (gdbarch_inner_than (gdbarch, 1, 2))
-	{
 	  sp = push_dummy_code (gdbarch, sp, funaddr,
 				args, nargs, target_values_type,
 				&real_pc, &bp_addr, get_current_regcache ());
-	  dummy_addr = sp;
-	}
-      else
-	{
-	  dummy_addr = sp;
-	  sp = push_dummy_code (gdbarch, sp, funaddr,
-				args, nargs, target_values_type,
-				&real_pc, &bp_addr, get_current_regcache ());
-	}
       break;
     case AT_ENTRY_POINT:
+      {
+	CORE_ADDR dummy_addr;
+
       real_pc = funaddr;
       dummy_addr = entry_point_address ();
       /* Make certain that the address points at real code, and not a
@@ -497,9 +486,10 @@ call_function_by_hand (struct value *fun
 						       dummy_addr,
 						       &current_target);
       /* A call dummy always consists of just a single breakpoint, so
-         it's address is the same as the address of the dummy.  */
+	   its address is the same as the address of the dummy.  */
       bp_addr = dummy_addr;
       break;
+      }
     case AT_SYMBOL:
       /* Some executables define a symbol __CALL_DUMMY_ADDRESS whose
 	 address is the location where the breakpoint should be
@@ -507,6 +497,7 @@ call_function_by_hand (struct value *fun
 	 this can be deleted - ON_STACK is a better option.  */
       {
 	struct minimal_symbol *sym;
+	CORE_ADDR dummy_addr;
 
 	sym = lookup_minimal_symbol ("__CALL_DUMMY_ADDRESS", NULL, NULL);
 	real_pc = funaddr;


             reply	other threads:[~2008-12-04 20:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-04 20:44 Doug Evans [this message]
2008-12-04 21:25 ` Pedro Alves

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=20081204204324.6D9CD1C7A10@localhost \
    --to=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    /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