public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-python: Merge branch 'archer-tromey-python' of ssh://sourceware.org/git/archer into archer-tromey-python
@ 2009-08-06 20:48 tromey
  0 siblings, 0 replies; 3+ messages in thread
From: tromey @ 2009-08-06 20:48 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-python has been updated
       via  41a25760d8148fac6e1d0ad738faf8b1649c520b (commit)
       via  0e624ee7e08835ceef907e9b455b955945765231 (commit)
      from  74200760800432ef70cb3a703f764ac628247a2d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 41a25760d8148fac6e1d0ad738faf8b1649c520b
Merge: 0e624ee7e08835ceef907e9b455b955945765231 74200760800432ef70cb3a703f764ac628247a2d
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu Aug 6 14:47:23 2009 -0600

    Merge branch 'archer-tromey-python' of ssh://sourceware.org/git/archer into archer-tromey-python

commit 0e624ee7e08835ceef907e9b455b955945765231
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu Aug 6 14:44:36 2009 -0600

    Reimplement python varobj code to conform to new spec
    
    gdb
    	* varobj.h (varobj_update_result_t) <new>: New field.
    	(varobj_get_child_range): Update.
    	(varobj_list_children): Update.  Rewrite documentation.
    	(varobj_has_more): Declare.
    	* varobj.c (struct varobj) <child_iter, saved_item>: New fields.
    	(varobj_has_more): New function.
    	(restrict_range, install_dynamic_child): Likewise.
    	(update_dynamic_varobj_children): Change 'new_and_unchanged' to
    	'new'.  Add 'update_children' and 'to' arguments.  Fix logic to
    	conform to new spec.
    	(varobj_get_num_children): Don't call
    	update_dynamic_varobj_children.
    	(varobj_list_children): Add from, to arguments.  Restrict result
    	range.
    	(install_visualizer): Clear child_iter field.
    	(varobj_get_child_range): Remove 'children' argument.  Rewrite.
    	(varobj_update): Set 'new' field on result object.  Fix logic to
    	conform to new spec.
    	(new_variable): Initialize new fields.
    	(free_variable): Destroy new fields.
    	(value_of_root): Copy from and to fields.
    	* mi/mi-cmds.h (mi_cmd_var_set_update_range): Declare.
    	* mi/mi-cmds.c (mi_cmds): Add var-set-update-range.
    	* mi/mi-cmd-var.c (mi_cmd_var_list_children): Don't set child
    	range.  Use varobj_has_more.
    	(varobj_update_one): Emit new_num_children when the children
    	changed.  Use varobj_has_more.  Emit the new_children list.
    	(mi_cmd_var_set_update_range): New function.
    gdb/doc
    	* gdb.texinfo (GDB/MI Variable Objects): Document
    	-var-set-update-range.
    gdb/testsuite
    	* lib/mi-support.exp (mi_create_floating_varobj): Update.
    	(mi_varobj_update_kv_helper): New proc.
    	(mi_varobj_update_dynamic_helper): Likewise.
    	(mi_varobj_update_dynamic): Rewrite.
    	* gdb.python/python-prettyprint.c (main): Update container in "MI"
    	mode.
    	* gdb.python/python-mi.exp: Update.

-----------------------------------------------------------------------

Summary of changes:
 gdb/doc/gdb.texinfo                           |   39 +++-
 gdb/mi/mi-cmd-var.c                           |   71 ++++---
 gdb/mi/mi-cmds.c                              |    1 +
 gdb/mi/mi-cmds.h                              |    1 +
 gdb/testsuite/gdb.python/python-mi.exp        |   75 +++++--
 gdb/testsuite/gdb.python/python-prettyprint.c |    3 +
 gdb/testsuite/lib/mi-support.exp              |   66 +++++-
 gdb/varobj.c                                  |  298 ++++++++++++++++---------
 gdb/varobj.h                                  |   25 ++-
 9 files changed, 413 insertions(+), 166 deletions(-)

