public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: sim: handle target sysroot prefix
@ 2015-06-21 18:08 Mike Frysinger
  2015-06-22  9:50 ` Gary Benson
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Mike Frysinger @ 2015-06-21 18:08 UTC (permalink / raw)
  To: gdb-patches; +Cc: gbenson

The default gdb sysroot now sets itself to "target:".  This works for
most remote targets, but when using the simulator, this causes problems
as the sim will attempt to search for that path.

Update the remote-sim logic to skip this leading prefix when it is found
so that the sysroot isn't passed in as an invalid value.

2015-06-21  Mike Frysinger  <vapier@gentoo.org>

	* remote-sim.c: Include gdb_bfd.h.
	(gdbsim_open): Declare new local sysroot pointing to gdb_sysroot.
	Skip TARGET_SYSROOT_PREFIX in gdb_sysroot when it is set.
---
 gdb/remote-sim.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index fd2fd58..b4f25bf 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -21,6 +21,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
+#include "gdb_bfd.h"
 #include "inferior.h"
 #include "infrun.h"
 #include "value.h"
@@ -669,6 +670,7 @@ gdbsim_open (const char *args, int from_tty)
   int len;
   char *arg_buf;
   struct sim_inferior_data *sim_data;
+  const char *sysroot = gdb_sysroot;
   SIM_DESC gdbsim_desc;
 
   if (remote_debug)
@@ -715,7 +717,9 @@ gdbsim_open (const char *args, int from_tty)
     }
   /* Pass along gdb's concept of the sysroot.  */
   strcat (arg_buf, " --sysroot=");
-  strcat (arg_buf, gdb_sysroot);
+  if (startswith (sysroot, TARGET_SYSROOT_PREFIX))
+    sysroot += strlen (TARGET_SYSROOT_PREFIX);
+  strcat (arg_buf, sysroot);
   /* finally, any explicit args */
   if (args)
     {
-- 
2.4.1

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

* Re: [PATCH] gdb: sim: handle target sysroot prefix
  2015-06-21 18:08 [PATCH] gdb: sim: handle target sysroot prefix Mike Frysinger
@ 2015-06-22  9:50 ` Gary Benson
  2015-06-23 15:28   ` Mike Frysinger
  2015-06-23 15:29 ` [PATCH] gdb: microblaze: delete useless stubs Mike Frysinger
  2015-06-23 15:29 ` [PATCH v2] gdb: sim: handle target sysroot prefix Mike Frysinger
  2 siblings, 1 reply; 16+ messages in thread
From: Gary Benson @ 2015-06-22  9:50 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

Hi Mike,

Mike Frysinger wrote:
> The default gdb sysroot now sets itself to "target:".  This works
> for most remote targets, but when using the simulator, this causes
> problems as the sim will attempt to search for that path.
> 
> Update the remote-sim logic to skip this leading prefix when it is
> found so that the sysroot isn't passed in as an invalid value.
> 
> 2015-06-21  Mike Frysinger  <vapier@gentoo.org>
> 
> 	* remote-sim.c: Include gdb_bfd.h.
> 	(gdbsim_open): Declare new local sysroot pointing to gdb_sysroot.
> 	Skip TARGET_SYSROOT_PREFIX in gdb_sysroot when it is set.
> ---
>  gdb/remote-sim.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
> index fd2fd58..b4f25bf 100644
> --- a/gdb/remote-sim.c
> +++ b/gdb/remote-sim.c
> @@ -21,6 +21,7 @@
>     along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
>  
>  #include "defs.h"
> +#include "gdb_bfd.h"
>  #include "inferior.h"
>  #include "infrun.h"
>  #include "value.h"
> @@ -669,6 +670,7 @@ gdbsim_open (const char *args, int from_tty)
>    int len;
>    char *arg_buf;
>    struct sim_inferior_data *sim_data;
> +  const char *sysroot = gdb_sysroot;
>    SIM_DESC gdbsim_desc;
>  
>    if (remote_debug)
> @@ -715,7 +717,9 @@ gdbsim_open (const char *args, int from_tty)
>      }
>    /* Pass along gdb's concept of the sysroot.  */
>    strcat (arg_buf, " --sysroot=");
> -  strcat (arg_buf, gdb_sysroot);
> +  if (startswith (sysroot, TARGET_SYSROOT_PREFIX))
> +    sysroot += strlen (TARGET_SYSROOT_PREFIX);
> +  strcat (arg_buf, sysroot);
>    /* finally, any explicit args */
>    if (args)
>      {

Please use "is_target_filename (sysroot)" rather than startswith.

Please also update the "strlen (gdb_sysroot)" in this function.

Please note that gdb_sysroot can be NULL.

Otherwise looks good to me :)

Cheers,
Gary

-- 
http://gbenson.net/

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

* Re: [PATCH] gdb: sim: handle target sysroot prefix
  2015-06-22  9:50 ` Gary Benson
