Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Get rid of current_gdbarch in xtensa
@ 2008-05-19 15:17 Markus Deuling
  2008-05-20 18:08 ` Ulrich Weigand
  0 siblings, 1 reply; 6+ messages in thread
From: Markus Deuling @ 2008-05-19 15:17 UTC (permalink / raw)
  To: GDB Patches; +Cc: , Ulrich Weigand <uweigand@de.ibm.com>

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

Hi,

this patch get rid of the last to current_gdbarch's in xtensa target. Unfortunately I
dont have a xtensa machine here. If anyone has access to such a machine I'd welcome
a test run with this patch very much. Thanks in advance.

ChangeLog:

	* xtensa-tdep.c (call0_track_op): Add gdbarch as parameter and replace
	current_gdbarch. Update callers.
	(call0_analyze_prologue): Likewise.

Regards,
Markus

-- 
  Markus Deuling
  GNU Toolchain for Linux on Cell BE
  deuling@de.ibm.com


[-- Attachment #2: diff-xtensa --]
[-- Type: text/plain, Size: 2504 bytes --]

diff -urpN src/gdb/xtensa-tdep.c dev/gdb/xtensa-tdep.c
--- src/gdb/xtensa-tdep.c	2008-05-16 06:17:17.000000000 +0200
+++ dev/gdb/xtensa-tdep.c	2008-05-16 08:09:09.000000000 +0200
@@ -1981,7 +1981,7 @@ call0_classify_opcode (xtensa_isa isa, x
 static void
 call0_track_op (xtensa_c0reg_t dst[], xtensa_c0reg_t src[],
 		xtensa_insn_kind opclass, int nods, unsigned odv[],
-		CORE_ADDR pc, int spreg)
+		CORE_ADDR pc, int spreg, struct gdbarch *gdbarch)
 {
   unsigned litbase, litaddr, litval;
 
@@ -2034,9 +2034,9 @@ call0_track_op (xtensa_c0reg_t dst[], xt
       /* 2 operands: dst, literal offset.  */
       gdb_assert (nods == 2);
       /* litbase = xtensa_get_litbase (pc); can be also used.  */
-      litbase = (gdbarch_tdep (current_gdbarch)->litbase_regnum == -1)
+      litbase = (gdbarch_tdep (gdbarch)->litbase_regnum == -1)
 	? 0 : xtensa_read_register
-		(gdbarch_tdep (current_gdbarch)->litbase_regnum);
+		(gdbarch_tdep (gdbarch)->litbase_regnum);
       litaddr = litbase & 1
 		  ? (litbase & ~1) + (signed)odv[1]
 		  : (pc + 3  + (signed)odv[1]) & ~3;
@@ -2093,8 +2093,9 @@ call0_track_op (xtensa_c0reg_t dst[], xt
       because they begin with default assumptions that analysis may change.  */
 
 static CORE_ADDR
-call0_analyze_prologue (CORE_ADDR start, CORE_ADDR pc,
-			int nregs, xtensa_c0reg_t rt[], int *call0)
+call0_analyze_prologue (CORE_ADDR start, CORE_ADDR pc, int nregs,
+			xtensa_c0reg_t rt[], int *call0,
+			struct gdbarch *gdbarch)
 {
   CORE_ADDR ia;		    /* Current insn address in prologue.  */
   CORE_ADDR ba = 0;	    /* Current address at base of insn buffer.  */
@@ -2285,7 +2286,7 @@ call0_analyze_prologue (CORE_ADDR start,
 	    }
 
 	  /* Track register movement and modification for this operation.  */
-	  call0_track_op (rt, rtmp, opclass, nods, odv, ia, 1);
+	  call0_track_op (rt, rtmp, opclass, nods, odv, ia, 1, gdbarch);
 	}
     }
 done:
@@ -2315,7 +2316,7 @@ call0_frame_cache (struct frame_info *th
     {
       body_pc = call0_analyze_prologue (start_pc, pc, C0_NREGS,
 					&cache->c0.c0_rt[0],
-					&cache->call0);
+					&cache->call0, gdbarch);
     }
   
   sp = get_frame_register_unsigned
@@ -2487,7 +2488,7 @@ xtensa_skip_prologue (struct gdbarch *gd
     }
 
   /* No debug line info.  Analyze prologue for Call0 or simply skip ENTRY.  */
-  body_pc = call0_analyze_prologue(start_pc, 0, 0, NULL, NULL);
+  body_pc = call0_analyze_prologue(start_pc, 0, 0, NULL, NULL, gdbarch);
   return body_pc != 0 ? body_pc : start_pc;
 }
 

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

* Re: [patch] Get rid of current_gdbarch in xtensa
  2008-05-19 15:17 [patch] Get rid of current_gdbarch in xtensa Markus Deuling
@ 2008-05-20 18:08 ` Ulrich Weigand
  2008-05-20 22:15   ` Maxim Grigoriev
  2008-05-21 22:27   ` [commit] " Maxim Grigoriev
  0 siblings, 2 replies; 6+ messages in thread
