Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Implement darwin remote TARGET_OBJECT_DARWIN_DYLD_INFO.
@ 2018-02-27 10:10 Xavier Roirand
  2018-02-27 10:26 ` tgingold
  0 siblings, 1 reply; 3+ messages in thread
From: Xavier Roirand @ 2018-02-27 10:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: brobecker, Xavier Roirand, tgingold

From: Xavier Roirand <xavier.roirand@adacore.com>

gdb/ChangeLog (Tristan Gingold <gingold@adacore.com>):

	* remote.c (remote_xfer_partial): Handle DARWIN_DYLD_INFO.
---
 gdb/ChangeLog |  6 ++++++
 gdb/remote.c  | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b9a9bcd..098ebda 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+
+2018-02-27  Tristan Gingold  <gingold@adacore.com>
+
+	Pushed by Xavier Roirand <roirand@adacore.com>.
+	* remote.c (remote_xfer_partial): Handle DARWIN_DYLD_INFO.
+
 2018-02-26  Maciej W. Rozycki  <macro@mips.com>
 
 	* mips-tdep.c (mips_gdbarch_init): Don't use a 32-bit BFD
diff --git a/gdb/remote.c b/gdb/remote.c
index 15d6c5b..95fbfc1 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -10495,6 +10495,39 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object,
 	return TARGET_XFER_E_IO;
     }
 
+  if (object == TARGET_OBJECT_DARWIN_DYLD_INFO)
+    {
+      /* Can only read.  */
+      if (readbuf == NULL)
+	return TARGET_XFER_E_IO;
+
+      if (offset == 0 && len <= 8)
+	{
+	  ULONGEST addr;
+	  int i;
+
+	  putpkt ("qShlibInfoAddr");
+	  getpkt (&rs->buf, &rs->buf_size, 0);
+	  if (packet_check_result (rs->buf) != PACKET_OK)
+	    return TARGET_XFER_E_IO;
+
+	  /* The packet contains the address in hex (but not suitable for
+	     hex2bin as the number of digits is arbitrary.  */
+	  addr = strtoulst (rs->buf, NULL, 16);
+
+	  /* Store it in big-endian.  */
+	  for (i = len - 1; i >= 0; i--)
+	    {
+	      readbuf[i] = addr & 0xff;
+	      addr >>= 8;
+	    }
+
+	  *xfered_len = len;
+	  return TARGET_XFER_OK;
+	}
+      else
+	return TARGET_XFER_EOF;
+    }
   /* Only handle flash writes.  */
   if (writebuf != NULL)
     {
-- 
2.7.4


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

* Re: [RFA] Implement darwin remote TARGET_OBJECT_DARWIN_DYLD_INFO.
  2018-02-27 10:10 [RFA] Implement darwin remote TARGET_OBJECT_DARWIN_DYLD_INFO Xavier Roirand
@ 2018-02-27 10:26 ` tgingold
  2018-02-27 10:42   ` Yao Qi
  0 siblings, 1 reply; 3+ messages in thread
From: tgingold @ 2018-02-27 10:26 UTC (permalink / raw)
  To: Xavier Roirand; +Cc: brobecker, Xavier Roirand, gdb-patches

Hi,

A bit of context.

I have never submitted this code before because it doesn't use the official gdb remote packet (‘qXfer:libraries:read’) but the one used by Apple (aka lldb) debugserver.

So with this patch, gdb is able to use debugserver.

Tristan.

----- Mail original -----
> From: Xavier Roirand <xavier.roirand@adacore.com>
> 
> gdb/ChangeLog (Tristan Gingold <gingold@adacore.com>):
> 
> 	* remote.c (remote_xfer_partial): Handle DARWIN_DYLD_INFO.
> ---
>  gdb/ChangeLog |  6 ++++++
>  gdb/remote.c  | 33 +++++++++++++++++++++++++++++++++
>  2 files changed, 39 insertions(+)
> 
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index b9a9bcd..098ebda 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,9 @@
> +
> +2018-02-27  Tristan Gingold  <gingold@adacore.com>
> +
> +	Pushed by Xavier Roirand <roirand@adacore.com>.
> +	* remote.c (remote_xfer_partial): Handle DARWIN_DYLD_INFO.
> +
>  2018-02-26  Maciej W. Rozycki  <macro@mips.com>
>  
>  	* mips-tdep.c (mips_gdbarch_init): Don't use a 32-bit BFD
> diff --git a/gdb/remote.c b/gdb/remote.c
> index 15d6c5b..95fbfc1 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -10495,6 +10495,39 @@ remote_xfer_partial (struct target_ops *ops,
> enum target_object object,
>  	return TARGET_XFER_E_IO;
>      }
>  
> +  if (object == TARGET_OBJECT_DARWIN_DYLD_INFO)
> +    {
> +      /* Can only read.  */
> +      if (readbuf == NULL)
> +	return TARGET_XFER_E_IO;
> +
> +      if (offset == 0 && len <= 8)
> +	{
> +	  ULONGEST addr;
> +	  int i;
> +
> +	  putpkt ("qShlibInfoAddr");
> +	  getpkt (&rs->buf, &rs->buf_size, 0);
> +	  if (packet_check_result (rs->buf) != PACKET_OK)
> +	    return TARGET_XFER_E_IO;
> +
> +	  /* The packet contains the address in hex (but not suitable for
> +	     hex2bin as the number of digits is arbitrary.  */
> +	  addr = strtoulst (rs->buf, NULL, 16);
> +
> +	  /* Store it in big-endian.  */
> +	  for (i = len - 1; i >= 0; i--)
> +	    {
> +	      readbuf[i] = addr & 0xff;
> +	      addr >>= 8;
> +	    }
> +
> +	  *xfered_len = len;
> +	  return TARGET_XFER_OK;
> +	}
> +      else
> +	return TARGET_XFER_EOF;
> +    }
>    /* Only handle flash writes.  */
>    if (writebuf != NULL)
>      {
> --
> 2.7.4
> 
> 


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

* Re: [RFA] Implement darwin remote TARGET_OBJECT_DARWIN_DYLD_INFO.
  2018-02-27 10:26 ` tgingold
@ 2018-02-27 10:42   ` Yao Qi
  0 siblings, 0 replies; 3+ messages in thread
From: Yao Qi @ 2018-02-27 10:42 UTC (permalink / raw)
  To: tgingold; +Cc: Xavier Roirand, brobecker, Xavier Roirand, gdb-patches

tgingold@free.fr writes:

Hi Tristan,
Thanks for the input,

> I have never submitted this code before because it doesn't use the
> official gdb remote packet (‘qXfer:libraries:read’) but the one used
> by Apple (aka lldb) debugserver.

With this patch applied, GDB starts to send packet qShlibInfoAddr.

> So with this patch, gdb is able to use debugserver.

This is a good justification to add this packet, but we still need to
document this packet.

-- 
Yao (齐尧)


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

end of thread, other threads:[~2018-02-27 10:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-27 10:10 [RFA] Implement darwin remote TARGET_OBJECT_DARWIN_DYLD_INFO Xavier Roirand
2018-02-27 10:26 ` tgingold
2018-02-27 10:42   ` Yao Qi

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