@ 2015-06-23 15:28   ` Mike Frysinger
  2015-06-24 10:30     ` Gary Benson
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Frysinger @ 2015-06-23 15:28 UTC (permalink / raw)
  To: Gary Benson; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1069 bytes --]

On 22 Jun 2015 10:50, Gary Benson wrote:
> Mike Frysinger wrote:
> > @@ -715,7 +717,9 @@ gdbsim_open (const char *args, int from_tty)
> >      }
> >    /* Pass along gdb's concept of the sysroot.  */
> >    strcat (arg_buf, " --sysroot=");
> > -  strcat (arg_buf, gdb_sysroot);
> > +  if (startswith (sysroot, TARGET_SYSROOT_PREFIX))
> > +    sysroot += strlen (TARGET_SYSROOT_PREFIX);
> > +  strcat (arg_buf, sysroot);
> >    /* finally, any explicit args */
> >    if (args)
> >      {
> 
> Please use "is_target_filename (sysroot)" rather than startswith.

OK

> Please also update the "strlen (gdb_sysroot)" in this function.

OK

> Please note that gdb_sysroot can be NULL.

how so ?  main.c:captured_main specifically handles that:

  /* Set the sysroot path.  */
  gdb_sysroot = relocate_gdb_directory (TARGET_SYSTEM_ROOT,
                    TARGET_SYSTEM_ROOT_RELOCATABLE);

  if (gdb_sysroot == NULL || *gdb_sysroot == '\0')
    {
      xfree (gdb_sysroot);
      gdb_sysroot = xstrdup (TARGET_SYSROOT_PREFIX);
    }
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [PATCH v2] gdb: sim: handle target sysroot prefix
  2015-06-21 18:08 [PATCH] gdb: sim: handle target sysroot prefix Mike Frysinger
  2015-06-22  9:50 ` Gary Benson
  2015-06-23 15:29 ` [PATCH] gdb: microblaze: delete useless stubs Mike Frysinger
@ 2015-06-23 15:29 ` Mike Frysinger
  2015-06-24 10:31   ` Gary Benson
  2015-06-24 13:47   ` Pedro Alves
  2 siblings, 2 replies; 16+ messages in thread
From: Mike Frysinger @ 2015-06-23 15:29 UTC (permalink / raw)
  To: gdb-patches; +Cc: gbenson

The default gdb sysroot now sets itself to "target:".  This works for
most remote targets, but when using the simulator, this causes problems
as the sim will attempt to search for that path.

Update the remote-sim logic to skip this leading prefix when it is found
so that the sysroot isn't passed in as an invalid value.

2015-06-21  Mike Frysinger  <vapier@gentoo.org>

	* remote-sim.c: Include gdb_bfd.h.
	(gdbsim_open): Declare new local sysroot pointing to gdb_sysroot.
	Skip TARGET_SYSROOT_PREFIX in gdb_sysroot when it is active.
---
v2
	- use is_target_filename

 gdb/remote-sim.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index fd2fd58..0c43379 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -21,6 +21,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
+#include "gdb_bfd.h"
 #include "inferior.h"
 #include "infrun.h"
 #include "value.h"
@@ -669,6 +670,7 @@ gdbsim_open (const char *args, int from_tty)
   int len;
   char *arg_buf;
   struct sim_inferior_data *sim_data;
+  const char *sysroot = gdb_sysroot;
   SIM_DESC gdbsim_desc;
 
   if (remote_debug)
@@ -688,7 +690,7 @@ gdbsim_open (const char *args, int from_tty)
   len = (7 + 1			/* gdbsim */
 	 + strlen (" -E little")
 	 + strlen (" --architecture=xxxxxxxxxx")
-	 + strlen (" --sysroot=") + strlen (gdb_sysroot) +
+	 + strlen (" --sysroot=") + strlen (sysroot) +
 	 + (args ? strlen (args) : 0)
 	 + 50) /* slack */ ;
   arg_buf = (char *) alloca (len);
@@ -715,7 +717,9 @@ gdbsim_open (const char *args, int from_tty)
     }
   /* Pass along gdb's concept of the sysroot.  */
   strcat (arg_buf, " --sysroot=");
-  strcat (arg_buf, gdb_sysroot);
+  if (is_target_filename (sysroot))
+    sysroot += strlen (TARGET_SYSROOT_PREFIX);
+  strcat (arg_buf, sysroot);
   /* finally, any explicit args */
   if (args)
     {
-- 
2.2.0.rc0.207.ga3a616c

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

* [PATCH] gdb: microblaze: delete useless stubs
  2015-06-21 18:08 [PATCH] gdb: sim: handle target sysroot prefix Mike Frysinger
  2015-06-22  9:50 ` Gary Benson
@ 2015-06-23 15:29 ` Mike Frysinger
  2015-06-23 15:31   ` Mike Frysinger
  2015-06-23 17:39   ` Michael Eager
  2015-06-23 15:29 ` [PATCH v2] gdb: sim: handle target sysroot prefix Mike Frysinger
  2 siblings, 2 replies; 16+ messages in thread
From: Mike Frysinger @ 2015-06-23 15:29 UTC (permalink / raw)
  To: gdb-patches; +Cc: gbenson

These don't accomplish anything the common core doesn't already, so
punt them as they purely waste code.

2015-06-21  Mike Frysinger  <vapier@gentoo.org>

	* microblaze-tdep.c (microblaze_push_dummy_code): Delete.
	(microblaze_push_dummy_call): Likewise.
	(microblaze_gdbarch_init): Delete calls to set_gdbarch_push_dummy_code
	and set_gdbarch_push_dummy_call.
---
 gdb/microblaze-tdep.c | 26 --------------------------
 1 file changed, 26 deletions(-)

diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index d66914e..8cc1df2 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -134,30 +134,6 @@ microblaze_fetch_instruction (CORE_ADDR pc)
   return extract_unsigned_integer (buf, 4, byte_order);
 }
 \f
