Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [commit] Fix a C++ segfault
@ 2006-07-20 22:54 Daniel Jacobowitz
  2006-07-21  0:28 ` Joel Brobecker
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2006-07-20 22:54 UTC (permalink / raw)
  To: gdb-patches

Something Michael Chastain pointed out to me a long time ago.
This prevents GDB from crashing, in the fairly obvious way.
It still doesn't pass the test:

+# TODO: GDB doesn't know to convert the string to a const char *, and
+# instead tries to use the string as a structure initializer.

But this is well into the range of where you need a real C++ compiler wired
up.  In Ottawa I talked to Mark Mitchell about the general problem; he said
that something like 20,000 lines of g++ is devoted to selecting the correct
conversions and overloaded functions.  I have absolutely zero interest, full
stop, in duplicating that code.  I don't intend any major improvements in
this area, unless someone is motivated enough to let us share the code for
it with g++.

Checked in.

-- 
Daniel Jacobowitz
CodeSourcery

2006-07-20  Daniel Jacobowitz  <dan@codesourcery.com>

	* eval.c (evaluate_struct_tuple): Skip static fields.

2006-07-20  Daniel Jacobowitz  <dan@codesourcery.com>

	* gdb.cp/bs15503.exp: Update comment for no longer crashing
	test.

Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.61
diff -u -p -r1.61 eval.c
--- eval.c	18 Feb 2006 20:47:54 -0000	1.61
+++ eval.c	20 Jul 2006 22:36:01 -0000
@@ -283,6 +283,10 @@ evaluate_struct_tuple (struct value *str
 	      if (variantno < 0)
 		{
 		  fieldno++;
+		  /* Skip static fields.  */
+		  while (fieldno < TYPE_NFIELDS (struct_type)
+			 && TYPE_FIELD_STATIC_KIND (struct_type, fieldno))
+		    fieldno++;
 		  subfieldno = fieldno;
 		  if (fieldno >= TYPE_NFIELDS (struct_type))
 		    error (_("too many initializers"));
Index: testsuite/gdb.cp/bs15503.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/bs15503.exp,v
retrieving revision 1.5
diff -u -p -r1.5 bs15503.exp
--- testsuite/gdb.cp/bs15503.exp	27 Apr 2005 16:35:15 -0000	1.5
+++ testsuite/gdb.cp/bs15503.exp	20 Jul 2006 22:36:02 -0000
@@ -83,11 +83,11 @@ gdb_test "print (const char *) s" \
 # gdb_test "print s > "AAA"			"\\$\[0-9\]+ = true"
 # gdb_test "print s < "ZZZ"			"\\$\[0-9\]+ = true"
 
-# TODO crash gdb!  This is going to be a great test!
-# -- chastain 2004-01-07
+# TODO: GDB doesn't know to convert the string to a const char *, and
+# instead tries to use the string as a structure initializer.
 # 
 # gdb_test "print s == \"I am a short stringand now a longer string\"" \
-#     "\\$\[0-9\]+ = "true"
+#     "\\$\[0-9\]+ = true"
 
 gdb_test "print (const char *) s.substr(0,4)"	"\\$\[0-9\]+ = $hex \"I am\""
 gdb_test "print (const char *) (s=s.substr(0,4))" \


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

* Re: [commit] Fix a C++ segfault
  2006-07-20 22:54 [commit] Fix a C++ segfault Daniel Jacobowitz
@ 2006-07-21  0:28 ` Joel Brobecker
  2006-07-21  0:40   ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Joel Brobecker @ 2006-07-21  0:28 UTC (permalink / raw)
  To: gdb-patches

Hello Daniel,

> 2006-07-20  Daniel Jacobowitz  <dan@codesourcery.com>
> 
> 	* eval.c (evaluate_struct_tuple): Skip static fields.

I don't know C++ too much - how often is this likely to occur?
Would this be a safe patch for the branch?

Thanks!

> Index: eval.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/eval.c,v
> retrieving revision 1.61
> diff -u -p -r1.61 eval.c
> --- eval.c	18 Feb 2006 20:47:54 -0000	1.61
> +++ eval.c	20 Jul 2006 22:36:01 -0000
> @@ -283,6 +283,10 @@ evaluate_struct_tuple (struct value *str
>  	      if (variantno < 0)
>  		{
>  		  fieldno++;
> +		  /* Skip static fields.  */
> +		  while (fieldno < TYPE_NFIELDS (struct_type)
> +			 && TYPE_FIELD_STATIC_KIND (struct_type, fieldno))
> +		    fieldno++;
>  		  subfieldno = fieldno;
>  		  if (fieldno >= TYPE_NFIELDS (struct_type))
>  		    error (_("too many initializers"));

-- 
Joel


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

* Re: [commit] Fix a C++ segfault
  2006-07-21  0:28 ` Joel Brobecker
@ 2006-07-21  0:40   ` Daniel Jacobowitz
  2006-07-21  0:43     ` Joel Brobecker
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2006-07-21  0:40 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Thu, Jul 20, 2006 at 05:27:57PM -0700, Joel Brobecker wrote:
> Hello Daniel,
> 
> > 2006-07-20  Daniel Jacobowitz  <dan@codesourcery.com>
> > 
> > 	* eval.c (evaluate_struct_tuple): Skip static fields.
> 
> I don't know C++ too much - how often is this likely to occur?
> Would this be a safe patch for the branch?

Safe, but not particularly relevant.  None of this code has been used
in years, it's quite clear - in fact 80% of that function is devoted to
Chill support.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [commit] Fix a C++ segfault
  2006-07-21  0:40   ` Daniel Jacobowitz
@ 2006-07-21  0:43     ` Joel Brobecker
  0 siblings, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2006-07-21  0:43 UTC (permalink / raw)
  To: gdb-patches

> > > 2006-07-20  Daniel Jacobowitz  <dan@codesourcery.com>
> > > 
> > > 	* eval.c (evaluate_struct_tuple): Skip static fields.
> > 
> > I don't know C++ too much - how often is this likely to occur?
> > Would this be a safe patch for the branch?
> 
> Safe, but not particularly relevant.  None of this code has been used
> in years, it's quite clear - in fact 80% of that function is devoted to
> Chill support.

OK, so I won't bother putting it in the branch.

Thanks!
-- 
Joel


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

end of thread, other threads:[~2006-07-21  0:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-20 22:54 [commit] Fix a C++ segfault Daniel Jacobowitz
2006-07-21  0:28 ` Joel Brobecker
2006-07-21  0:40   ` Daniel Jacobowitz
2006-07-21  0:43     ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox