public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* RFA: add python exception subclasses (Was: gdb with python support  still get crash on showing uninitialized local variables)
       [not found] ` <m3tykn2id8.fsf@fleche.redhat.com>
@ 2010-10-19 20:17   ` Tom Tromey
  2010-10-19 21:13     ` Eli Zaretskii
                       ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Tom Tromey @ 2010-10-19 20:17 UTC (permalink / raw)
  To: asmwarrior; +Cc: gdb-patches

>>>>> ">" == Asm gmail <asmwarrior@gmail.com> writes:

This needs a doc review.

>>> stdStrRef =
>>> s = std::stack wrapping: std::deque with -521291805 elements = {<error
>>> reading variable s (Cannot access memory at address 0x80)>

Tom> I am working on a fix for this.

Tom> Currently all gdb exceptions are convert to a Python RuntimeError.  But,
Tom> I think we should differentiate a little more.  In particular, I think a
Tom> gdb MEMORY_ERROR should be a separate class, and should be handled
Tom> specially by the pretty-printing code (basically by omitting the stack
Tom> trace).

This patch implements this idea.  It adds some new subclasses of
RuntimeError, including one specifically for MEMORY_ERROR.  Then it
arranges for the memory error exception to be treated specially by the
pretty-printing code.

Built and regtested on x86-64 (compile farm).
Some new test cases are included.

asmwarrior, it would be helpful if you could try this out.

Ok?

Tom

2010-10-19  Tom Tromey  <tromey@redhat.com>

	* varobj.c (value_get_print_value): Rearrange.  Pass stream to
	apply_varobj_pretty_printer.
	* c-lang.c: Include exceptions.h.
	(c_get_string): Throw MEMORY_ERROR when appropriate.
	* python/py-prettyprint.c (enum string_repr_result): New.
	(print_stack_unless_memory_error): New function.
	(print_string_repr): Change return type.  Use
	print_stack_unless_memory_error.
	(print_children): Use print_stack_unless_memory_error.
	(apply_val_pretty_printer): Update.  Don't print children if
	string representation threw an exception.
	(apply_varobj_pretty_printer): Add 'stream' argument.  Use
	print_stack_unless_memory_error.
	* python/python.c (gdbpy_gdb_error, gdbpy_gdb_memory_error): New
	globals.
	(_initialize_python): Initialize them.
	* python/python-internal.h (GDB_PY_HANDLE_EXCEPTION): Use
	gdbpy_convert_exception.
	(GDB_PY_SET_HANDLE_EXCEPTION): Likewise.
	(gdbpy_gdb_error, gdbpy_gdb_memory_error): Declare.
	(gdbpy_convert_exception): Declare.
	(apply_varobj_pretty_printer): Update.
	* python/py-utils.c (gdbpy_convert_exception): New function.

2010-10-19  Tom Tromey  <tromey@redhat.com>

	* gdb.texinfo (Basic Python): Update.  Add xref.
	(Exception Handling): Document new exception classes.
	(Types In Python): Update.
	(Frames In Python): Update.

2010-10-19  Tom Tromey  <tromey@redhat.com>

	* gdb.python/py-prettyprint.c (main): Add new 'ns2' local.
	* gdb.python/py-prettyprint.exp (run_lang_tests): Add test for
	MemoryError.
	* gdb.python/python.exp (gdb_py_test_multiple): Update exception
	type.
	* gdb.python/py-value.exp (test_value_in_inferior): Add test for
	MemoryError.
	(test_subscript_regression): Update exception type.

diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 40c4172..2e80595 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -35,6 +35,7 @@
 #include "cp-support.h"
 #include "gdb_obstack.h"
 #include <ctype.h>
+#include "exceptions.h"
 
 extern void _initialize_c_language (void);
 
@@ -698,13 +699,19 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length,
     }
   else
     {
-      err = read_string (value_as_address (value), *length, width, fetchlimit,
-  			 byte_order, buffer, length);
+      CORE_ADDR addr = value_as_address (value);
+
+      err = read_string (addr, *length, width, fetchlimit,
+			 byte_order, buffer, length);
       if (err)
 	{
 	  xfree (*buffer);
-	  error (_("Error reading string from inferior: %s"),
-		 safe_strerror (err));
+	  if (err == EIO)
+	    throw_error (MEMORY_ERROR, "Address %s out of bounds",
+			 paddress (get_type_arch (type), addr));
+	  else
+	    error (_("Error reading string from inferior: %s"),
+		   safe_strerror (err));
 	}
     }
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 9446932..a8f81c4 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -20548,8 +20548,9 @@ spaces if the parameter has a multi-part name.  For example,
 @samp{print object} is a valid parameter name.
 
 If the named parameter does not exist, this function throws a
-@code{RuntimeError}.  Otherwise, the parameter's value is converted to
-a Python value of the appropriate type, and returned.
+@code{gdb.error} (@pxref{Exception Handling}).  Otherwise, the
+parameter's value is converted to a Python value of the appropriate
+type, and returned.
 @end defun
 
 @findex gdb.history
@@ -20560,7 +20561,7 @@ If @var{number} is negative, then @value{GDBN} will take its absolute value
 and count backward from the last element (i.e., the most recent element) to
 find the value to return.  If @var{number} is zero, then @value{GDBN} will
 return the most recent element.  If the element specified by @var{number}
-doesn't exist in the value history, a @code{RuntimeError} exception will be
+doesn't exist in the value history, a @code{gdb.error} exception will be
 raised.
 
 If no exception is raised, the return value is always an instance of
@@ -20688,15 +20689,31 @@ Traceback (most recent call last):
 NameError: name 'foo' is not defined
 @end smallexample
 
-@value{GDBN} errors that happen in @value{GDBN} commands invoked by Python
-code are converted to Python @code{RuntimeError} exceptions.  User
-interrupt (via @kbd{C-c} or by typing @kbd{q} at a pagination
-prompt) is translated to a Python @code{KeyboardInterrupt}
-exception.  If you catch these exceptions in your Python code, your
-exception handler will see @code{RuntimeError} or
-@code{KeyboardInterrupt} as the exception type, the @value{GDBN} error
-message as its value, and the Python call stack backtrace at the
-Python statement closest to where the @value{GDBN} error occured as the
+@value{GDBN} errors that happen in @value{GDBN} commands invoked by
+Python code are converted to Python exceptions.  The type of the
+Python exception depends on the error.
+
+@ftable @code
+@item gdb.error
+This is the base class for most exceptions generated by @value{GDBN}.
+It is derived from @code{RuntimeError}, for compatibility with earlier
+versions of @value{GDBN}.
+
+If an error occurring in @value{GDBN} does not fit into some more
+specific category, then the generated exception will have this type.
+
+@item gdb.MemoryError
+This is a subclass of @code{gdb.error} which is thrown when an
+operation tried to access invalid memory in the inferior.
+
+@item KeyboardInterrupt
+User interrupt (via @kbd{C-c} or by typing @kbd{q} at a pagination
+prompt) is translated to a Python @code{KeyboardInterrupt} exception.
+@end ftable
+
+In all cases, your exception handler will see the @value{GDBN} error
+message as its value and the Python call stack backtrace at the Python
+statement closest to where the @value{GDBN} error occured as the
 traceback.
 
 @findex gdb.GdbError
@@ -21061,7 +21078,7 @@ variant of this type.  That is, the result is neither @code{const} nor
 Return a Python @code{Tuple} object that contains two elements: the
 low bound of the argument type and the high bound of that type.  If
 the type does not have a range, @value{GDBN} will raise a
-@code{RuntimeError} exception.
+@code{gdb.error} exception (@pxref{Exception Handling}).
 @end defmethod
 
 @defmethod Type reference
@@ -22166,8 +22183,8 @@ When the debugged program stops, @value{GDBN} is able to analyze its call
 stack (@pxref{Frames,,Stack frames}).  The @code{gdb.Frame} class
 represents a frame in the stack.  A @code{gdb.Frame} object is only valid
 while its corresponding frame exists in the inferior's stack.  If you try
-to use an invalid frame object, @value{GDBN} will throw a @code{RuntimeError}
-exception.
+to use an invalid frame object, @value{GDBN} will throw a @code{gdb.error}
+exception (@pxref{Exception Handling}).
 
 Two @code{gdb.Frame} objects can be compared for equality with the @code{==}
 operator, like:
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 37c4078..e6a13c1 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -29,6 +29,18 @@
 #ifdef HAVE_PYTHON
 #include "python-internal.h"
 
+/* Return type of print_string_repr.  */
+
+enum string_repr_result
+  {
+    /* The string method returned None.  */
+    string_repr_none,
+    /* The string method had an error.  */
+    string_repr_error,
+    /* Everything ok.  */
+    string_repr_ok
+  };
+
 /* Helper function for find_pretty_printer which iterates over a list,
    calls each function and inspects output.  This will return a
    printer object if one recognizes VALUE.  If no printer is found, it
@@ -256,12 +268,40 @@ gdbpy_get_display_hint (PyObject *printer)
   return result;
 }
 
+/* A wrapper for gdbpy_print_stack that ignores MemoryError.  */
+
+static void
+print_stack_unless_memory_error (struct ui_file *stream)
+{
+  if (PyErr_ExceptionMatches (gdbpy_gdb_memory_error))
+    {
+      struct cleanup *cleanup;
+      PyObject *type, *value, *trace;
+      char *msg;
+
+      PyErr_Fetch (&type, &value, &trace);
+      cleanup = make_cleanup_py_decref (type);
+      make_cleanup_py_decref (value);
+      make_cleanup_py_decref (trace);
+
+      msg = gdbpy_exception_to_string (type, value);
+      make_cleanup (xfree, msg);
+
+      if (msg == NULL || *msg == '\0')
+	fprintf_filtered (stream, _("<error reading variable"));
+      else
+	fprintf_filtered (stream, _("<error reading variable: %s>"), msg);
+
+      do_cleanups (cleanup);
+    }
+  else
+    gdbpy_print_stack ();
+}
+
 /* Helper for apply_val_pretty_printer which calls to_string and
-   formats the result.  If the value returnd is Py_None, nothing is
-   printed and the function returns a 1; in all other cases data is
-   printed as given by the pretty printer and the function returns 0.
-*/
-static int
+   formats the result.  */
+
+static enum string_repr_result
 print_string_repr (PyObject *printer, const char *hint,
 		   struct ui_file *stream, int recurse,
 		   const struct value_print_options *options,
@@ -270,7 +310,7 @@ print_string_repr (PyObject *printer, const char *hint,
 {
   struct value *replacement = NULL;
   PyObject *py_str = NULL;
-  int is_py_none = 0;
+  enum string_repr_result result = string_repr_ok;
 
   py_str = pretty_print_one_value (printer, &replacement);
   if (py_str)
@@ -278,7 +318,7 @@ print_string_repr (PyObject *printer, const char *hint,
       struct cleanup *cleanup = make_cleanup_py_decref (py_str);
 
       if (py_str == Py_None)
-	is_py_none = 1;
+	result = string_repr_none;
       else if (gdbpy_is_lazy_string (py_str))
 	{
 	  CORE_ADDR addr;
@@ -316,7 +356,10 @@ print_string_repr (PyObject *printer, const char *hint,
 		fputs_filtered (output, stream);
 	    }
 	  else
-	    gdbpy_print_stack ();
+	    {
+	      result = string_repr_error;
+	      print_stack_unless_memory_error (stream);
+	    }
 	}
 
       do_cleanups (cleanup);
@@ -329,9 +372,12 @@ print_string_repr (PyObject *printer, const char *hint,
       common_val_print (replacement, stream, recurse, &opts, language);
     }
   else
-    gdbpy_print_stack ();
+    {
+      result = string_repr_error;
+      print_stack_unless_memory_error (stream);
+    }
 
-  return is_py_none;
+  return result;
 }
 
 static void
@@ -437,7 +483,7 @@ print_children (PyObject *printer, const char *hint,
 					 NULL);
   if (! children)
     {
-      gdbpy_print_stack ();
+      print_stack_unless_memory_error (stream);
       return;
     }
 
@@ -446,7 +492,7 @@ print_children (PyObject *printer, const char *hint,
   iter = PyObject_GetIter (children);
   if (!iter)
     {
-      gdbpy_print_stack ();
+      print_stack_unless_memory_error (stream);
       goto done;
     }
   make_cleanup_py_decref (iter);
@@ -476,7 +522,7 @@ print_children (PyObject *printer, const char *hint,
       if (! item)
 	{
 	  if (PyErr_Occurred ())
-	    gdbpy_print_stack ();
+	    print_stack_unless_memory_error (stream);
 	  /* Set a flag so we can know whether we printed all the
 	     available elements.  */
 	  else	  
@@ -631,7 +677,7 @@ apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
   char *hint = NULL;
   struct cleanup *cleanups;
   int result = 0;
-  int is_py_none = 0;
+  enum string_repr_result print_result;
   cleanups = ensure_python_env (gdbarch, language);
 
   /* Instantiate the printer.  */
@@ -666,17 +712,18 @@ apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
   make_cleanup (free_current_contents, &hint);
 
   /* Print the section */
-  is_py_none = print_string_repr (printer, hint, stream, recurse,
-				  options, language, gdbarch);
-  print_children (printer, hint, stream, recurse, options, language,
-		  is_py_none);
+  print_result = print_string_repr (printer, hint, stream, recurse,
+				    options, language, gdbarch);
+  if (print_result != string_repr_error)
+    print_children (printer, hint, stream, recurse, options, language,
+		    print_result == string_repr_none);
 
   result = 1;
 
 
  done:
   if (PyErr_Occurred ())
-    gdbpy_print_stack ();
+    print_stack_unless_memory_error (stream);
   do_cleanups (cleanups);
   return result;
 }
@@ -693,7 +740,8 @@ apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
    NULL.  */
 PyObject *
 apply_varobj_pretty_printer (PyObject *printer_obj,
-			     struct value **replacement)
+			     struct value **replacement,
+			     struct ui_file *stream)
 {
   PyObject *py_str = NULL;
 
@@ -701,7 +749,7 @@ apply_varobj_pretty_printer (PyObject *printer_obj,
   py_str = pretty_print_one_value (printer_obj, replacement);
 
   if (*replacement == NULL && py_str == NULL)
-    gdbpy_print_stack ();
+    print_stack_unless_memory_error (stream);
 
   return py_str;
 }
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index 90609fa..2f0aac4 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -274,6 +274,25 @@ gdbpy_exception_to_string (PyObject *ptype, PyObject *pvalue)
   return str;
 }
 
+/* Convert a GDB exception to the appropriate Python exception.
+   
+   This sets the Python error indicator, and returns NULL.  */
+
+PyObject *
+gdbpy_convert_exception (struct gdb_exception exception)
+{
+  PyObject *exc_class;
+
+  if (exception.reason == RETURN_QUIT)
+    exc_class = PyExc_KeyboardInterrupt;
+  else if (exception.error == MEMORY_ERROR)
+    exc_class = gdbpy_gdb_memory_error;
+  else
+    exc_class = gdbpy_gdb_error;
+
+  return PyErr_Format (exc_class, "%s", exception.message);
+}
+
 /* Converts OBJ to a CORE_ADDR value.
 
    Returns 1 on success or 0 on failure, with a Python exception set.  This
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index d00c23e..c196a30 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -76,6 +76,8 @@ typedef int Py_ssize_t;
 /* Also needed to parse enum var_types. */
 #include "command.h"
 
+#include "exceptions.h"
+
 struct block;
 struct value;
 struct language_defn;
@@ -175,9 +177,7 @@ extern const struct language_defn *python_language;
 #define GDB_PY_HANDLE_EXCEPTION(Exception)				\
     do {								\
       if (Exception.reason < 0)						\
-	return PyErr_Format (Exception.reason == RETURN_QUIT		\
-			     ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, \
-			     "%s", Exception.message);			\
+	return gdbpy_convert_exception (Exception);			\
     } while (0)
 
 /* Use this after a TRY_EXCEPT to throw the appropriate Python
@@ -186,9 +186,7 @@ extern const struct language_defn *python_language;
     do {								\
       if (Exception.reason < 0)						\
         {								\
-	  PyErr_Format (Exception.reason == RETURN_QUIT			\
-			? PyExc_KeyboardInterrupt : PyExc_RuntimeError, \
-			"%s", Exception.message);			\
+	  gdbpy_convert_exception (Exception);				\
 	  return -1;							\
 	}								\
     } while (0)
@@ -218,7 +216,8 @@ int gdbpy_is_value_object (PyObject *obj);
 /* Note that these are declared here, and not in python.h with the
    other pretty-printer functions, because they refer to PyObject.  */
 PyObject *apply_varobj_pretty_printer (PyObject *print_obj,
-				       struct value **replacement);
+				       struct value **replacement,
+				       struct ui_file *stream);
 PyObject *gdbpy_get_varobj_pretty_printer (struct value *value);
 char *gdbpy_get_display_hint (PyObject *printer);
 PyObject *gdbpy_default_visualizer (PyObject *self, PyObject *args);
@@ -229,8 +228,13 @@ extern PyObject *gdbpy_to_string_cst;
 extern PyObject *gdbpy_display_hint_cst;
 extern PyObject *gdbpy_enabled_cst;
 
+/* Exception types.  */
+extern PyObject *gdbpy_gdb_error;
+extern PyObject *gdbpy_gdb_memory_error;
 extern PyObject *gdbpy_gdberror_exc;
 
+extern PyObject *gdbpy_convert_exception (struct gdb_exception);
+
 int get_addr_from_python (PyObject *obj, CORE_ADDR *addr);
 
 #endif /* GDB_PYTHON_INTERNAL_H */
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 78410c6..1eef8ce 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -66,6 +66,12 @@ PyObject *gdbpy_enabled_cst;
 /* The GdbError exception.  */
 PyObject *gdbpy_gdberror_exc;
 
+/* The `gdb.error' base class.  */
+PyObject *gdbpy_gdb_error;
+
+/* The `gdb.MemoryError' exception.  */
+PyObject *gdbpy_gdb_memory_error;
+
 /* Architecture and language to be used in callbacks from
    the Python interpreter.  */
 struct gdbarch *python_gdbarch;