-
-static CORE_ADDR
-microblaze_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
-			    CORE_ADDR funcaddr,
-			    struct value **args, int nargs,
-			    struct type *value_type,
-			    CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
-			    struct regcache *regcache)
-{
-  error (_("push_dummy_code not implemented"));
-  return sp;
-}
-
-
-static CORE_ADDR
-microblaze_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
-			    struct regcache *regcache, CORE_ADDR bp_addr,
-			    int nargs, struct value **args, CORE_ADDR sp,
-			    int struct_return, CORE_ADDR struct_addr)
-{
-  error (_("store_arguments not implemented"));
-  return sp;
-}
-
 static const gdb_byte *
 microblaze_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pc, 
 			       int *len)
@@ -749,8 +725,6 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* Call dummy code.  */
   set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
-  set_gdbarch_push_dummy_code (gdbarch, microblaze_push_dummy_code);
-  set_gdbarch_push_dummy_call (gdbarch, microblaze_push_dummy_call);
 
   set_gdbarch_return_value (gdbarch, microblaze_return_value);
   set_gdbarch_stabs_argument_has_addr
-- 
2.4.1

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

* Re: [PATCH] gdb: microblaze: delete useless stubs
  2015-06-23 15:29 ` [PATCH] gdb: microblaze: delete useless stubs Mike Frysinger
@ 2015-06-23 15:31   ` Mike Frysinger
  2015-06-23 17:39   ` Michael Eager
  1 sibling, 0 replies; 16+ messages in thread
From: Mike Frysinger @ 2015-06-23 15:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: gbenson

[-- Attachment #1: Type: text/plain, Size: 67 bytes --]

sorry, ignore this patch.  had a stale local one in my tree.
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH] gdb: microblaze: delete useless stubs
  2015-06-23 15:29 ` [PATCH] gdb: microblaze: delete useless stubs Mike Frysinger
  2015-06-23 15:31   ` Mike Frysinger
@ 2015-06-23 17:39   ` Michael Eager
  1 sibling, 0 replies; 16+ messages in thread
From: Michael Eager @ 2015-06-23 17:39 UTC (permalink / raw)
  To: Mike Frysinger, gdb-patches; +Cc: gbenson