First 500 lines of diff:
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 2b8fcc7..fd7c9ab 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -23663,6 +23663,8 @@ access this functionality:
 @tab update the variable and its children
 @item @code{-var-set-frozen}
 @tab set frozeness attribute
+@item @code{-var-set-update-range}
+@tab set range of children to display on update
 @end multitable
 
 In the next subsection we describe each operation in detail and suggest
@@ -23836,9 +23838,7 @@ and unions.
 to report.  If @var{from} or @var{to} is less than zero, the range is
 reset and all children will be reported.  Otherwise, children starting
 at @var{from} (zero-based) and ending just before @var{to} will be
-reported.  The selected range is sticky; future calls to
-@code{-var-update} or @code{-var-list-children} will use any
-previously set range.
+reported.
 
 For each child the following results are returned:
 
@@ -23871,7 +23871,11 @@ Otherwise this result is not present.
 
 @item frozen
 If the variable object is frozen, this variable will be present with a value of 1.
+@end table
+
+The result may have its own attributes:
 
+@table @var
 @item has_more
 This is an integer attribute which is nonzero if there are children
 remaining after the end of the selected range.
@@ -24058,6 +24062,9 @@ With the @samp{*} parameter, if a variable object is bound to a
 currently running thread, it will not be updated, without any
 diagnostic.
 
+If @code{-var-set-update-range} was previously used on a varobj, then
+only the selected range of children will be reported.
+
 @subsubheading Example
 
 @smallexample
@@ -24125,6 +24132,32 @@ Unfreezing a variable does not update it, only subsequent
 (gdb)
 @end smallexample
 
+@subheading The @code{-var-set-update-range} command
+@findex -var-set-update-range
+@anchor{-var-set-update-range}
+
+@subsubheading Synopsis
+
+@smallexample
+ -var-set-update-range @var{name} @var{from} @var{to}
+@end smallexample
+
+Set the range of children to be returned by future invocations of
+@code{-var-update}.
+
+@var{from} and @var{to} indicate the range of children to report.  If
+@var{from} or @var{to} is less than zero, the range is reset and all
+children will be reported.  Otherwise, children starting at @var{from}
+(zero-based) and ending just before @var{to} will be reported.
+
+@subsubheading Example
+
+@smallexample
+(gdb)
+-var-set-update-range V 1 2
+^done
+@end smallexample
+
 @subheading The @code{-var-set-visualizer} command
 @findex -var-set-visualizer
 @anchor{-var-set-visualizer}
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index 82f7220..e5f237d 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -388,20 +388,20 @@ mi_cmd_var_list_children (char *command, char **argv, int argc)
     {
       from = atoi (argv[argc - 2]);
       to = atoi (argv[argc - 1]);
-      varobj_set_child_range (var, from, to);
+    }
+  else
+    {
+      from = -1;
+      to = -1;
     }
 
-  children = varobj_list_children (var);
+  children = varobj_list_children (var, &from, &to);
   ui_out_field_int (uiout, "numchild", VEC_length (varobj_p, children));
   if (argc == 2 || argc == 4)
     print_values = mi_parse_values_option (argv[0]);
   else
     print_values = PRINT_NO_VALUES;
 
-  /* Re-fetch the child range, because varobj_get_child_range computes
-     the real start and end indices for us.  */
-  varobj_get_child_range (var, children, &from, &to);
-
   display_hint = varobj_get_display_hint (var);
   if (display_hint)
     {
@@ -430,8 +430,7 @@ mi_cmd_var_list_children (char *command, char **argv, int argc)
       do_cleanups (cleanup_children);
     }
 
-  ui_out_field_int (uiout, "has_more",
-		    VEC_length (varobj_p, children) > to);
+  ui_out_field_int (uiout, "has_more", varobj_has_more (var, to));
 }
 
 void
@@ -698,11 +697,11 @@ varobj_update_one (struct varobj *var, enum print_values print_values,
 	}
 
       if (r->type_changed)
