Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Ricard Wanderlof <ricard.wanderlof@axis.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH] Fix CRISv32 compilation
Date: Fri, 30 Aug 2013 13:30:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.00.1308301528420.10770@lnxricardw.se.axis.com> (raw)

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


This patch adds support for threaded debugging on the CRISv32
architecture. It's been floating around for several years now in our local
repository so it's way overdue pushing upstream.

Patch included inline for review and as attachement for use.


Suggested-by: Edgar Iglisias <edgar.iglesias@gmail.com>
Signed-off-by: Ricard Wanderlof <ricardw@axis.com>


2013-08-30  Ricard Wanderlof  <ricardw@axis.com>

  	* cris-tdep.c: Fix typedef for elf_greg_t.
  	  (cris_gdbarch_init): Add call to
  	  set_gdbarch_fetch_tls_load_module_address.

gdbserver

    	* linux-crisv32-low.c (ps_get_thread_area): New function.



diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 03041e4..dce2724 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -3820,7 +3820,7 @@ cris_delayed_get_disassembler (bfd_vma addr, struct disassemble_info *info)
   }

   /* Copied from <asm/elf.h>.  */
-typedef unsigned long elf_greg_t;
+typedef uint32_t elf_greg_t;

   /* Same as user_regs_struct struct in <asm/user.h>.  */
   #define CRISV10_ELF_NGREG 35
@@ -4137,6 +4137,9 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
         set_gdbarch_single_step_through_delay
   	(gdbarch, crisv32_single_step_through_delay);

+      set_gdbarch_fetch_tls_load_module_address (gdbarch,
+                                                 svr4_fetch_objfile_link_map);
+
         break;

       default:
diff --git a/gdb/gdbserver/linux-crisv32-low.c b/gdb/gdbserver/linux-crisv32-low.c
index 2849d02..84cb7ff 100644
--- a/gdb/gdbserver/linux-crisv32-low.c
+++ b/gdb/gdbserver/linux-crisv32-low.c
@@ -27,6 +27,10 @@ extern const struct target_desc *tdesc_crisv32;
   /* CRISv32 */
   #define cris_num_regs 49

+#ifndef PTRACE_GET_THREAD_AREA
+#define PTRACE_GET_THREAD_AREA 25
+#endif
+
   /* Note: Ignoring USP (having the stack pointer in two locations causes trouble
      without any significant gain).  */

@@ -339,6 +343,20 @@ cris_stopped_data_address (void)
     return eda;
   }

+ps_err_e
+ps_get_thread_area (const struct ps_prochandle *ph,
+                    lwpid_t lwpid, int idx, void **base)
+{
+  if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
+    return PS_ERR;
+
+  /* IDX is the bias from the thread pointer to the beginning of the
+     thread descriptor.  It has to be subtracted due to implementation
+     quirks in libthread_db.  */
+  *base = (void *) ((char *)*base - idx);
+  return PS_OK;
+}
+
   static void
   cris_fill_gregset (struct regcache *regcache, void *buf)
   {


/Ricard
-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch file.patch --]
[-- Type: text/x-diff; name="cris-head-thread.patch", Size: 1934 bytes --]

diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 03041e4..dce2724 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -3820,7 +3820,7 @@ cris_delayed_get_disassembler (bfd_vma addr, struct disassemble_info *info)
 }
 
 /* Copied from <asm/elf.h>.  */
-typedef unsigned long elf_greg_t;
+typedef uint32_t elf_greg_t;
 
 /* Same as user_regs_struct struct in <asm/user.h>.  */
 #define CRISV10_ELF_NGREG 35
@@ -4137,6 +4137,9 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       set_gdbarch_single_step_through_delay 
 	(gdbarch, crisv32_single_step_through_delay);
 
+      set_gdbarch_fetch_tls_load_module_address (gdbarch,
+                                                 svr4_fetch_objfile_link_map);
+
       break;
 
     default:
diff --git a/gdb/gdbserver/linux-crisv32-low.c b/gdb/gdbserver/linux-crisv32-low.c
index 2849d02..84cb7ff 100644
--- a/gdb/gdbserver/linux-crisv32-low.c
+++ b/gdb/gdbserver/linux-crisv32-low.c
@@ -27,6 +27,10 @@ extern const struct target_desc *tdesc_crisv32;
 /* CRISv32 */
 #define cris_num_regs 49
 
+#ifndef PTRACE_GET_THREAD_AREA
+#define PTRACE_GET_THREAD_AREA 25
+#endif
+
 /* Note: Ignoring USP (having the stack pointer in two locations causes trouble
    without any significant gain).  */
 
@@ -339,6 +343,20 @@ cris_stopped_data_address (void)
   return eda;
 }
 
+ps_err_e
+ps_get_thread_area (const struct ps_prochandle *ph,
+                    lwpid_t lwpid, int idx, void **base)
+{
+  if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
+    return PS_ERR;
+
+  /* IDX is the bias from the thread pointer to the beginning of the
+     thread descriptor.  It has to be subtracted due to implementation
+     quirks in libthread_db.  */
+  *base = (void *) ((char *)*base - idx);
+  return PS_OK;
+}
+
 static void
 cris_fill_gregset (struct regcache *regcache, void *buf)
 {

             reply	other threads:[~2013-08-30 13:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-30 13:30 Ricard Wanderlof [this message]
2013-09-02 18:04 ` [PATCH][CRISv32] Add support for threaded debugging Pedro Alves
2013-09-03 12:35   ` Ricard Wanderlof
2013-09-03 14:32     ` Pedro Alves
2013-09-03 14:58       ` Ricard Wanderlof
2013-09-03 15:02         ` Pedro Alves
  -- strict thread matches above, loose matches on Subject: below --
2013-08-30 13:13 [PATCH] Fix CRISv32 compilation Ricard Wanderlof
2013-09-02 17:29 ` Pedro Alves
     [not found]   ` <alpine.DEB.2.00.1309030857010.10770@lnxricardw.se.axis.com>
2013-09-03 12:03     ` Pedro Alves
2013-09-03 14:23       ` Ricard Wanderlof
2013-09-06  8:09   ` Ricard Wanderlof

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=alpine.DEB.2.00.1308301528420.10770@lnxricardw.se.axis.com \
    --to=ricard.wanderlof@axis.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