On 06/23/2015 08:29 AM, Mike Frysinger wrote:
> These don't accomplish anything the common core doesn't already, so
> punt them as they purely waste code.
>
> 2015-06-21  Mike Frysinger  <vapier@gentoo.org>
>
> 	* microblaze-tdep.c (microblaze_push_dummy_code): Delete.
> 	(microblaze_push_dummy_call): Likewise.
> 	(microblaze_gdbarch_init): Delete calls to set_gdbarch_push_dummy_code
> 	and set_gdbarch_push_dummy_call.
> ---
>   gdb/microblaze-tdep.c | 26 --------------------------
>   1 file changed, 26 deletions(-)

OK.

-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077

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

* Re: [PATCH] gdb: sim: handle target sysroot prefix
  2015-06-23 15:28   ` Mike Frysinger
@ 2015-06-24 10:30     ` Gary Benson
  2015-06-25  8:35       ` [OB PATCH] Remove gdb_sysroot NULL checks Gary Benson
  0 siblings, 1 reply; 16+ messages in thread
From: Gary Benson @ 2015-06-24 10:30 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

Mike Frysinger wrote:
> On 22 Jun 2015 10:50, Gary Benson wrote:
> > Please note that gdb_sysroot can be NULL.
> 
> how so ?  main.c:captured_main specifically handles that:
> 
>   /* Set the sysroot path.  */
>   gdb_sysroot = relocate_gdb_directory (TARGET_SYSTEM_ROOT,
>                     TARGET_SYSTEM_ROOT_RELOCATABLE);
> 
>   if (gdb_sysroot == NULL || *gdb_sysroot == '\0')
>     {
>       xfree (gdb_sysroot);
>       gdb_sysroot = xstrdup (TARGET_SYSROOT_PREFIX);
>     }

Good point.  I may go and clear out all the gdb_sysroot == NULL
checks.

Cheers,
Gary

-- 
http://gbenson.net/

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

* Re: [PATCH v2] gdb: sim: handle target sysroot prefix
  2015-06-23 15:29 ` [PATCH v2] gdb: sim: handle target sysroot prefix Mike Frysinger
@ 2015-06-24 10:31   ` Gary Benson
  2015-06-24 13:47   ` Pedro Alves
  1 sibling, 0 replies; 16+ messages in thread
From: Gary Benson @ 2015-06-24 10:31 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: gdb-patches

Mike Frysinger wrote:
> The default gdb sysroot now sets itself to "target:".  This works
> for most remote targets, but when using the simulator, this causes
> problems as the sim will attempt to search for that path.
> 
> Update the remote-sim logic to skip this leading prefix when it is
> found so that the sysroot isn't passed in as an invalid value.
> 
> 2015-06-21  Mike Frysinger  <vapier@gentoo.org>
> 
> 	* remote-sim.c: Include gdb_bfd.h.
> 	(gdbsim_open): Declare new local sysroot pointing to gdb_sysroot.
> 	Skip TARGET_SYSROOT_PREFIX in gdb_sysroot when it is active.

Looks good to me :)

Cheers,
Gary

-- 
http://gbenson.net/

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

* Re: [PATCH v2] gdb: sim: handle target sysroot prefix
  2015-06-23 15:29 ` [PATCH v2] gdb: sim: handle target sysroot prefix Mike Frysinger
  2015-06-24 10:31   ` Gary Benson
@ 2015-06-24 13:47   ` Pedro Alves
  2015-06-24 14:32     ` Mike Frysinger
  1 sibling, 1 reply; 16+ messages in thread
From: Pedro Alves @ 2015-06-24 13:47 UTC (permalink / raw)
  To: Mike Frysinger, gdb-patches; +Cc: gbenson

On 06/23/2015 04:29 PM, Mike Frysinger wrote:

