Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* MI failures related to string printing
@ 2007-01-12 10:52 Vladimir Prus
  2007-01-12 11:22 ` Mark Kettenis
  0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Prus @ 2007-01-12 10:52 UTC (permalink / raw)
  To: gdb


As I've reported before, I'm getting this failure:

FAIL: gdb.mi/mi-var-child.exp: update all vars psnp->next->next->long_ptr (and 2.long_ptr) changed

After investigation, it appears related to recent -var-update changes. The failing test
does:

mi_gdb_test "-var-update *" \
	"\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.next.next.long_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
	"update all vars psnp->next->next->long_ptr (and 2.long_ptr) changed"

It's the last check in mi-var-child.exp. The reply from gdb includes also:

	{name="psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr",in_scope="true",type_changed="false"}

and another similar thing. The problem is that test is written like this:

	  char a0, *a1, **a2, ***a3;

	  a0 = '0';
	  a1 = &a0;
	  a2 = &a1;
	  a3 = &a2;

There's a variable object correspoding to a1. When varobj_update tries to compare old
and new value of that varobj, it computes string value of a1. Unfortunately, a1 points to
a single character. There's no terminating zero character. So, the string value of a1 is 
essentially random, and -var-update randomly marks varobj as changed.

What do we do about it? At the very least, the test should be fixed. Is there anything smart
we can do here?

- Volodya




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

* Re: MI failures related to string printing
  2007-01-12 10:52 MI failures related to string printing Vladimir Prus
@ 2007-01-12 11:22 ` Mark Kettenis
  2007-01-12 12:11   ` Nick Roberts
  2007-01-12 12:30   ` Bob Rossi
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Kettenis @ 2007-01-12 11:22 UTC (permalink / raw)
  To: vladimir; +Cc: gdb

> From: Vladimir Prus <vladimir@codesourcery.com>
> Date: Fri, 12 Jan 2007 13:51:29 +0300
> 
> 
> As I've reported before, I'm getting this failure:
> 
> FAIL: gdb.mi/mi-var-child.exp: update all vars psnp->next->next->long_ptr (and 2.long_ptr) changed
> 
> After investigation, it appears related to recent -var-update changes. The failing test
> does:
> 
> mi_gdb_test "-var-update *" \
> 	"\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.next.next.long_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
> 	"update all vars psnp->next->next->long_ptr (and 2.long_ptr) changed"
> 
> It's the last check in mi-var-child.exp. The reply from gdb includes also:
> 
> 	{name="psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr",in_scope="true",type_changed="false"}
> 
> and another similar thing. The problem is that test is written like this:
> 
> 	  char a0, *a1, **a2, ***a3;
> 
> 	  a0 = '0';
> 	  a1 = &a0;
> 	  a2 = &a1;
> 	  a3 = &a2;
> 
> There's a variable object correspoding to a1. When varobj_update tries to compare old
> and new value of that varobj, it computes string value of a1. Unfortunately, a1 points to
> a single character. There's no terminating zero character. So, the string value of a1 is 
> essentially random, and -var-update randomly marks varobj as changed.
> 
> What do we do about it? At the very least, the test should be fixed. Is there anything smart
> we can do here?

I think the whole idea of doing string comparisons for C (or C++)
"char *" pointers is flawed.  There is no guarantee that a "char *"
actually points to a null-terminated as the test shows.  You should
not treat "char *" any different from other pointers like "int *", at
least not by default.  You could implement a way for the user to
specify that a "char *" is actually a pointer to a string instead of a
single character.  But otherwise I think the string comparison should
only do for languages that have a genuine string type, such as Pascal.

Mark




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

* Re: MI failures related to string printing
  2007-01-12 11:22 ` Mark Kettenis
@ 2007-01-12 12:11   ` Nick Roberts
  2007-01-12 12:30   ` Bob Rossi
  1 sibling, 0 replies; 4+ messages in thread
From: Nick Roberts @ 2007-01-12 12:11 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: vladimir, gdb

 > I think the whole idea of doing string comparisons for C (or C++)
 > "char *" pointers is flawed.  There is no guarantee that a "char *"
 > actually points to a null-terminated as the test shows.  You should
 > not treat "char *" any different from other pointers like "int *", at
 > least not by default.  You could implement a way for the user to
 > specify that a "char *" is actually a pointer to a string instead of a
 > single character.  But otherwise I think the string comparison should
 > only do for languages that have a genuine string type, such as Pascal.

It's unfortunate you didn't express this opinion earlier.  There are no
gauarantees but generally if you are watching a "char *" type it points to
something useful, or you learn something if it doesn't.  Without string
comparison you can't `watch' the contents of a string change.  I think it's
better to focus on such practical issues than pathological cases in the
testsuite.

-- 
Nick                                           http://www.inet.net.nz/~nickrob


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

* Re: MI failures related to string printing
  2007-01-12 11:22 ` Mark Kettenis
  2007-01-12 12:11   ` Nick Roberts
@ 2007-01-12 12:30   ` Bob Rossi
  1 sibling, 0 replies; 4+ messages in thread
From: Bob Rossi @ 2007-01-12 12:30 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: vladimir, gdb

On Fri, Jan 12, 2007 at 12:18:44PM +0100, Mark Kettenis wrote:
> I think the whole idea of doing string comparisons for C (or C++)
> "char *" pointers is flawed.  There is no guarantee that a "char *"
> actually points to a null-terminated as the test shows.  You should
> not treat "char *" any different from other pointers like "int *", at
> least not by default.  You could implement a way for the user to
> specify that a "char *" is actually a pointer to a string instead of a
> single character.  But otherwise I think the string comparison should
> only do for languages that have a genuine string type, such as Pascal.

GDB handles char*'s specially in the print command. There is an option
to tell it that the string shouldn't be displayed as null-terminated.

I think it's appropriate to handle the char* special as long as there is
an option not to do so.

Bob Rossi


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

end of thread, other threads:[~2007-01-12 12:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-12 10:52 MI failures related to string printing Vladimir Prus
2007-01-12 11:22 ` Mark Kettenis
2007-01-12 12:11   ` Nick Roberts
2007-01-12 12:30   ` Bob Rossi

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