-	{
-          ui_out_field_string (uiout, "new_type", varobj_get_type (r->varobj));
-          ui_out_field_int (uiout, "new_num_children", 
-			    varobj_get_num_children (r->varobj));
-	}
+	ui_out_field_string (uiout, "new_type", varobj_get_type (r->varobj));
+
+      if (r->type_changed || r->children_changed)
+	ui_out_field_int (uiout, "new_num_children", 
+			  varobj_get_num_children (r->varobj));
 
       display_hint = varobj_get_display_hint (var);
       if (display_hint)
@@ -713,30 +712,32 @@ varobj_update_one (struct varobj *var, enum print_values print_values,
 
       if (r->children_changed)
 	{
-	  int ix, from, to;
-	  struct varobj *child;
-	  struct cleanup *cleanup =
-	    make_cleanup_ui_out_list_begin_end (uiout, "children");
+	  int from, to;
+	  varobj_get_child_range (r->varobj, &from, &to);
+	  ui_out_field_int (uiout, "has_more",
+			    varobj_has_more (r->varobj, to));
+	}
 
-	  VEC (varobj_p)* children = varobj_list_children (r->varobj);
-	  varobj_get_child_range (r->varobj, children, &from, &to);
+      if (r->new)
+	{
+	  int j;
+	  varobj_p child;
+	  struct cleanup *cleanup;
 
-	  for (ix = from;
-	       ix < to && VEC_iterate (varobj_p, children, ix, child);
-	       ++ix)
+	  cleanup = make_cleanup_ui_out_list_begin_end (uiout, "new_children");
+	  for (j = 0; VEC_iterate (varobj_p, r->new, j, child); ++j)
 	    {
 	      struct cleanup *cleanup_child;
 	      cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
-	      print_varobj (child, print_values, 1 /* print expression */);
+	      print_varobj (child, print_values, 1 /* print_expression */);
 	      do_cleanups (cleanup_child);
 	    }
 
 	  do_cleanups (cleanup);
-
-	  ui_out_field_int (uiout, "has_more",
-			    VEC_length (varobj_p, children) > to);
+	  VEC_free (varobj_p, r->new);
+	  r->new = NULL;	/* Paranoia.  */
 	}
-  
+
       if (mi_version (uiout) > 1)
 	do_cleanups (cleanup);
     }
@@ -750,3 +751,19 @@ mi_cmd_enable_pretty_printing (char *command, char **argv, int argc)
     error (_("mi_cmd_enable_pretty_printing: no arguments allowed"));
   varobj_enable_pretty_printing ();
 }
+
+void
+mi_cmd_var_set_update_range (char *command, char **argv, int argc)
+{
+  struct varobj *var;
+  int from, to;
+
+  if (argc != 3)
+    error (_("mi_cmd_var_set_update_range: Usage: VAROBJ FROM TO"));
+  
+  var = varobj_get_handle (argv[0]);
+  from = atoi (argv[1]);
+  to = atoi (argv[2]);
+
+  varobj_set_child_range (var, from, to);
+}
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index 772566e..ef25cba 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -112,6 +112,7 @@ struct mi_cmd mi_cmds[] =
   { "var-list-children", { NULL, 0 }, mi_cmd_var_list_children},
   { "var-set-format", { NULL, 0 }, mi_cmd_var_set_format},
   { "var-set-frozen", { NULL, 0 }, mi_cmd_var_set_frozen},
+  { "var-set-update-range", { NULL, 0 }, mi_cmd_var_set_update_range },
   { "var-set-visualizer", { NULL, 0 }, mi_cmd_var_set_visualizer},
   { "var-show-attributes", { NULL, 0 }, mi_cmd_var_show_attributes},
   { "var-show-format", { NULL, 0 }, mi_cmd_var_show_format},
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index 79798ef..b0d68ed 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -99,6 +99,7 @@ extern mi_cmd_argv_ftype mi_cmd_var_show_attributes;
 extern mi_cmd_argv_ftype mi_cmd_var_show_format;
 extern mi_cmd_argv_ftype mi_cmd_var_update;
 extern mi_cmd_argv_ftype mi_cmd_enable_pretty_printing;