>  gdb/remote-sim.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
> index fd2fd58..0c43379 100644
> --- a/gdb/remote-sim.c
> +++ b/gdb/remote-sim.c
> @@ -21,6 +21,7 @@
>     along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
>  
>  #include "defs.h"
> +#include "gdb_bfd.h"
>  #include "inferior.h"
>  #include "infrun.h"
>  #include "value.h"
> @@ -669,6 +670,7 @@ gdbsim_open (const char *args, int from_tty)
>    int len;
>    char *arg_buf;
>    struct sim_inferior_data *sim_data;
> +  const char *sysroot = gdb_sysroot;
>    SIM_DESC gdbsim_desc;
>  
>    if (remote_debug)
> @@ -688,7 +690,7 @@ gdbsim_open (const char *args, int from_tty)
>    len = (7 + 1			/* gdbsim */
>  	 + strlen (" -E little")
>  	 + strlen (" --architecture=xxxxxxxxxx")
> -	 + strlen (" --sysroot=") + strlen (gdb_sysroot) +
> +	 + strlen (" --sysroot=") + strlen (sysroot) +
>  	 + (args ? strlen (args) : 0)
>  	 + 50) /* slack */ ;
>    arg_buf = (char *) alloca (len);
> @@ -715,7 +717,9 @@ gdbsim_open (const char *args, int from_tty)
>      }
>    /* Pass along gdb's concept of the sysroot.  */
>    strcat (arg_buf, " --sysroot=");
> -  strcat (arg_buf, gdb_sysroot);
> +  if (is_target_filename (sysroot))
> +    sysroot += strlen (TARGET_SYSROOT_PREFIX);

Please do this skipping above the "len = " computation.  As is
we'll just oversize arg_bug, but there's no good reason
for the discrepancy.

OK with that change.

(it would be easy to get rid of all that using reconcat.)

Thanks you; thanks Gary.

-- 
Pedro Alves

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

* Re: [PATCH v2] gdb: sim: handle target sysroot prefix
  2015-06-24 13:47   ` Pedro Alves
@ 2015-06-24 14:32     ` Mike Frysinger
  0 siblings, 0 replies; 16+ messages in thread
From: Mike Frysinger @ 2015-06-24 14:32 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, gbenson


[-- Attachment #1.1: Type: text/plain, Size: 1562 bytes --]

On 24 Jun 2015 14:46, Pedro Alves wrote:
> On 06/23/2015 04:29 PM, Mike Frysinger wrote:
> > --- a/gdb/remote-sim.c
> > +++ b/gdb/remote-sim.c
> > @@ -669,6 +670,7 @@ gdbsim_open (const char *args, int from_tty)
> >    int len;
> >    char *arg_buf;
> >    struct sim_inferior_data *sim_data;
> > +  const char *sysroot = gdb_sysroot;
> >    SIM_DESC gdbsim_desc;
> >  
> >    if (remote_debug)
> > @@ -688,7 +690,7 @@ gdbsim_open (const char *args, int from_tty)
> >    len = (7 + 1			/* gdbsim */
> >  	 + strlen (" -E little")
> >  	 + strlen (" --architecture=xxxxxxxxxx")
> > -	 + strlen (" --sysroot=") + strlen (gdb_sysroot) +
> > +	 + strlen (" --sysroot=") + strlen (sysroot) +
> >  	 + (args ? strlen (args) : 0)
> >  	 + 50) /* slack */ ;
> >    arg_buf = (char *) alloca (len);
> > @@ -715,7 +717,9 @@ gdbsim_open (const char *args, int from_tty)
> >      }
> >    /* Pass along gdb's concept of the sysroot.  */
> >    strcat (arg_buf, " --sysroot=");
> > -  strcat (arg_buf, gdb_sysroot);
> > +  if (is_target_filename (sysroot))
> > +    sysroot += strlen (TARGET_SYSROOT_PREFIX);
> 
> Please do this skipping above the "len = " computation.  As is
> we'll just oversize arg_bug, but there's no good reason
> for the discrepancy.
> 
> OK with that change.

already pushed ;).  i've committed the attached on top though.

> (it would be easy to get rid of all that using reconcat.)

hmm, maybe.  would be nice if the argv could be built up incrementally.
maybe xstrprintf would be a simple stop gap.
-mike

