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


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

[ob/dwarf] Do not crash on unexpected function arguments


This patch is a bandage for another RealView quirk; the argument
is marked artificial in "void x(int) { }".  That's not a pointer, so
we crashed trying to read TYPE_TARGET_TYPE.

There's no reliable way to separate these two cases.  In the latest
versions, and with --dwarf3, we could rely on DW_AT_object_pointer
instead; but in order to do that we have to detect a priori that this
producer will generate DW_AT_object_pointer in order to respond to its
absence.

So, for now, I've checked in the simple don't-crash version.  Tested
on arm-eabi.

-- 
Daniel Jacobowitz
CodeSourcery

2010-09-08  Daniel Jacobowitz  <dan@codesourcery.com>

	* dwarf2read.c (dwarf2_compute_name): Check that the first
	argument is a pointer.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.454
diff -u -p -r1.454 dwarf2read.c
--- dwarf2read.c	8 Sep 2010 23:14:52 -0000	1.454
+++ dwarf2read.c	8 Sep 2010 23:33:25 -0000
@@ -4848,8 +4848,14 @@ dwarf2_compute_name (char *name, struct 
 		}
 	      else if (cu->language == language_cplus)
 		{
+		  /* Assume that an artificial first parameter is
+		     "this", but do not crash if it is not.  RealView
+		     marks unnamed (and thus unused) parameters as
+		     artificial; there is no way to differentiate
+		     the two cases.  */
 		  if (TYPE_NFIELDS (type) > 0
 		      && TYPE_FIELD_ARTIFICIAL (type, 0)
+		      && TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_PTR
 		      && TYPE_CONST (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0))))
 		    fputs_unfiltered (" const", buf);
 		}


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