From: Ulrich Weigand @ 2008-05-20 18:08 UTC (permalink / raw)
  To: Markus Deuling, maxim2405; +Cc: GDB Patches

Markus Deuling wrote:

> @@ -2034,9 +2034,9 @@ call0_track_op (xtensa_c0reg_t dst[], xt
>        /* 2 operands: dst, literal offset.  */
>        gdb_assert (nods == 2);
>        /* litbase = xtensa_get_litbase (pc); can be also used.  */
> -      litbase = (gdbarch_tdep (current_gdbarch)->litbase_regnum == -1)
> +      litbase = (gdbarch_tdep (gdbarch)->litbase_regnum == -1)
>  	? 0 : xtensa_read_register
> -		(gdbarch_tdep (current_gdbarch)->litbase_regnum);
> +		(gdbarch_tdep (gdbarch)->litbase_regnum);

There's really a different problem here: xtensa_read_register simply
uses get_current_regcache () to retrieve that "litbase" register.

This seems quite broken, in particular when call0_track_op is called
out of the xtensa_skip_prologue code path, where the current regcache
may not really be related at all to the function that is being
queried ...

In those cases where we have a proper frame to read from, the question
of how to retrieve the litbase register number should resolve itself
automatically.

Maxim, do you have any suggestions how to handle this?  Is there a
way to retrieve the "litbase" in the xtensa_skip_prologue case?

Bye,
Ulrich

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


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

* Re: [patch] Get rid of current_gdbarch in xtensa
  2008-05-20 18:08 ` Ulrich Weigand
@ 2008-05-20 22:15   ` Maxim Grigoriev
  2008-05-20 22:23     ` Ulrich Weigand
  2008-05-21 22:27   ` [commit] " Maxim Grigoriev
  1 sibling, 1 reply; 6+ messages in thread
From: Maxim Grigoriev @ 2008-05-20 22:15 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Markus Deuling, GDB Patches

Hello Ulrich and Markus,

Thanks for taking care of Xtensa.

I think xtensa_read_register() should be eliminated.
If you don't mind I can take the original Markus's patch
from here and finish and test it.

Thanks,
-- Maxim


Ulrich Weigand wrote:
> Markus Deuling wrote:
>
>   
>> @@ -2034,9 +2034,9 @@ call0_track_op (xtensa_c0reg_t dst[], xt
>>        /* 2 operands: dst, literal offset.  */
>>        gdb_assert (nods == 2);
>>        /* litbase = xtensa_get_litbase (pc); can be also used.  */
>> -      litbase = (gdbarch_tdep (current_gdbarch)->litbase_regnum == -1)
>> +      litbase = (gdbarch_tdep (gdbarch)->litbase_regnum == -1)
>>  	? 0 : xtensa_read_register
>> -		(gdbarch_tdep (current_gdbarch)->litbase_regnum);
>> +		(gdbarch_tdep (gdbarch)->litbase_regnum);
>>     
>
> There's really a different problem here: xtensa_read_register simply
> uses get_current_regcache () to retrieve that "litbase" register.
>
> This seems quite broken, in particular when call0_track_op is called
> out of the xtensa_skip_prologue code path, where the current regcache
> may not really be related at all to the function that is being
> queried ...
>
> In those cases where we have a proper frame to read from, the question
> of how to retrieve the litbase register number should resolve itself
> automatically.
>
> Maxim, do you have any suggestions how to handle this?  Is there a
> way to retrieve the "litbase" in the xtensa_skip_prologue case?
>
> Bye,
> Ulrich
>
>   


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

* Re: [patch] Get rid of current_gdbarch in xtensa
  2008-05-20 22:15   ` Maxim Grigoriev
@ 2008-05-20 22:23     ` Ulrich Weigand
  0 siblings, 0 replies; 6+ messages in thread
From: Ulrich Weigand @ 2008-05-20 22:23 UTC (permalink / raw)
  To: Maxim Grigoriev; +Cc: Markus Deuling, GDB Patches

Hello Maxim,

> I think xtensa_read_register() should be eliminated.
> If you don't mind I can take the original Markus's patch
> from here and finish and test it.

Certainly, thanks for taking care of this!

Bye,
Ulrich

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


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

* [commit] Get rid of current_gdbarch in xtensa
  2008-05-20 18:08 ` Ulrich Weigand
  2008-05-20 22:15   ` Maxim Grigoriev
@ 2008-05-21 22:27   ` Maxim Grigoriev
  2008-05-23 14:44     ` Markus Deuling
  1 sibling, 1 reply; 6+ messages in thread
From: Maxim Grigoriev @ 2008-05-21 22:27 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Markus Deuling, GDB Patches

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

Getting rid of current_gdbarch and current_regcache in xtensa-tdep.c
Patch provided by Markus was updated according to suggestion from Ulrich.



[-- Attachment #2: Markus_Maxim.diff --]
[-- Type: text/x-patch, Size: 5810 bytes --]

2008-05-21 Markus Deuling  <deuling@de.ibm.com>
	   Maxim Grigoriev  <maxim2405@gmail.com>

	* xtensa-tdep.c (xtensa_read_register): Remove.
	(xtensa_frame_cache): Get rid of xtensa_read_register. Pass extra
	argument litbase to call0_frame_cache().
	(call0_track_op, call0_analyze_prologue)
	(call0_frame_cache): Use extra argument litbase.

Index: gdb/xtensa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/xtensa-tdep.c,v
retrieving revision 1.26
diff -u -r1.26 xtensa-tdep.c
--- gdb/xtensa-tdep.c	16 May 2008 00:27:23 -0000	1.26
+++ gdb/xtensa-tdep.c	21 May 2008 18:10:54 -0000
@@ -211,15 +211,6 @@
   return 0;
 }
 
-static unsigned long
-xtensa_read_register (int regnum)
-{
-  ULONGEST value;
-
-  regcache_raw_read_unsigned (get_current_regcache (), regnum, &value);
-  return (unsigned long) value;
-}
-
 /* Return the type of a register.  Create a new type, if necessary.  */
 
 static struct ctype_cache
@@ -959,7 +950,7 @@
   CORE_ADDR base;	/* Stack pointer of this frame.  */
   CORE_ADDR pc;		/* PC at the entry point to the function.  */
   CORE_ADDR ra;		/* The raw return address (without CALLINC).  */
-  CORE_ADDR ps;		/* The PS register of the previous frame.  */
+  CORE_ADDR ps;		/* The PS register of this frame.  */
   CORE_ADDR prev_sp;	/* Stack Pointer of the previous frame.  */
   int call0;		/* It's a call0 framework (else windowed).  */
   union
@@ -1178,7 +1169,7 @@
 static void
 call0_frame_cache (struct frame_info *this_frame,
 		   xtensa_frame_cache_t *cache,
-		   CORE_ADDR pc);
+		   CORE_ADDR pc, CORE_ADDR litbase);
 
 static struct xtensa_frame_cache *
 xtensa_frame_cache (struct frame_info *this_frame, void **this_cache)
@@ -1186,7 +1177,6 @@
   xtensa_frame_cache_t *cache;
   CORE_ADDR ra, wb, ws, pc, sp, ps;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  unsigned int ps_regnum = gdbarch_ps_regnum (gdbarch);
   unsigned int fp_regnum;
   char op1;
   int  windowed;
@@ -1194,14 +1184,14 @@
   if (*this_cache)
     return *this_cache;
 
-  windowed = windowing_enabled (xtensa_read_register (ps_regnum));
+  ps = get_frame_register_unsigned (this_frame, gdbarch_ps_regnum (gdbarch));
+  windowed = windowing_enabled (ps);
 
   /* Get pristine xtensa-frame.  */
   cache = xtensa_alloc_frame_cache (windowed);
   *this_cache = cache;
 
-  pc = get_frame_register_unsigned (this_frame,
-				    gdbarch_pc_regnum (gdbarch));
+  pc = get_frame_register_unsigned (this_frame, gdbarch_pc_regnum (gdbarch));
 
   if (windowed)
     {
@@ -1210,7 +1200,6 @@
 					gdbarch_tdep (gdbarch)->wb_regnum);
       ws = get_frame_register_unsigned (this_frame,
 					gdbarch_tdep (gdbarch)->ws_regnum);
-      ps = get_frame_register_unsigned (this_frame, ps_regnum);
 
       op1 = read_memory_integer (pc, 1);
       if (XTENSA_IS_ENTRY (gdbarch, op1))
@@ -1303,13 +1292,17 @@
 			     (gdbarch, gdbarch_tdep (gdbarch)->a0_base + 1,
 			      cache->wd.wb);
 
-	      cache->prev_sp = xtensa_read_register (regnum);
+	      cache->prev_sp = get_frame_register_unsigned (this_frame, regnum);
 	    }
 	}
     }
   else	/* Call0 framework.  */
     {
-      call0_frame_cache (this_frame, cache, pc);
+      unsigned int litbase_regnum = gdbarch_tdep (gdbarch)->litbase_regnum;
+      CORE_ADDR litbase = (litbase_regnum == -1)
+	? 0 : get_frame_register_unsigned (this_frame, litbase_regnum);
+
+      call0_frame_cache (this_frame, cache, pc, litbase);
       fp_regnum = cache->c0.fp_regnum;
     }
 