[-- Attachment #1.2: 0001-gdb-sim-merge-the-sysroot-update-logic-together.patch --]
[-- Type: text/x-diff, Size: 1860 bytes --]

From 87d1b30944783ae0efb49236c6d872d775a37417 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Wed, 24 Jun 2015 21:23:12 +0700
Subject: [PATCH] gdb: sim: merge the sysroot update logic together

Initialize the local sysroot fully before we start using it.
This keeps it all a bit simpler.
---
 gdb/ChangeLog    | 4 ++++
 gdb/remote-sim.c | 8 +++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f46a620..19144ed 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2015-06-24  Mike Frysinger  <vapier@gentoo.org>
 
+	* remote-sim.c (gdbsim_open): Move sysroot update to the top.
+
+2015-06-24  Mike Frysinger  <vapier@gentoo.org>
+
 	* remote-sim.c: Include gdb_bfd.h.
 	(gdbsim_open): Declare new local sysroot pointing to gdb_sysroot.
 	Skip TARGET_SYSROOT_PREFIX in gdb_sysroot when it is active.
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 0c43379..82c129d 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -670,9 +670,13 @@ gdbsim_open (const char *args, int from_tty)
   int len;
   char *arg_buf;
   struct sim_inferior_data *sim_data;
-  const char *sysroot = gdb_sysroot;
+  const char *sysroot;
   SIM_DESC gdbsim_desc;
 
+  sysroot = gdb_sysroot;
+  if (is_target_filename (sysroot))
+    sysroot += strlen (TARGET_SYSROOT_PREFIX);
+
   if (remote_debug)
     fprintf_unfiltered (gdb_stdlog,
 			"gdbsim_open: args \"%s\"\n", args ? args : "(null)");
@@ -717,8 +721,6 @@ gdbsim_open (const char *args, int from_tty)
     }
   /* Pass along gdb's concept of the sysroot.  */
   strcat (arg_buf, " --sysroot=");
-  if (is_target_filename (sysroot))
-    sysroot += strlen (TARGET_SYSROOT_PREFIX);
   strcat (arg_buf, sysroot);
   /* finally, any explicit args */
   if (args)
-- 
2.4.4


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* [OB PATCH] Remove gdb_sysroot NULL checks
  2015-06-24 10:30     ` Gary Benson
@ 2015-06-25  8:35       ` Gary Benson
  0 siblings, 0 replies; 16+ messages in thread
From: Gary Benson @ 2015-06-25  8:35 UTC (permalink / raw)
  To: gdb-patches; +Cc: Mike Frysinger

Hi all,

Since fed040c6a50399617d8265cbddc7fd21b3f134ef gdb_sysroot is
never NULL.  This commit removes all gdb_sysroot NULL checks.

Pushed as obvious.

Cheers,
Gary

--
gdb/ChangeLog:

	* exec.c (exec_file_locate_attach): Remove gdb_sysroot NULL check.
	* infrun.c (follow_exec): Likewise.
	* remote.c (remote_filesystem_is_local): Likewise.
	* solib.c (solib_find_1): Likewise.
---
 gdb/ChangeLog |    7 +++++++
 gdb/exec.c    |    3 +--
 gdb/infrun.c  |    2 +-
 gdb/remote.c  |    3 +--
 gdb/solib.c   |   29 ++++++++++++-----------------
 5 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/gdb/exec.c b/gdb/exec.c
index 8a4ab6f..3dfc437 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -154,8 +154,7 @@ exec_file_locate_attach (int pid, int from_tty)
 
   /* If gdb_sysroot is not empty and the discovered filename
      is absolute then prefix the filename with gdb_sysroot.  */
-  if (gdb_sysroot != NULL && *gdb_sysroot != '\0'
-      && IS_ABSOLUTE_PATH (exec_file))
+  if (*gdb_sysroot != '\0' && IS_ABSOLUTE_PATH (exec_file))
     full_exec_path = exec_file_find (exec_file, NULL);
 
   if (full_exec_path == NULL)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 233d0f8..792f847 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1133,7 +1133,7 @@ follow_exec (ptid_t ptid, char *execd_pathname)
 
   breakpoint_init_inferior (inf_execd);
 
