This is the mail archive of the insight@sourceware.org mailing list for the Insight 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] Take varobj_update() updates into account


Hello,

 A recent change has made varobj_update() throw an error if a call is made 
for a non-root variable.  This means a wrapper is now needed for the 
function when called from insight.

 The following change implements the wrapper and fixes a hang that happens 
in gdb.gdbtk/c_variable.exp for c_variable-5.1 -- all the update tests 
succeed for me now:

PASS c_variable-5.1 {check that nothing changed} {}
PASS c_variable-5.2 {check that integer changed} {}
PASS c_variable-5.3 {check that char_ptr changed} {}
PASS c_variable-5.4 {check that int_ptr_ptr and children changed} {}
PASS c_variable-5.5 {check that long_array[0] changed} {}
PASS c_variable-5.6 {check that long_array[1] changed} {}
PASS c_variable-5.7 {check that long_array[2] changed} {}
PASS c_variable-5.8 {check that long_array[3-9] changed} {}
PASS c_variable-5.9 {check that func_ptr changed} {}

I have a feeling some more work may be needed to handle the case where a 
variable has changed its type, but this change should be a step in the 
right direction.

 This change has been tested for mipsisa32-sde-elf, using 
mips-sim-sde32/-EB and mips-sim-sde32/-EL as the targets, removing the 
hang for both.

2007-03-30  Maciej W. Rozycki  <macro@mips.com>

	* generic/gdbtk-wrapper.c (GDB_varobj_update): New function.
	(wrap_varobj_update): Likewise.
	* generic/gdbtk-wrapper.h (GDB_varobj_update): New declaration.
	* generic/gdbtk-varobj.c (variable_update): Call
	GDB_varobj_update() rather than varobj_update() directly.  Take
	the new semantics of the latter into account.
	* generic/gdbtk-cmds.c: Include "varobj.h".
	* generic/gdbtk-stack.c: Likewise.

 OK to apply?

  Maciej

gdbtk-varobj_update.diff
Index: binutils-quilt/src/gdb/gdbtk/generic/gdbtk-varobj.c
===================================================================
--- binutils-quilt.orig/src/gdb/gdbtk/generic/gdbtk-varobj.c	2007-03-29 19:01:25.000000000 +0100
+++ binutils-quilt/src/gdb/gdbtk/generic/gdbtk-varobj.c	2007-03-29 19:28:14.000000000 +0100
@@ -26,6 +26,7 @@
 #include <tcl.h>
 #include "gdbtk.h"
 #include "gdbtk-cmds.h"
+#include "gdbtk-wrapper.h"
 
 /*
  * Public functions defined in this file
@@ -444,10 +445,12 @@
   Tcl_Obj *changed;
   struct varobj **changelist;
   struct varobj **vc;
+  int result;
 
-  /* varobj_update() can return -1 if the variable is no longer around,
-     i.e. we stepped out of the frame in which a local existed. */
-  if (varobj_update (var, &changelist) == -1)
+  /* varobj_update() throws an error for a non-root variable
+     and otherwise it returns a value < 0 if the variable is
+     not in scope, not valid anymore or has changed type.  */
+  if (GDB_varobj_update (var, &changelist, &result) != GDB_OK || result < 0)
     return Tcl_NewStringObj ("-1", -1);
 
   changed = Tcl_NewListObj (0, NULL);  
Index: binutils-quilt/src/gdb/gdbtk/generic/gdbtk-wrapper.c
===================================================================
--- binutils-quilt.orig/src/gdb/gdbtk/generic/gdbtk-wrapper.c	2007-03-29 19:01:25.000000000 +0100
+++ binutils-quilt/src/gdb/gdbtk/generic/gdbtk-wrapper.c	2007-03-29 19:28:14.000000000 +0100
@@ -21,6 +21,7 @@
 #include "defs.h"
 #include "frame.h"
 #include "value.h"
+#include "varobj.h"
 #include "block.h"
 #include "exceptions.h"
 #include "gdbtk-wrapper.h"
@@ -81,6 +82,9 @@
 
 gdb_result GDB_get_current_frame (struct frame_info **result);
 
+gdb_result GDB_varobj_update (struct varobj **varp,
+			      struct varobj ***changelist, int *result);
+
 /*
  * Private functions for this file
  */
@@ -126,6 +130,8 @@
 static int wrap_find_relative_frame (char *opaque_arg);
 
 static int wrap_get_current_frame (char *opaque_arg);
+
+static int wrap_varobj_update (char *opaque_arg);
 
 static gdb_result
 call_wrapped_function (catch_errors_ftype *fn, struct gdb_wrapper_arguments *arg)
@@ -721,3 +727,31 @@
   return 1;
 }
 
+gdb_result
+GDB_varobj_update (struct varobj **varp, struct varobj ***changelist,
+		   int *result)
+{
+  struct gdb_wrapper_arguments args;
+  gdb_result r;
+
+  args.args[0] = (char *) varp;
+  args.args[1] = (char *) changelist;
+
+  r = call_wrapped_function ((catch_errors_ftype *) wrap_varobj_update, &args);
+  if (r != GDB_OK)
+    return r;
+
+  *result = (int) args.result;
+  return GDB_OK;
+}
+
+static int wrap_varobj_update (char *opaque_arg)
+{
+  struct gdb_wrapper_arguments **args
+    = (struct gdb_wrapper_arguments **) opaque_arg;
+  struct varobj **varp = (struct varobj **) (*args)->args[0];
+  struct varobj ***changelist = (struct varobj ***) (*args)->args[1];
+
+  (*args)->result = (char *) varobj_update (varp, changelist);
+  return 1;
+}
Index: binutils-quilt/src/gdb/gdbtk/generic/gdbtk-wrapper.h
===================================================================
--- binutils-quilt.orig/src/gdb/gdbtk/generic/gdbtk-wrapper.h	2007-03-29 19:01:25.000000000 +0100
+++ binutils-quilt/src/gdb/gdbtk/generic/gdbtk-wrapper.h	2007-03-29 19:28:14.000000000 +0100
@@ -80,5 +80,7 @@
 					   int *start,
 					   struct frame_info **result);
 extern gdb_result GDB_get_current_frame (struct frame_info **result);
+extern gdb_result GDB_varobj_update (struct varobj **varp,
+				     struct varobj ***changelist, int *result);
 #endif /* GDBTK_WRAPPER_H */
 
Index: binutils-quilt/src/gdb/gdbtk/generic/gdbtk-stack.c
===================================================================
--- binutils-quilt.orig/src/gdb/gdbtk/generic/gdbtk-stack.c	2007-03-29 19:01:25.000000000 +0100
+++ binutils-quilt/src/gdb/gdbtk/generic/gdbtk-stack.c	2007-03-29 19:28:14.000000000 +0100
@@ -24,6 +24,7 @@
 #include "linespec.h"
 #include "block.h"
 #include "dictionary.h"
+#include "varobj.h"
 
 #include <tcl.h>
 #include "gdbtk.h"
Index: binutils-quilt/src/gdb/gdbtk/generic/gdbtk-cmds.c
===================================================================
--- binutils-quilt.orig/src/gdb/gdbtk/generic/gdbtk-cmds.c	2007-03-29 19:01:24.000000000 +0100
+++ binutils-quilt/src/gdb/gdbtk/generic/gdbtk-cmds.c	2007-03-29 19:28:46.000000000 +0100
@@ -39,6 +39,7 @@
 #include "filenames.h"
 #include "disasm.h"
 #include "value.h"
+#include "varobj.h"
 #include "exceptions.h"
 
 /* tcl header files includes varargs.h unless HAS_STDARG is defined,


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