This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Set register even when no frame exists


Hello,


We have recently run into a problem with an ARM board debugging via a jtag emulator (bdi2000). The problem looks very much like what was discussed in "GDB and ARM Frame Pointer strangeness" (http://sources.redhat.com/ml/gdb/2004-06/msg00040.html)


What is happening in our case is this:

gdb connects to bdi2000 (target remote ...) then reset command is issued via bdi2000 (monitor reset...) the target is reset. (and stopped). bdi2000 via init sequence initializes on-board hardware.

After that, gdb loads image into device memory.

However, when gdb now tries to set PC to the start instruction of the loaded image, GDB fails with:

"Value being assigned to is no longer active"

and gives up trying to write the register.


Note that at this point the target is barely initialized; stack pointer register (GPR 11) has random value which makes frame_find_by_id to fail.


Simple solution (see the patch attached) is to call "get_current_frame" which will effectively create a sentinel frame.To me having only sentinel frame at this point in game makes a lot of sense.


Thanks,


Aleksandar Ristovski
QNX Software Systems



2008-09-26 Aleksandar Ristovski <aristovski@qnx.com>

	* valops.c (value_assign): Get current frame if frame_find_by_id
	fails.

Index: gdb/valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.200
diff -u -p -r1.200 valops.c
--- gdb/valops.c	11 Sep 2008 14:27:34 -0000	1.200
+++ gdb/valops.c	26 Sep 2008 17:32:56 -0000
@@ -839,6 +839,12 @@ value_assign (struct value *toval, struc
 	/* Figure out which frame this is in currently.  */
 	frame = frame_find_by_id (VALUE_FRAME_ID (toval));
 	value_reg = VALUE_REGNUM (toval);
+	
+	/* Get sentinel frame.  For remote targets that just
+	   booted, there will be no frame to work with.  Use registers
+	   instead (sentinel frame).  */
+	if (!frame)
+	  frame = get_current_frame ();
 
 	if (!frame)
 	  error (_("Value being assigned to is no longer active."));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]