-  if (gdb_sysroot != NULL && *gdb_sysroot != '\0')
+  if (*gdb_sysroot != '\0')
     {
       char *name = exec_file_find (execd_pathname, NULL);
 
diff --git a/gdb/remote.c b/gdb/remote.c
index f15d75e..68dd99d 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -10538,8 +10538,7 @@ remote_filesystem_is_local (struct target_ops *self)
      this case we treat the remote filesystem as local if the
      sysroot is exactly TARGET_SYSROOT_PREFIX and if the stub
      does not support vFile:open.  */
-  if (gdb_sysroot != NULL
-      && strcmp (gdb_sysroot, TARGET_SYSROOT_PREFIX) == 0)
+  if (strcmp (gdb_sysroot, TARGET_SYSROOT_PREFIX) == 0)
     {
       enum packet_support ps = packet_support (PACKET_vFile_open);
 
diff --git a/gdb/solib.c b/gdb/solib.c
index 0010c2f..ed1bc25 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -159,23 +159,18 @@ solib_find_1 (char *in_pathname, int *fd, int is_solib)
   struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
   char *sysroot = gdb_sysroot;
 
-  if (sysroot != NULL)
-    {
-      /* If the absolute prefix starts with "target:" but the
-	 filesystem accessed by the target_fileio_* methods
-	 is the local filesystem then we strip the "target:"
-	 prefix now and work with the local filesystem.  This
-	 ensures that the same search algorithm is used for
-	 all local files regardless of whether a "target:"
-	 prefix was used.  */
-      if (is_target_filename (sysroot) && target_filesystem_is_local ())
-	sysroot += strlen (TARGET_SYSROOT_PREFIX);
-
-      if (*sysroot == '\0')
-	sysroot = NULL;
-    }
-
-  if (sysroot != NULL)
+  /* If the absolute prefix starts with "target:" but the filesystem
+     accessed by the target_fileio_* methods is the local filesystem
+     then we strip the "target:" prefix now and work with the local
+     filesystem.  This ensures that the same search algorithm is used
+     for all local files regardless of whether a "target:" prefix was
+     used.  */
+  if (is_target_filename (sysroot) && target_filesystem_is_local ())
+    sysroot += strlen (TARGET_SYSROOT_PREFIX);
+
+  if (*sysroot == '\0')
+    sysroot = NULL;
+  else
     {
       int prefix_len = strlen (sysroot);
 
-- 
1.7.1

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

* Re: [PATCH] gdb: microblaze: delete useless stubs
  2015-06-22  4:56   ` Mike Frysinger
@ 2015-06-22 14:28     ` Michael Eager
  0 siblings, 0 replies; 16+ messages in thread
From: Michael Eager @ 2015-06-22 14:28 UTC (permalink / raw)
  To: gdb-patches

On 06/21/2015 09:56 PM, Mike Frysinger wrote:
> On 21 Jun 2015 12:36, Michael Eager wrote:
>> On 06/21/2015 11:13 AM, Mike Frysinger wrote:
>>> These don't accomplish anything the common core doesn't already, so
>>> punt them as they purely waste code.
>>>
>>> 2015-06-21  Mike Frysinger  <vapier@gentoo.org>
>>>
>>> 	* microblaze-tdep.c (microblaze_push_dummy_code): Delete.
>>> 	(microblaze_push_dummy_call): Likewise.
>>> 	(microblaze_gdbarch_init): Delete calls to set_gdbarch_push_dummy_code
>>> 	and set_gdbarch_push_dummy_call.
>>
>> Does the common code issue an error if someone tries
>> to call a target function?
>
> yes
>
> gdb/infcall.c:
> struct value *
> call_function_by_hand_dummy (struct value *function,
> ...
>    if (!gdbarch_push_dummy_call_p (gdbarch))
>      error (_("This target does not support function calls."));
>
> $ ./gdb ...
> (gdb) p foo(1)
> This target does not support function calls.
> -mike

Go ahead and commit.


-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077

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

* Re: [PATCH] gdb: microblaze: delete useless stubs
  2015-06-21 19:36 ` Michael Eager
@ 2015-06-22  4:56   ` Mike Frysinger
  2015-06-22 14:28     ` Michael Eager
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Frysinger @ 2015-06-22  4:56 UTC (permalink / raw)
  To: Michael Eager; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 880 bytes --]

On 21 Jun 2015 12:36, Michael Eager wrote:
> On 06/21/2015 11:13 AM, Mike Frysinger wrote:
> > These don't accomplish anything the common core doesn't already, so
> > punt them as they purely waste code.
> >
> > 2015-06-21  Mike Frysinger  <vapier@gentoo.org>
> >
> > 	* microblaze-tdep.c (microblaze_push_dummy_code): Delete.
> > 	(microblaze_push_dummy_call): Likewise.
> > 	(microblaze_gdbarch_init): Delete calls to set_gdbarch_push_dummy_code
> > 	and set_gdbarch_push_dummy_call.
> 
> Does the common code issue an error if someone tries
> to call a target function?

yes

gdb/infcall.c:
struct value *
call_function_by_hand_dummy (struct value *function,
...
  if (!gdbarch_push_dummy_call_p (gdbarch))
    error (_("This target does not support function calls."));

$ ./gdb ...
(gdb) p foo(1)
This target does not support function calls.
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH] gdb: microblaze: delete useless stubs
  2015-06-21 18:13 [PATCH] gdb: microblaze: delete useless stubs Mike Frysinger
@ 2015-06-21 19:36 ` Michael Eager
  2015-06-22  4:56   ` Mike Frysinger
  0 siblings, 1 reply; 16+ messages in thread
From: Michael Eager @ 2015-06-21 19:36 UTC (permalink / raw)
  To: Mike Frysinger, gdb-patches

On 06/21/2015 11:13 AM, Mike Frysinger wrote:
> These don't accomplish anything the common core doesn't already, so
> punt them as they purely waste code.
>
> 2015-06-21  Mike Frysinger  <vapier@gentoo.org>
>
> 	* microblaze-tdep.c (microblaze_push_dummy_code): Delete.
> 	(microblaze_push_dummy_call): Likewise.
> 	(microblaze_gdbarch_init): Delete calls to set_gdbarch_push_dummy_code
> 	and set_gdbarch_push_dummy_call.

Does the common code issue an error if someone tries
to call a target function?


-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077

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

* [PATCH] gdb: microblaze: delete useless stubs
@ 2015-06-21 18:13 Mike Frysinger
  2015-06-21 19:36 ` Michael Eager
  0 siblings, 1 reply; 16+ messages in thread
From: Mike Frysinger @ 2015-06-21 18:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: eager

These don't accomplish anything the common core doesn't already, so
punt them as they purely waste code.

2015-06-21  Mike Frysinger  <vapier@gentoo.org>

	* microblaze-tdep.c (microblaze_push_dummy_code): Delete.
	(microblaze_push_dummy_call): Likewise.
	(microblaze_gdbarch_init): Delete calls to set_gdbarch_push_dummy_code
	and set_gdbarch_push_dummy_call.
---
 gdb/microblaze-tdep.c | 26 --------------------------
 1 file changed, 26 deletions(-)

diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index d66914e..8cc1df2 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -134,30 +134,6 @@ microblaze_fetch_instruction (CORE_ADDR pc)
   return extract_unsigned_integer (buf, 4, byte_order);
 }
 \f
-
-static CORE_ADDR
-microblaze_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
-			    CORE_ADDR funcaddr,
-			    struct value **args, int nargs,
-			    struct type *value_type,
-			    CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
-			    struct regcache *regcache)
-{
-  error (_("push_dummy_code not implemented"));
-  return sp;
-}
-
-
-static CORE_ADDR
-microblaze_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
-			    struct regcache *regcache, CORE_ADDR bp_addr,
-			    int nargs, struct value **args, CORE_ADDR sp,
-			    int struct_return, CORE_ADDR struct_addr)
-{
-  error (_("store_arguments not implemented"));
-  return sp;
-}
-
 static const gdb_byte *
 microblaze_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pc, 
 			       int *len)