+extern mi_cmd_argv_ftype mi_cmd_var_set_update_range;
 
 /* Description of a single command. */
 
diff --git a/gdb/testsuite/gdb.python/python-mi.exp b/gdb/testsuite/gdb.python/python-mi.exp
index e7bfe54..095ee78 100644
--- a/gdb/testsuite/gdb.python/python-mi.exp
+++ b/gdb/testsuite/gdb.python/python-mi.exp
@@ -69,16 +69,21 @@ mi_list_varobj_children container {
 
 mi_next "next over update 1"
 
-mi_varobj_update_dynamic container {
-    { {container.\[0\]} {\[0\]} 0 int }
-} "varobj update 1"
+mi_varobj_update_dynamic container "varobj update 1" {
+    type_changed false new_num_children 1 has_more 0
+} {
+} {
+    { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 }
+}
 
 mi_next "next over update 2"
 
-mi_varobj_update_dynamic container {
-    { {container.\[0\]} {\[0\]} 0 int }
-    { {container.\[1\]} {\[1\]} 0 int }
-} "varobj update 2"
+mi_varobj_update_dynamic container "varobj update 2" {
+    type_changed false new_num_children 2 has_more 0
+} {
+} {
+    { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 }
+}
 
 mi_gdb_test "-var-set-visualizer container None" \
   "\\^done" \
@@ -92,19 +97,26 @@ mi_gdb_test "-var-set-visualizer container gdb.default_visualizer" \
   "\\^done" \
   "choose default visualizer"
 
-mi_varobj_update_dynamic container {
-    { {container.\[0\]} {\[0\]} 0 int }
-    { {container.\[1\]} {\[1\]} 0 int }
-} "varobj update after choosing default"
+mi_varobj_update_dynamic container "varobj update after choosing default" {
+    type_changed false new_num_children 2 has_more 0
+} {
+} {
+    { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 }
+    { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 }
+}
 
 mi_gdb_test "-var-set-visualizer container ContainerPrinter" \
   "\\^done" \
   "choose visualizer using expression"
 
-mi_varobj_update_dynamic container {
-    { {container.\[0\]} {\[0\]} 0 int }
-    { {container.\[1\]} {\[1\]} 0 int }
-} "varobj update after choosing via expression"
+mi_varobj_update_dynamic container \
+  "varobj update after choosing via expression" {
+      type_changed false new_num_children 2 has_more 0
+  } {
+  } {
+      { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 }
+      { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 }
+  }
 
 mi_list_varobj_children_range container 1 2 2 {
     { {container.\[1\]} {\[1\]} 0 int }
@@ -115,6 +127,39 @@ mi_list_varobj_children_range container -1 -1 2 {
     { {container.\[1\]} {\[1\]} 0 int }
 } "list varobj children after resetting child range"
 
+mi_next "next over update 3"
+
+mi_gdb_test "-var-set-update-range container 0 1" \
+  "\\^done" \
+  "set update range"
+
+# This should truncate the list.
+mi_list_varobj_children container {
+    { {container.\[0\]} {\[0\]} 0 int }
+} "list children after setting update range"
+
+# This should return just the items in [1,2).
+mi_list_varobj_children_range container 1 2 2 {
+    { {container.\[1\]} {\[1\]} 0 int }
+} "list selected children after setting range"
+
+# This should not be affected by the previous list-children request.
+mi_list_varobj_children container {
+    { {container.\[0\]} {\[0\]} 0 int }
+} "list children after listing selected range"
+
+mi_next "next over update 4"
+
+# This should only show the first child, because the update range has
+# been set.
+mi_varobj_update_dynamic container \
+  "update after next with restricted range" {
+      type_changed false new_num_children 1 has_more 1
+  } {
+      { name {container.\[0\]} in_scope true type_changed false }
+  } {
+  }
+
 mi_continue_to_line \
     [gdb_get_line_number {Another MI breakpoint} ${testfile}.c] \
     "step to second breakpoint"
diff --git a/gdb/testsuite/gdb.python/python-prettyprint.c b/gdb/testsuite/gdb.python/python-prettyprint.c
index 5cc35be..6bbbf1d 100644
--- a/gdb/testsuite/gdb.python/python-prettyprint.c
+++ b/gdb/testsuite/gdb.python/python-prettyprint.c
@@ -203,6 +203,9 @@ main ()
   add_item (&c, 72);
 
 #ifdef MI
+  add_item (&c, 1011);
+  c.elements[0] = 1023;
+
   do_nothing ();
 #endif
 
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 33f277a..f6b62e2 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -1200,7 +1200,7 @@ proc mi_create_varobj { name expression testname } {
 
 proc mi_create_floating_varobj { name expression testname } {
     mi_gdb_test "-var-create $name @ $expression" \
-        "\\^done,name=\"$name\",numchild=\"\[0-9\]+\",value=\".*\",type=.*" \
+        "\\^done,name=\"$name\",numchild=\"\(-1\|\[0-9\]+\)\",value=\".*\",type=.*" \
         $testname
 }
 
@@ -1249,16 +1249,64 @@ proc mi_varobj_update_with_type_change { name new_type new_children testname } {
     mi_gdb_test "-var-update $name" $er $testname
 }
 
-# Update a dynamic varobj named NAME.  CHILDREN is a list of children,
-# in the same form as mi_list_varobj_children.  TESTNAME is the name
-# of the test.
-proc mi_varobj_update_dynamic {name children testname} {
-    set children_exp_j [mi_child_regexp $children 0]
+# A helper that turns a key/value list into a regular expression
+# matching some MI output.
+proc mi_varobj_update_kv_helper {list} {
+    set first 1
+    set rx ""
+    foreach {key value} $list {
+	if {!$first} {
+	    append rx ,
+	}
+	set first 0
+	if {$key == "new_children"} {
+	    append rx "$key=\\\[$value\\\]"
+	} else {
+	    append rx "$key=\"$value\""
+	}
+    }
+    return $rx
+}
+
+# A helper for mi_varobj_update_dynamic that computes a match
+# expression given a child list.
+proc mi_varobj_update_dynamic_helper {children} {
+    set crx ""
 
-    set er "\\^done,changelist=\\\["
+    set first 1
+    foreach child $children {
+	if {!$first} {
+	    append crx ,
+	}
+	set first 0
+	append crx "{"
+	append crx [mi_varobj_update_kv_helper $child]
+	append crx "}"
+    }
+
+    return $crx
+}
 
-    append er "{name=\"$name\",in_scope=\"true\",type_changed=\"false\""
-    append er ",children=\\\[$children_exp_j.*\\\],has_more=\".\"}\\\]"
+# Update a dynamic varobj named NAME.  CHILDREN is a list of children
+# that have been updated; NEW_CHILDREN is a list of children that were
+# added to the primary varobj.  Each child is a list of key/value
+# pairs that are expected.  SELF is a key/value list holding
+# information about the varobj itself.  TESTNAME is the name of the
+# test.
+proc mi_varobj_update_dynamic {name testname self children new_children} {
+    if {[llength $new_children]} {
+	set newrx [mi_varobj_update_dynamic_helper $new_children]
+	lappend self new_children $newrx
+    }
+    set selfrx [mi_varobj_update_kv_helper $self]
+    set crx [mi_varobj_update_dynamic_helper $children]
+
+    set er "\\^done,changelist=\\\[\{name=\"$name\",in_scope=\"true\""
+    append er ",$selfrx\}"
+    if {"$crx" != ""} {
+	append er ",$crx"
+    }
+    append er "\\\]"
 
     verbose -log "Expecting: $er"
     mi_gdb_test "-var-update $name" $er $testname
diff --git a/gdb/varobj.c b/gdb/varobj.c
index a3938d0..2a0d317 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -197,6 +197,17 @@ struct varobj
   /* The pretty-printer that has been constructed.  If NULL, then a
      new printer object is needed, and one will be constructed.  */
   PyObject *pretty_printer;
+
+  /* The iterator returned by the printer's 'children' method, or NULL
+     if not available.  */
+  PyObject *child_iter;
+
+  /* We request one extra item from the iterator, so that we can
+     report to the caller whether there are more items than we have
+     already reported.  However, we don't want to install this value
+     when we read it, because that will mess up future updates.  So,
+     we stash it here instead.  */
+  PyObject *saved_item;
 };
 
 struct cpstack
@@ -815,6 +826,17 @@ varobj_get_display_hint (struct varobj *var)
   return result;
 }
 
+/* Return true if the varobj has items after TO, false otherwise.  */
+
+int
+varobj_has_more (struct varobj *var, int to)
+{
+  if (VEC_length (varobj_p, var->children) > to)
+    return 1;
+  return (VEC_length (varobj_p, var->children) == to
+	  && var->saved_item != NULL);
+}
+
 /* If the variable object is bound to a specific thread, that
    is its evaluation can always be done in context of a frame
    inside that thread, returns GDB id of the thread -- which
@@ -847,22 +869,73 @@ varobj_get_frozen (struct varobj *var)
   return var->frozen;
 }
 
+/* A helper function that restricts a range to what is actually
+   available in a VEC.  This follows the usual rules for the meaning
+   of FROM and TO -- if either is negative, the entire range is
+   used.  */
+
+static void
+restrict_range (VEC (varobj_p) *children, int *from, int *to)
+{
+  if (*from < 0 || *to < 0)
+    {
+      *from = 0;
+      *to = VEC_length (varobj_p, children);
+    }
+  else
+    {
+      if (*from > VEC_length (varobj_p, children))
+	*from = VEC_length (varobj_p, children);
+      if (*to > VEC_length (varobj_p, children))
+	*to = VEC_length (varobj_p, children);
+      if (*from > *to)


hooks/post-receive
--
Repository for Project Archer.


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

* [SCM]  archer-tromey-python: Merge branch 'archer-tromey-python' of ssh://sourceware.org/git/archer into archer-tromey-python
@ 2009-09-18 22:39 tromey
  0 siblings, 0 replies; 3+ messages in thread
From: tromey @ 2009-09-18 22:39 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-python has been updated
       via  f471c6694511a867e0bec72ca658c614d20b98f6 (commit)
       via  23c708ccadb968d1c410bc17b204731134b0f65e (commit)
      from  1e582cf2df11843bf1f98d53aac3cb92012c6310 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit f471c6694511a867e0bec72ca658c614d20b98f6
Merge: 23c708ccadb968d1c410bc17b204731134b0f65e 1e582cf2df11843bf1f98d53aac3cb92012c6310
Author: Tom Tromey <tromey@redhat.com>
Date:   Fri Sep 18 16:38:17 2009 -0600

    Merge branch 'archer-tromey-python' of ssh://sourceware.org/git/archer into archer-tromey-python

commit 23c708ccadb968d1c410bc17b204731134b0f65e
Author: Tom Tromey <tromey@redhat.com>
Date:   Fri Sep 18 16:26:49 2009 -0600

    	* python/lib/gdb/FrameWrapper.py: Don't directly reference
    	self.frame.

-----------------------------------------------------------------------

Summary of changes:
 gdb/python/lib/gdb/FrameWrapper.py |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

First 500 lines of diff:
diff --git a/gdb/python/lib/gdb/FrameWrapper.py b/gdb/python/lib/gdb/FrameWrapper.py
index 39f8246..b790a54 100644
--- a/gdb/python/lib/gdb/FrameWrapper.py
+++ b/gdb/python/lib/gdb/FrameWrapper.py
@@ -30,7 +30,7 @@ class FrameWrapper:
 
         stream.write (sym.print_name + "=")
         try:
-            val = self.frame.read_var (sym)
+            val = self.read_var (sym)
             if val != None:
                 val = str (val)
         # FIXME: would be nice to have a more precise exception here.
@@ -75,21 +75,21 @@ class FrameWrapper:
     # FIXME: this should probably just be a method on gdb.Frame.
     # But then we need stream wrappers.
     def describe (self, stream, full):
-        if self.frame.type () == gdb.DUMMY_FRAME:
+        if self.type () == gdb.DUMMY_FRAME:
             stream.write (" <function called from gdb>\n")
-        elif self.frame.type () == gdb.SIGTRAMP_FRAME:
+        elif self.type () == gdb.SIGTRAMP_FRAME:
             stream.write (" <signal handler called>\n")
         else:
-            sal = self.frame.find_sal ()
-            pc = self.frame.pc ()
-            name = self.frame.name ()
+            sal = self.find_sal ()
+            pc = self.pc ()
+            name = self.name ()
             if not name:
                 name = "??"
             if pc != sal.pc or not sal.symtab:
                 stream.write (" 0x%08x in" % pc)
             stream.write (" " + name + " (")
 
-            func = self.frame.function ()
+            func = self.function ()
             self.print_frame_args (stream, func)
 
             stream.write (")")
@@ -98,7 +98,7 @@ class FrameWrapper:
                 stream.write (" at " + sal.symtab.filename)
                 stream.write (":" + str (sal.line))
 
-            if not self.frame.name () or (not sal.symtab or not sal.symtab.filename):
+            if not self.name () or (not sal.symtab or not sal.symtab.filename):
                 lib = gdb.solib_address (pc)
                 if lib:
                     stream.write (" from " + lib)


hooks/post-receive
--
Repository for Project Archer.


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

* [SCM]  archer-tromey-python: Merge branch 'archer-tromey-python' of ssh://sourceware.org/git/archer into archer-tromey-python
@ 2008-11-24 23:06 tromey
  0 siblings, 0 replies; 3+ messages in thread
From: tromey @ 2008-11-24 23:06 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-python has been updated
       via  0823707d573b2ad740132a2b8d5c7c241c814ff1 (commit)
       via  54f9d81017696c2af3b6001db29a107e198e7e69 (commit)
      from  4663986956ad35c466e354f6d1997c15cc145e3c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 0823707d573b2ad740132a2b8d5c7c241c814ff1
Merge: 54f9d81017696c2af3b6001db29a107e198e7e69 4663986956ad35c466e354f6d1997c15cc145e3c
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Nov 24 16:05:32 2008 -0700

    Merge branch 'archer-tromey-python' of ssh://sourceware.org/git/archer into archer-tromey-python

commit 54f9d81017696c2af3b6001db29a107e198e7e69
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Nov 24 16:05:11 2008 -0700

    	* Makefile.in (PY_FILES): Add new file.
    	* python/lib/gdb/command/pahole.py: New file.

-----------------------------------------------------------------------

Summary of changes:
 gdb/ChangeLog                        |    5 ++
 gdb/Makefile.in                      |    9 ++--
 gdb/python/lib/gdb/command/pahole.py |   81 ++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+), 4 deletions(-)
 create mode 100644 gdb/python/lib/gdb/command/pahole.py

First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e90d44d..979ca40 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -15,6 +15,11 @@
 
 2008-11-24  Tom Tromey  <tromey@redhat.com>
 
+	* Makefile.in (PY_FILES): Add new file.
+	* python/lib/gdb/command/pahole.py: New file.
+
+2008-11-24  Tom Tromey  <tromey@redhat.com>
+
 	* python/lib/gdb/libstdcxx/v6/__init__.py: New file.
 	* python/lib/gdb/libstdcxx/__init__.py: New file.
 	* python/lib/gdb/function/__init__.py: New file.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 935748d..4251bdf 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1923,10 +1923,11 @@ python-value.o: $(srcdir)/python/python-value.c
 # Note that we should only install files in the "gdb" module.
 PY_FILES = gdb/FrameIterator.py gdb/command/alias.py \
     gdb/command/backtrace.py gdb/command/require.py \
-    gdb/command/__init__.py gdb/libstdcxx/v6/printers.py \
-    gdb/libstdcxx/v6/__init__.py gdb/libstdcxx/__init__.py \
-    gdb/function/caller_is.py gdb/function/in_scope.py \
-    gdb/function/__init__.py gdb/backtrace.py gdb/__init__.py
+    gdb/command/pahole.py gdb/command/__init__.py \
+    gdb/libstdcxx/v6/printers.py gdb/libstdcxx/v6/__init__.py \
+    gdb/libstdcxx/__init__.py gdb/function/caller_is.py	\
+    gdb/function/in_scope.py gdb/function/__init__.py gdb/backtrace.py \
+    gdb/__init__.py
 
 # Install the Python library.  Python library files go under
 # $(GDB_DATADIR_PATH)/python.
diff --git a/gdb/python/lib/gdb/command/pahole.py b/gdb/python/lib/gdb/command/pahole.py
new file mode 100644
index 0000000..b159937
--- /dev/null
+++ b/gdb/python/lib/gdb/command/pahole.py
@@ -0,0 +1,81 @@
+# pahole command for gdb
+
+# Copyright (C) 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+import gdb
+
+class Pahole (gdb.Command):
+    """Show the holes in a structure.
+This command takes a single argument, a type name.
+It prints the type and displays comments showing where holes are."""
+
+    def __init__ (self):
+        super (Pahole, self).__init__ ("pahole", gdb.COMMAND_NONE,
+                                       gdb.COMPLETE_SYMBOL)
+
+    @staticmethod
+    def strip (type):
+        while type.code () == gdb.TYPE_CODE_TYPEDEF:
+            type = type.target ()
+        return type
+
+    def pahole (self, type, level, name):
+        if name is None:
+            name = ''
+        tag = type.tag ()
+        if tag is None:
+            tag = ''
+        print '%sstruct %s {' % (' ' * (2 * level), tag)
+        bitpos = 0
+        for field in type.fields ():
+            # Skip static fields.
+            if not hasattr (field, ('bitpos')):
+                continue
+
+            ftype = self.strip (field.type)
+
+            if bitpos != field.bitpos:
+                hole = field.bitpos - bitpos
+                print '  /* XXX %d bit hole, try to pack */' % hole
+                bitpos = field.bitpos
+            if field.bitsize > 0:
+                fieldsize = field.bitsize
+            else:
+                # TARGET_CHAR_BIT here...
+                fieldsize = 8 * ftype.sizeof ()
+
+            # TARGET_CHAR_BIT
+            print ' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)),
+            bitpos = bitpos + fieldsize
+
+            if ftype.code () == gdb.TYPE_CODE_STRUCT:
+                self.pahole (ftype, level + 1, field.name)
+            else:
+                print ' ' * (2 + 2 * level),
+                print '%s %s' % (str (ftype), field.name)
+
+        print ' ' * (14 + 2 * level),
+        print '} %s' % name
+
+    def invoke (self, arg, from_tty):
+        type = gdb.Type (arg)
+        type = self.strip (type)
+        if type.code () != gdb.TYPE_CODE_STRUCT:
+            raise '%s is not a struct type' % arg
+        print ' ' * 14,
+        self.pahole (type, 0, '')
+
+Pahole()


hooks/post-receive
--
Repository for Project Archer.


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

end of thread, other threads:[~2009-09-18 22:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-06 20:48 [SCM] archer-tromey-python: Merge branch 'archer-tromey-python' of ssh://sourceware.org/git/archer into archer-tromey-python tromey
  -- strict thread matches above, loose matches on Subject: below --
2009-09-18 22:39 tromey
2008-11-24 23:06 tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).