@@ -967,6 +973,13 @@ Enables or disables printing of Python stack traces."),
     xfree (gdb_pythondir);
   }
 
+  gdbpy_gdb_error = PyErr_NewException ("gdb.error", PyExc_RuntimeError, NULL);
+  PyModule_AddObject (gdb_module, "error", gdbpy_gdb_error);
+
+  gdbpy_gdb_memory_error = PyErr_NewException ("gdb.MemoryError",
+					       gdbpy_gdb_error, NULL);
+  PyModule_AddObject (gdb_module, "MemoryError", gdbpy_gdb_memory_error);
+
   gdbpy_gdberror_exc = PyErr_NewException ("gdb.GdbError", NULL, NULL);
   PyModule_AddObject (gdb_module, "GdbError", gdbpy_gdberror_exc);
 
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.c b/gdb/testsuite/gdb.python/py-prettyprint.c
index b633111..23e3ff9 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.c
+++ b/gdb/testsuite/gdb.python/py-prettyprint.c
@@ -213,7 +213,7 @@ main ()
   /* Clearing by being `static' could invoke an other GDB C++ bug.  */
   struct nullstr nullstr;
   nostring_type nstype;
-  struct ns  ns;
+  struct ns ns, ns2;
   struct lazystring estring, estring2;
 
   nstype.elements = narray;