@@ -1981,9 +1974,9 @@
 static void
 call0_track_op (xtensa_c0reg_t dst[], xtensa_c0reg_t src[],
 		xtensa_insn_kind opclass, int nods, unsigned odv[],
-		CORE_ADDR pc, int spreg)
+		CORE_ADDR pc, CORE_ADDR litbase, int spreg)
 {
-  unsigned litbase, litaddr, litval;
+  unsigned litaddr, litval;
 
   switch (opclass)
     {
@@ -2033,10 +2026,6 @@
     case c0opc_l32r:
       /* 2 operands: dst, literal offset.  */
       gdb_assert (nods == 2);
-      /* litbase = xtensa_get_litbase (pc); can be also used.  */
-      litbase = (gdbarch_tdep (current_gdbarch)->litbase_regnum == -1)
-	? 0 : xtensa_read_register
-		(gdbarch_tdep (current_gdbarch)->litbase_regnum);
       litaddr = litbase & 1
 		  ? (litbase & ~1) + (signed)odv[1]
 		  : (pc + 3  + (signed)odv[1]) & ~3;
@@ -2093,7 +2082,7 @@
       because they begin with default assumptions that analysis may change.  */
 
 static CORE_ADDR
-call0_analyze_prologue (CORE_ADDR start, CORE_ADDR pc,
+call0_analyze_prologue (CORE_ADDR start, CORE_ADDR pc, CORE_ADDR litbase,
 			int nregs, xtensa_c0reg_t rt[], int *call0)
 {
   CORE_ADDR ia;		    /* Current insn address in prologue.  */
@@ -2285,7 +2274,7 @@
 	    }
 
 	  /* Track register movement and modification for this operation.  */
-	  call0_track_op (rt, rtmp, opclass, nods, odv, ia, 1);
+	  call0_track_op (rt, rtmp, opclass, nods, odv, ia, litbase, 1);
 	}
     }
 done:
@@ -2300,7 +2289,7 @@
 
 static void
 call0_frame_cache (struct frame_info *this_frame,
-		   xtensa_frame_cache_t *cache, CORE_ADDR pc)
+		   xtensa_frame_cache_t *cache, CORE_ADDR pc, CORE_ADDR litbase)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   CORE_ADDR start_pc;		/* The beginning of the function.  */
@@ -2313,7 +2302,7 @@
 
   if (find_pc_partial_function (pc, NULL, &start_pc, NULL))
     {
-      body_pc = call0_analyze_prologue (start_pc, pc, C0_NREGS,
+      body_pc = call0_analyze_prologue (start_pc, pc, litbase, C0_NREGS,
 					&cache->c0.c0_rt[0],
 					&cache->call0);
     }
@@ -2487,7 +2476,7 @@
     }
 
   /* No debug line info.  Analyze prologue for Call0 or simply skip ENTRY.  */
