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]

Re: [patch] Take varobj_update() updates into account


On Fri, 30 Mar 2007, Maciej W. Rozycki wrote:

>  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.

 Here is a new version that takes recent changes to varobj.c into account 
and also adds a missing update of dependencies.

gdb/gdbtk/:
2007-04-17  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.

gdb/:
2007-04-17  Maciej W. Rozycki  <macro@mips.com>

	* Makefile.in (gdbtk-wrapper.o): Update dependencies.
	(gdbtk-varobj.o, gdbtk-cmds.o, gdbtk-stack.o): 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-04-17 18:39:26.000000000 +0100
+++ binutils-quilt/src/gdb/gdbtk/generic/gdbtk-varobj.c	2007-04-17 18:40:59.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, 1, &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-04-17 18:39:26.000000000 +0100
+++ binutils-quilt/src/gdb/gdbtk/generic/gdbtk-wrapper.c	2007-04-17 18:47:18.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,10 @@
 
 gdb_result GDB_get_current_frame (struct frame_info **result);
 
+gdb_result GDB_varobj_update (struct varobj **varp,
+			      struct varobj ***changelist, int explicit,
+			      int *result);
+
 /*
  * Private functions for this file
  */
@@ -126,6 +131,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 +728,33 @@
   return 1;
 }
 
+gdb_result
+GDB_varobj_update (struct varobj **varp, struct varobj ***changelist,
+		   int explicit, int *result)
+{
+  struct gdb_wrapper_arguments args;
+  gdb_result r;
+
+  args.args[0] = (char *) varp;
+  args.args[1] = (char *) changelist;
+  args.args[2] = (char *) explicit;
+
+  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];
+  int explicit = (int) (*args)->args[2];
+
+  (*args)->result = (char *) varobj_update (varp, changelist, explicit);
+  return 1;
+}
Index: binutils-quilt/src/gdb/gdbtk/generic/gdbtk-wrapper.h
===================================================================
--- binutils-quilt.orig/src/gdb/gdbtk/generic/gdbtk-wrapper.h	2007-04-17 18:39:26.000000000 +0100
+++ binutils-quilt/src/gdb/gdbtk/generic/gdbtk-wrapper.h	2007-04-17 18:41:36.000000000 +0100
@@ -80,5 +80,8 @@
 					   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 explicit,
+				     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-04-17 18:39:26.000000000 +0100
+++ binutils-quilt/src/gdb/gdbtk/generic/gdbtk-stack.c	2007-04-17 18:39:38.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-04-17 18:39:26.000000000 +0100
+++ binutils-quilt/src/gdb/gdbtk/generic/gdbtk-cmds.c	2007-04-17 18:39:38.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: binutils-quilt/src/gdb/Makefile.in
===================================================================
--- binutils-quilt.orig/src/gdb/Makefile.in	2007-04-17 18:39:36.000000000 +0100
+++ binutils-quilt/src/gdb/Makefile.in	2007-04-17 18:39:38.000000000 +0100
@@ -2972,7 +2972,7 @@
 	$(defs_h) $(inferior_h)	$(source_h) $(symfile_h) $(objfiles_h) \
 	$(gdbcore_h) $(demangle_h) $(linespec_h) $(tui_file_h) $(top_h) \
 	$(annotate_h) $(block_h) $(dictionary_h) $(gdb_string_h) \
-	$(dis_asm_h) $(gdbcmd_h)
+	$(dis_asm_h) $(gdbcmd_h) $(varobj_h)
 	$(CC) -c $(INTERNAL_CFLAGS) $(IDE_CFLAGS) $(ITCL_CFLAGS)	\
 	 $(TCL_CFLAGS) $(TK_CFLAGS) $(X11_CFLAGS)		\
 	$(GDBTK_CFLAGS) $(srcdir)/gdbtk/generic/gdbtk-cmds.c		\
@@ -3014,7 +3014,7 @@
 	$(srcdir)/gdbtk/generic/gdbtk.h $(srcdir)/gdbtk/generic/gdbtk-cmds.h \
 	$(srcdir)/gdbtk/generic/gdbtk-wrapper.h \
 	$(defs_h) $(target_h) $(breakpoint_h) $(linespec_h) \
-	$(block_h) $(dictionary_h)
+	$(block_h) $(dictionary_h) $(varobj_h)
 	$(CC) -c $(INTERNAL_CFLAGS) $(IDE_CFLAGS) $(ITCL_CFLAGS) \
 	 $(TCL_CFLAGS) $(TK_CFLAGS) $(X11_CFLAGS)   \
 	$(GDBTK_CFLAGS) $(srcdir)/gdbtk/generic/gdbtk-stack.c \
@@ -3022,6 +3022,7 @@
 
 gdbtk-varobj.o: $(srcdir)/gdbtk/generic/gdbtk-varobj.c \
 		$(srcdir)/gdbtk/generic/gdbtk.h \
+		$(srcdir)/gdbtk/generic/gdbtk-wrapper.h \
 		$(defs_h) $(value_h) $(varobj_h) $(gdb_string_h)
 	$(CC) -c $(INTERNAL_CFLAGS) $(IDE_CFLAGS) $(ITCL_CFLAGS)  \
 	$(TCL_CFLAGS) $(TK_CFLAGS) $(X11_CFLAGS) $(GDBTK_CFLAGS)\
@@ -3029,7 +3030,7 @@
 
 gdbtk-wrapper.o: $(srcdir)/gdbtk/generic/gdbtk-wrapper.c \
 	$(srcdir)/gdbtk/generic/gdbtk-wrapper.h \
-	$(defs_h) $(frame_h) $(value_h)
+	$(defs_h) $(frame_h) $(value_h) $(varobj_h)
 	$(CC) -c $(INTERNAL_CFLAGS) $(IDE_CFLAGS) $(GDBTK_CFLAGS)\
 		$(srcdir)/gdbtk/generic/gdbtk-wrapper.c
 


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