@@ -749,8 +725,6 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* Call dummy code.  */
   set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
-  set_gdbarch_push_dummy_code (gdbarch, microblaze_push_dummy_code);
-  set_gdbarch_push_dummy_call (gdbarch, microblaze_push_dummy_call);
 
   set_gdbarch_return_value (gdbarch, microblaze_return_value);
   set_gdbarch_stabs_argument_has_addr
-- 
2.4.1

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

end of thread, other threads:[~2015-06-25  8:35 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-21 18:08 [PATCH] gdb: sim: handle target sysroot prefix Mike Frysinger
2015-06-22  9:50 ` Gary Benson
2015-06-23 15:28   ` Mike Frysinger
2015-06-24 10:30     ` Gary Benson
2015-06-25  8:35       ` [OB PATCH] Remove gdb_sysroot NULL checks Gary Benson
2015-06-23 15:29 ` [PATCH] gdb: microblaze: delete useless stubs Mike Frysinger
2015-06-23 15:31   ` Mike Frysinger
2015-06-23 17:39   ` Michael Eager
2015-06-23 15:29 ` [PATCH v2] gdb: sim: handle target sysroot prefix Mike Frysinger
2015-06-24 10:31   ` Gary Benson
2015-06-24 13:47   ` Pedro Alves
2015-06-24 14:32     ` Mike Frysinger
2015-06-21 18:13 [PATCH] gdb: microblaze: delete useless stubs Mike Frysinger
2015-06-21 19:36 ` Michael Eager
2015-06-22  4:56   ` Mike Frysinger
2015-06-22 14:28     ` Michael Eager

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).