-  body_pc = call0_analyze_prologue(start_pc, 0, 0, NULL, NULL);
+  body_pc = call0_analyze_prologue(start_pc, 0, 0, 0, NULL, NULL);
   return body_pc != 0 ? body_pc : start_pc;
 }
 

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

* Re: [commit] Get rid of current_gdbarch in xtensa
  2008-05-21 22:27   ` [commit] " Maxim Grigoriev
@ 2008-05-23 14:44     ` Markus Deuling
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Deuling @ 2008-05-23 14:44 UTC (permalink / raw)
  To: Maxim Grigoriev; +Cc: Ulrich Weigand, GDB Patches

Maxim Grigoriev schrieb:
> Getting rid of current_gdbarch and current_regcache in xtensa-tdep.c
> Patch provided by Markus was updated according to suggestion from Ulrich.

Thank you very much, Maxim !

Regards,
Markus

-- 
  Markus Deuling
  GNU Toolchain for Linux on Cell BE
  deuling@de.ibm.com


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

end of thread, other threads:[~2008-05-23  3:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-19 15:17 [patch] Get rid of current_gdbarch in xtensa Markus Deuling
2008-05-20 18:08 ` Ulrich Weigand
2008-05-20 22:15   ` Maxim Grigoriev
2008-05-20 22:23     ` Ulrich Weigand
2008-05-21 22:27   ` [commit] " Maxim Grigoriev
2008-05-23 14:44     ` Markus Deuling

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