@@ -231,6 +231,10 @@ main ()
   ns.null_str = "embedded\0null\0string";
   ns.length = 20;
 
+  /* Make a "corrupted" string.  */
+  ns2.null_str = NULL;
+  ns2.length = 20;
+
   estring.lazy_str = "embedded x\201\202\203\204" ;
 
   /* Incomplete UTF-8, but ok Latin-1.  */
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp
index b8f37d3..7eda415 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.exp
+++ b/gdb/testsuite/gdb.python/py-prettyprint.exp
@@ -87,6 +87,8 @@ proc run_lang_tests {lang} {
 	gdb_py_test_silent_cmd "set print elements 200" "" 1
     }
 
+    gdb_test "print ns2" ".error reading variable: Address 0x0 out of bounds."
+
     gdb_test "print x" " = \"this is x\""
     gdb_test "print cstring" " = \"const string\""
 
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index 895969b..9bee1c0 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -210,6 +210,9 @@ proc test_value_in_inferior {} {
   # Test address attribute
   gdb_test "python print 'result =', arg0.address" "= 0x\[\[:xdigit:\]\]+" "Test address attribute"
 
+  # Test memory error.
+  gdb_test "python print gdb.parse_and_eval('*(int*)0')" "gdb.MemoryError: Cannot access memory at address 0x0.*"
+
   # Test string fetches,  both partial and whole.
   gdb_test "print st" "\"divide et impera\""
   gdb_py_test_silent_cmd "python st = gdb.history (0)" "get value from history" 1
@@ -371,7 +374,7 @@ proc test_subscript_regression {lang} {
 
  # Try to access an int with a subscript.  This should fail.
  gdb_test "python print intv" "1" "Baseline print of a Python value"
- gdb_test "python print intv\[0\]" "RuntimeError: Cannot subscript requested type.*" \
+ gdb_test "python print intv\[0\]" "gdb.error: Cannot subscript requested type.*" \
      "Attempt to access an integer with a subscript"
 
  # Try to access a string with a subscript.  This should pass.
@@ -386,7 +389,7 @@ proc test_subscript_regression {lang} {
 
  # Try to access a single dimension array with a subscript to the
  # result.  This should fail.
- gdb_test "python print pointer\[intv\]\[0\]" "RuntimeError: Cannot subscript requested type.*" \
+ gdb_test "python print pointer\[intv\]\[0\]" "gdb.error: Cannot subscript requested type.*" \
      "Attempt to access an integer with a subscript"
 
  # Lastly, test subscript access to an array with multiple
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index 301245b..dd9175a 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -160,7 +160,7 @@ runto [gdb_get_line_number "Break to end."]
 
 # Test gdb.decode_line.
 gdb_test "python gdb.decode_line(\"main.c:43\")" \
-    "RuntimeError: No source file named main.c.*" "test decode_line no source named main"
+    "gdb.error: No source file named main.c.*" "test decode_line no source named main"
 
 gdb_py_test_silent_cmd "python symtab = gdb.decode_line()" "test decode_line current location" 1
 gdb_test "python print len(symtab)" "2" "Test decode_line current location"
@@ -177,7 +177,7 @@ gdb_test "python print symtab\[1\]\[0\].symtab" "gdb/testsuite/gdb.python/python
 gdb_test "python print symtab\[1\]\[0\].line" "26" "Test decode_line python.c:26 line number"
 
 gdb_test "python gdb.decode_line(\"randomfunc\")" \
-    "RuntimeError: Function \"randomfunc\" not defined.*" "test decode_line randomfunc"
+    "gdb.error: Function \"randomfunc\" not defined.*" "test decode_line randomfunc"
 gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"func1\")" "test decode_line func1()" 1
 gdb_test "python print len(symtab)" "2" "Test decode_line func1 length"
 gdb_test "python print len(symtab\[1\])" "1" "Test decode_line func1 length"
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 09f91eb..e87d399 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2479,7 +2479,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
 		       struct varobj *var)
 {
   struct ui_file *stb;
-  struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
+  struct cleanup *old_chain;
   gdb_byte *thevalue = NULL;
   struct value_print_options opts;
   struct type *type = NULL;
@@ -2493,6 +2493,9 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
   if (value == NULL)
     return NULL;
 
+  stb = mem_fileopen ();
+  old_chain = make_cleanup_ui_file_delete (stb);
+
   gdbarch = get_type_arch (value_type (value));
 #if HAVE_PYTHON
   {
@@ -2505,7 +2508,10 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
 	/* First check to see if we have any children at all.  If so,
 	   we simply return {...}.  */
 	if (dynamic_varobj_has_child_method (var))
-	  return xstrdup ("{...}");
+	  {
+	    do_cleanups (old_chain);
+	    return xstrdup ("{...}");
+	  }
 
 	if (PyObject_HasAttr (value_formatter, gdbpy_to_string_cst))
 	  {
@@ -2522,7 +2528,8 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
 	      }
 
 	    output = apply_varobj_pretty_printer (value_formatter,
-						  &replacement);
+						  &replacement,
+						  stb);
 	    if (output)
 	      {
 		make_cleanup_py_decref (output);
@@ -2567,9 +2574,6 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
   }
 #endif
 
-  stb = mem_fileopen ();
-  make_cleanup_ui_file_delete (stb);
-
   get_formatted_print_options (&opts, format_code[(int) format]);
   opts.deref_ref = 0;
   opts.raw = 1;

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

* Re: RFA: add python exception subclasses (Was: gdb with python support  still get crash on showing uninitialized local variables)
  2010-10-19 20:17   ` RFA: add python exception subclasses (Was: gdb with python support still get crash on showing uninitialized local variables) Tom Tromey
@ 2010-10-19 21:13     ` Eli Zaretskii
  2010-10-20  5:19     ` gdb with python support still get crash on showing uninitialized local variables asmwarrior
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2010-10-19 21:13 UTC (permalink / raw)
  To: Tom Tromey; +Cc: asmwarrior, gdb-patches

> From: Tom Tromey <tromey@redhat.com>
> Cc: gdb-patches@sourceware.org
> Date: Tue, 19 Oct 2010 14:17:15 -0600
> 
> This needs a doc review.

Thanks, the documentation part is fine with me.

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

* Re: gdb with python support  still get crash on showing uninitialized local variables
  2010-10-19 20:17   ` RFA: add python exception subclasses (Was: gdb with python support still get crash on showing uninitialized local variables) Tom Tromey
  2010-10-19 21:13     ` Eli Zaretskii
@ 2010-10-20  5:19     ` asmwarrior
  2010-10-22 19:13       ` Tom Tromey
  2010-11-12 20:47     ` RFA: add python exception subclasses Tom Tromey
       [not found]     ` <AANLkTinsJLTZT0ws=LbpYcq85_Z9_R=fcXz+J+kqScJU@mail.gmail.com>
  3 siblings, 1 reply; 11+ messages in thread
From: asmwarrior @ 2010-10-20  5:19 UTC (permalink / raw)
  To: gdb, gdb-patches

On 2010-10-20 4:17, Tom Tromey wrote:
 > reading variable s (Cannot access memory at address 0x80)
 > Tom> I am working on a fix for this.
 >
 > Tom> Currently all gdb exceptions are convert to a Python 
RuntimeError.  But,
 > Tom> I think we should differentiate a little more.  In particular, I 
think a
 > Tom> gdb MEMORY_ERROR should be a separate class, and should be handled
 > Tom> specially by the pretty-printing code (basically by omitting the 
stack
 > Tom> trace).
 >
 > This patch implements this idea.  It adds some new subclasses of
 > RuntimeError, including one specifically for MEMORY_ERROR.  Then it
 > arranges for the memory error exception to be treated specially by the
 > pretty-printing code.
 >
 > Built and regtested on x86-64 (compile farm).
 > Some new test cases are included.
 >
 > asmwarrior, it would be helpful if you could try this out.
 >
 > Ok?
 >
 > Tom
 >
OK.


I just use git to check out the latest whole gdb source (>100M)
Then apply your patch

Then use MSYS + MINGW GCC 4.4.4 to build it .

But I failed with the build error. like:

../../gdb/libiberty/fibheap.c:151: warning: incompatible implicit 
declaration of
  built-in function 'free'
../../gdb/libiberty/fibheap.c:156: warning: incompatible implicit 
declaration of
  built-in function 'free'
../../gdb/libiberty/fibheap.c:172: warning: incompatible implicit 
declaration of
  built-in function 'free'
../../gdb/libiberty/fibheap.c: In function 'fibheap_extract_min':
../../gdb/libiberty/fibheap.c:190: warning: incompatible implicit 
declaration of
  built-in function 'free'
../../gdb/libiberty/fibheap.c: In function 'fibheap_replace_key_data':
../../gdb/libiberty/fibheap.c:220: error: 'LONG_MIN' undeclared (first 
use in th
is function)
../../gdb/libiberty/fibheap.c:220: error: (Each undeclared identifier is 
reporte
d only once
../../gdb/libiberty/fibheap.c:220: error: for each function it appears in.)
../../gdb/libiberty/fibheap.c: In function 'fibheap_delete_node':
../../gdb/libiberty/fibheap.c:261: error: 'LONG_MIN' undeclared (first 
use in th
is function)
../../gdb/libiberty/fibheap.c:265: warning: implicit declaration of 
function 'ab
ort'
../../gdb/libiberty/fibheap.c:265: warning: incompatible implicit 
declaration of
  built-in function 'abort'
../../gdb/libiberty/fibheap.c: In function 'fibheap_delete':
../../gdb/libiberty/fibheap.c:277: warning: incompatible implicit 
declaration of
  built-in function 'free'
../../gdb/libiberty/fibheap.c: In function 'fibheap_consolidate':
../../gdb/libiberty/fibheap.c:368: warning: implicit declaration of 
function 'me
mset'
../../gdb/libiberty/fibheap.c:368: warning: incompatible implicit 
declaration of
  built-in function 'memset'
make[2]: *** [fibheap.o] Error 1
make[2]: Leaving directory `e:/test/build/libiberty'
make[1]: *** [all-libiberty] Error 2
make[1]: Leaving directory `e:/test/build'
make: *** [all] Error 2

When I manually add this macro definition then continue the build, I got 
other more errors.

I can remember that the snapshot of GDB source 20101005, I can build it 
successful. I'm not sure why.

Asmwarrior.

BTW:

My friend Loaden has some build errors when building gdb.exe (weekly 
20101019) from linux, here is his build log:

  /bin/install -c -m 644 ../../../../src/gdb/bfd/doc/bfd.info 
'/home/loaden/gdb/share/info'
  install-info --info-dir='/home/loaden/gdb/share/info' 
'/home/loaden/gdb/share/info/bfd.info'
make[4]: Leaving directory `/home/loaden/AUR/gdb/build/gdb-win/bfd/doc'
Making install in po
make[4]: Entering directory `/home/loaden/AUR/gdb/build/gdb-win/bfd/po'
if test -r ../../../../src/gdb/bfd/../mkinstalldirs; then \
       ../../../../src/gdb/bfd/../mkinstalldirs /home/loaden/gdb/share; \
     else \
       ../../../../src/gdb/bfd/mkinstalldirs /home/loaden/gdb/share; \
     fi
/bin/sh: line 1: ../../../../src/gdb/bfd/../mkinstalldirs: Permission denied
make[4]: *** [install-data-yes] Error 126
make[4]: Leaving directory `/home/loaden/AUR/gdb/build/gdb-win/bfd/po'
make[4]: Entering directory `/home/loaden/AUR/gdb/build/gdb-win/bfd'
make[5]: Entering directory `/home/loaden/AUR/gdb/build/gdb-win/bfd'
make[5]: Nothing to be done for `install-exec-am'.
test -z "/home/loaden/gdb/include" || /bin/mkdir -p 
"/home/loaden/gdb/include"
  /bin/install -c -m 644 bfd.h 
../../../src/gdb/bfd/../include/ansidecl.h 
../../../src/gdb/bfd/../include/symcat.h 
../../../src/gdb/bfd/../include/bfdlink.h '/home/loaden/gdb/include'
test -z "/home/loaden/gdb/lib" || /bin/mkdir -p "/home/loaden/gdb/lib"
  /bin/sh ./libtool   --mode=install /bin/install -c   libbfd.la 
'/home/loaden/gdb/lib'
libtool: install: /bin/install -c .libs/libbfd.lai 
/home/loaden/gdb/lib/libbfd.la
libtool: install: /bin/install -c .libs/libbfd.a 
/home/loaden/gdb/lib/libbfd.a
libtool: install: chmod 644 /home/loaden/gdb/lib/libbfd.a
libtool: install: i686-mingw32-ranlib /home/loaden/gdb/lib/libbfd.a
libtool: install: warning: remember to run `libtool --finish 
/home/loaden/AUR/gdb/depends/lib'
make[5]: Leaving directory `/home/loaden/AUR/gdb/build/gdb-win/bfd'
make[4]: Leaving directory `/home/loaden/AUR/gdb/build/gdb-win/bfd'
make[3]: *** [install-recursive] Error 1
make[3]: Leaving directory `/home/loaden/AUR/gdb/build/gdb-win/bfd'
make[2]: *** [install] Error 2
make[2]: Leaving directory `/home/loaden/AUR/gdb/build/gdb-win/bfd'
make[1]: *** [install-bfd] Error 2
make[1]: Leaving directory `/home/loaden/AUR/gdb/build/gdb-win'
make: *** [install] Error 2




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

* Re: gdb with python support  still get crash on showing uninitialized local variables
  2010-10-20  5:19     ` gdb with python support still get crash on showing uninitialized local variables asmwarrior
@ 2010-10-22 19:13       ` Tom Tromey
  2010-10-22 21:22         ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2010-10-22 19:13 UTC (permalink / raw)
  To: asmwarrior; +Cc: gdb, gdb-patches

>>>>> "asmwarrior" == asmwarrior  <asmwarrior@gmail.com> writes:

asmwarrior> I just use git to check out the latest whole gdb source (>100M)
asmwarrior> Then apply your patch

asmwarrior> Then use MSYS + MINGW GCC 4.4.4 to build it .

asmwarrior> But I failed with the build error. like:

That seems weird, like maybe you are missing a header file.
I don't know for certain what it is, though; you'll have to debug it.

asmwarrior> /bin/sh: line 1: ../../../../src/gdb/bfd/../mkinstalldirs: Permission denied

This file should be +x.

Tom

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

* Re: gdb with python support  still get crash on showing uninitialized local variables
  2010-10-22 19:13       ` Tom Tromey
@ 2010-10-22 21:22         ` Eli Zaretskii
  2010-10-29 19:18           ` Joel Brobecker
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2010-10-22 21:22 UTC (permalink / raw)
  To: Tom Tromey; +Cc: asmwarrior, gdb, gdb-patches

> From: Tom Tromey <tromey@redhat.com>
> Cc: "gdb\@sourceware.org" <gdb@sourceware.org>, gdb-patches@sourceware.org
> Date: Fri, 22 Oct 2010 13:17:04 -0600
> 
> asmwarrior> /bin/sh: line 1: ../../../../src/gdb/bfd/../mkinstalldirs: Permission denied
> 
> This file should be +x.

There's no such thing on Windows.

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

* Re: gdb with python support  still get crash on showing uninitialized local variables
  2010-10-22 21:22         ` Eli Zaretskii
@ 2010-10-29 19:18           ` Joel Brobecker
  2010-10-29 22:01             ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Joel Brobecker @ 2010-10-29 19:18 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Tom Tromey, asmwarrior, gdb, gdb-patches

> > asmwarrior> /bin/sh: line 1: ../../../../src/gdb/bfd/../mkinstalldirs: Permission denied
> > 
> > This file should be +x.
> 
> There's no such thing on Windows.

Yes, because it's a script, the makefile should execute it via $SHELL.
I see that we're making the same error in gdb/doc, for instance, so
it looks like we would be unable to build the documentation if building
using MinGW tools.

I am flying back this evening, so I will try to remember to send a patch
soon.

-- 
Joel

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

* Re: gdb with python support  still get crash on showing uninitialized local variables
  2010-10-29 19:18           ` Joel Brobecker
@ 2010-10-29 22:01             ` Eli Zaretskii
  2010-10-31  2:24               ` asmwarrior
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2010-10-29 22:01 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: tromey, asmwarrior, gdb, gdb-patches

> Date: Fri, 29 Oct 2010 15:18:20 -0400
> From: Joel Brobecker <brobecker@adacore.com>
> Cc: Tom Tromey <tromey@redhat.com>, asmwarrior@gmail.com,	gdb@sourceware.org, gdb-patches@sourceware.org
> 
> Yes, because it's a script, the makefile should execute it via $SHELL.
> I see that we're making the same error in gdb/doc, for instance, so
> it looks like we would be unable to build the documentation if building
> using MinGW tools.

If you are using the MinGW port of GNU Make, it will always use sh.exe
(if it can find it on your PATH) automatically to run any shell
scripts invoked by the Makefile.  I just tried that with a MinGW build
of Make 3.82, and commands like "./mkinstalldirs foo/bar" just work (I
do have a sh.exe).  This works because the function process_begin on
w32/subproc/sub_proc.c has code to detect a Unix shell script and
DTRT.

So there's some other factor at work here.  Or maybe the sh.exe which
is installed on the OP's machine has some issues that mine doesn't.

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

* Re: Re: gdb with python support  still get crash on showing uninitialized local variables
  2010-10-29 22:01             ` Eli Zaretskii
@ 2010-10-31  2:24               ` asmwarrior
  0 siblings, 0 replies; 11+ messages in thread
From: asmwarrior @ 2010-10-31  2:24 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Joel Brobecker, tromey, gdb, gdb-patches

On 3:59, Eli Zaretskii wrote:
>> Date: Fri, 29 Oct 2010 15:18:20 -0400
>> From: Joel Brobecker<brobecker@adacore.com>
>> Cc: Tom Tromey<tromey@redhat.com>, asmwarrior@gmail.com,	gdb@sourceware.org, gdb-patches@sourceware.org
>>
>> Yes, because it's a script, the makefile should execute it via $SHELL.
>> I see that we're making the same error in gdb/doc, for instance, so
>> it looks like we would be unable to build the documentation if building
>> using MinGW tools.
>
> If you are using the MinGW port of GNU Make, it will always use sh.exe
> (if it can find it on your PATH) automatically to run any shell
> scripts invoked by the Makefile.  I just tried that with a MinGW build
> of Make 3.82, and commands like "./mkinstalldirs foo/bar" just work (I
> do have a sh.exe).  This works because the function process_begin on
> w32/subproc/sub_proc.c has code to detect a Unix shell script and
> DTRT.
>
> So there's some other factor at work here.  Or maybe the sh.exe which
> is installed on the OP's machine has some issues that mine doesn't.
Hi Eli
I use the configure make command directly in the MSYS shell. So I think 
they by default use the GNU make (not the mingw32-make).

But I run the make -v on the MSYS shell, it gives the version number 
3.81. So I will try 3.82 as your mentioned.

Asmwarrior

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

* Re: RFA: add python exception subclasses
  2010-10-19 20:17   ` RFA: add python exception subclasses (Was: gdb with python support still get crash on showing uninitialized local variables) Tom Tromey
  2010-10-19 21:13     ` Eli Zaretskii
  2010-10-20  5:19     ` gdb with python support still get crash on showing uninitialized local variables asmwarrior
@ 2010-11-12 20:47     ` Tom Tromey
       [not found]     ` <AANLkTinsJLTZT0ws=LbpYcq85_Z9_R=fcXz+J+kqScJU@mail.gmail.com>
  3 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2010-11-12 20:47 UTC (permalink / raw)
  To: asmwarrior; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> This patch implements this idea.  It adds some new subclasses of
Tom> RuntimeError, including one specifically for MEMORY_ERROR.  Then it
Tom> arranges for the memory error exception to be treated specially by the
Tom> pretty-printing code.

I am checking this in now.

I don't think it fully fixes the problem, but it is a good step.

I think the other part is fixing the existing printers so that their
iterators more gracefully handle a MemoryError thrown when computing a
value.

Tom

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

* Re: RFA: add python exception subclasses
       [not found]     ` <AANLkTinsJLTZT0ws=LbpYcq85_Z9_R=fcXz+J+kqScJU@mail.gmail.com>
@ 2010-12-17 19:04       ` Tom Tromey
  2010-12-18  2:26         ` asmwarrior
  0 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2010-12-17 19:04 UTC (permalink / raw)
  To: asm warrior; +Cc: gdb, gdb-patches

>>>>> ">" == asm warrior <asmwarrior@gmail.com> writes:

>> It seems this patch was already in the cvs trunk, but using the latest gdb I
>> build myself yesterday(MSYS+MinGW). gdb still crashes when showing
>> uninitialized vector<string>.

Could you post the session and a backtrace?

Tom

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

* Re: RFA: add python exception subclasses
  2010-12-17 19:04       ` Tom Tromey
@ 2010-12-18  2:26         ` asmwarrior
  0 siblings, 0 replies; 11+ messages in thread
From: asmwarrior @ 2010-12-18  2:26 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb, gdb-patches

On 2010-12-18 3:04, Tom Tromey wrote:
>>> It seems this patch was already in the cvs trunk, but using the latest gdb I
>>> build myself yesterday(MSYS+MinGW). gdb still crashes when showing
>>> uninitialized vector<string>.
> Could you post the session and a backtrace?
>
> Tom
since the previous reply was reject by the mail-list, I create a compact 
one.

log here(some text removed)
--------------------------------------------------------------------

 > p v
$1 = std::vector of length -259079, capacity -521893089 = {<error 
reading variable: Cannot access memory at address 0x900014b6>, <error 
reading variable: Cannot access memory at address 0x34ac>, <error 
reading variable: Cannot access memory at address 0x300b9f4>, <error 
reading variable: Cannot access memory at address 0x12ff7ff2>, <error 
reading variable: Cannot access memory at address 0x900010b6>, <error 
reading variable: Cannot access memory at address 0x35ac>, <error 
reading variable: Cannot access memory at address 0x300b9f4>, <error 
reading variable: Cannot access memory at address 0x12ff7ff2>, <error 
reading variable:

.....

<error reading variable: Cannot access memory at address 0x12ff7ff2>, 
"s\000\037\066\003\326\025\000\000\001\020%\000\000\025_\037\000\000\025\020%\000\000\025\326\025\000\000\025\213$\000\000\000\063\004\221\036\000\000E\001putwc\000\037%\002\320\037\000\000\001\065%\000\000\025\244\026\000\000\025j#\000\000\000E\001putwchar\000\037\221\002\320\037\000\000\001R%\000\000\025\244\026\000\000\000E\001swscanf\000\037r\002\221\025\000\000\001t%\000\000\025e\037\000\000\025e\037\000\000F\000E\001ungetwc\000\037'\002\320\037\000\000\001\225%\000\000\025\320\037\000\000\025j#\000\000\000E\001vfwprintf\000\037/\002\221\025\000\000\001\275%\000\000\025j#\000\000\025e\037\000\000\025\236\037\000\000\000E\001vfwscanf\000\037B\002\221\025\000\000\001\344%\000\000\025j#\000\000\025e\037\000\000\025\236\037\000\000\000E\001vswscanf\000\037C\002\221\025\000\000\001\v&\000\000\025e\037\000\000\025e\037\000\000\025\236\037\000\000\000E\001vwprintf\000\037\060\002\221\025\000\000\001-&\000\000\025e\037\000\000\025\236\037\000\000\000E\001vwscanf\000\037A
....

<error reading variable: Cannot access memory at address 0xdd08ec77>, 
<error reading variable: Cannot access memory at address 0x448b2408>, 
<error reading variable: Cannot access memory at address 0xc4830418>, 
<error reading variable: Cannot access memory at address 0x24fc>, <error 
reading variable: Cannot access memory at address 0x3d747fe4>, <error 
reading variable: Cannot access memory at address 0xf0000031>, <error 
reading variable: Cannot access memory at address 0x665f7473>, <error 
reading variable: Cannot access memory at address 0x6624047f>, <error 
reading variable: Cannot access memory at address 0x74027f31>, <error 
reading variable: Cannot access memory at address 0xe083661e>, <error 
reading variable: Cannot access memory at address 0x9b217514>, <error 
reading variable: Cannot access memory at address 0x8366e0d3>, <error 
reading variable: Cannot access memory at address 0x187420d4>, <error 
reading variable: Cannot access memory at address 0x8ac>, <error reading 
variable: Cannot access memory at address 0x1dfa82f4>, <error reading 
variable: Cannot access memory at address 0xb2e80768>, <error reading 
variable: Cannot access memory at address 0x59fffff4>, <error reading 
variable: Cannot access memory at address 0x94e8b7>, <error reading 
variable: Cannot access memory at address 0xc359fff4>, <error reading 
variable: Cannot access memory at address 0x5a242ccd>, <error reading 
variable: Cannot access memory at address 0xe005ddb7>, <error reading 
variable: Cannot access memory at address 0xd97c90d7>, <error reading 
variable: Cannot access memory at address 0xddfdd9bd>, <error reading 
variable: Cannot access memory at address 0xd9c0d9cd>, <error reading 
variable: Cannot acces
This application has requested the Runtime to terminate it in an unusual 
way.
Please contact the application's support team for more information.



--------------------------------------------------------------------
the test code was quite simple:

#include <wx/wx.h>
#include <string>
#include <map>
#include <list>
#include <stack>
#include <vector>

int main()
{
      wxString wxStr(L"wxString");
      wxStr += L" Value";
      std::string stdStr("std::string");
      stdStr.append(" value");
      std::map<int, std::string> m;
      m[0] = "000";
      m[1] = "111";
      wxString& wxStrRef = wxStr;
      wxStrRef += L" Ref";
      std::string& stdStrRef = stdStr;
      stdStrRef += " Ref";

      std::list<std::string> l = {"a", "b", "c"};
      std::vector<std::string> v = {"a", "b", "c"};

      std::stack<std::string> s;
      s.push("a");
      s.push("b");

      return 0;
}

and set break-point in the first line. then run the "p v" command.
Hope this helps. thanks.

asmwarrior

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

end of thread, other threads:[~2010-12-18  2:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4CB66700.3000907@gmail.com>
     [not found] ` <m3tykn2id8.fsf@fleche.redhat.com>
2010-10-19 20:17   ` RFA: add python exception subclasses (Was: gdb with python support still get crash on showing uninitialized local variables) Tom Tromey
2010-10-19 21:13     ` Eli Zaretskii
2010-10-20  5:19     ` gdb with python support still get crash on showing uninitialized local variables asmwarrior
2010-10-22 19:13       ` Tom Tromey
2010-10-22 21:22         ` Eli Zaretskii
2010-10-29 19:18           ` Joel Brobecker
2010-10-29 22:01             ` Eli Zaretskii
2010-10-31  2:24               ` asmwarrior
2010-11-12 20:47     ` RFA: add python exception subclasses Tom Tromey
     [not found]     ` <AANLkTinsJLTZT0ws=LbpYcq85_Z9_R=fcXz+J+kqScJU@mail.gmail.com>
2010-12-17 19:04       ` Tom Tromey
2010-12-18  2:26         ` asmwarrior

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