* [RFC] examine for TYPE_CODE_REF in pascal language PR 11349
@ 2010-04-30 16:19 Pierre Muller
0 siblings, 0 replies; 2+ messages in thread
From: Pierre Muller @ 2010-04-30 16:19 UTC (permalink / raw)
To: gdb-patches
Trying to fix bug report PR 11349,
http://sourceware.org/bugzilla/show_bug.cgi?id=11349
I finally found this:
-inside x_command, a TYPE_CODE_REF generates a call
to value_ind, but this generates possibly several dereferencing
if the target type is also a pointer.
In Free Pascal, with dwarf debug format,
variables passed as 'var' are considered as TYPE_CODE_REF.
if the variable itself is an ansistring,
this type is simply a type pointing to a CHAR.
the function DOIT has one parameter 'by var' called S
of type ANSISTRING.
If I try to examine as a string this variable
(gdb) x /s S
as S type is a TYPE_CODE_REF, value_ind is called,
but this dereferences the type twice so that we end up with a
single CHAR value:
hence the error
0x74: <Address 0x74 out of bounds>
If I replace value_ind by coerce_ref, everything
works as I want it for pascal, but I was wandering if
this is not also what other languages would expect.
(gdb) x /s S
0x408094 <$TEST_GDB_BUG_11349$_Ld3>: 'test'
I do not know what is the expectation for C language
here, and I don't even know how to generate code that
has variables of type TYPE_CODE_REF from C source.
Should this change be extended to other languages
or to all languages?
Pierre Muller
Pascal language support maintainer for GDB
2010-04-30 Pierre Muller <muller@ics.u-strasbg.fr>
* printcmd.c (x_command): Only dereference once implicitly for
TYPE_CODE_REF type for pascal language.
Index: src/gdb/printcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/printcmd.c,v
retrieving revision 1.176
diff -u -p -r1.176 printcmd.c
--- src/gdb/printcmd.c 22 Apr 2010 23:15:41 -0000 1.176
+++ src/gdb/printcmd.c 30 Apr 2010 13:12:45 -0000
@@ -1420,7 +1420,12 @@ x_command (char *exp, int from_tty)
old_chain = make_cleanup (free_current_contents, &expr);
val = evaluate_expression (expr);
if (TYPE_CODE (value_type (val)) == TYPE_CODE_REF)
- val = value_ind (val);
+ {
+ if (current_language->la_language == language_pascal)
+ val = coerce_ref (val);
+ else
+ val = value_ind (val);
+ }
/* In rvalue contexts, such as this, functions are coerced into
pointers to functions. This makes "x/i main" work. */
if (/* last_format == 'i' && */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC] examine for TYPE_CODE_REF in pascal language PR 11349
[not found] <17731.9300863475$1272644394@news.gmane.org>
@ 2010-04-30 16:59 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2010-04-30 16:59 UTC (permalink / raw)
To: Pierre Muller; +Cc: gdb-patches
>>>>> "Pierre" == Pierre Muller <pierre.muller@ics-cnrs.unistra.fr> writes:
Pierre> -inside x_command, a TYPE_CODE_REF generates a call
Pierre> to value_ind, but this generates possibly several dereferencing
Pierre> if the target type is also a pointer.
Pierre> I do not know what is the expectation for C language
Pierre> here, and I don't even know how to generate code that
Pierre> has variables of type TYPE_CODE_REF from C source.
You need C++ to make a TYPE_CODE_REF. It corresponds to a C++
reference.
Pierre> Should this change be extended to other languages
Pierre> or to all languages?
I think coerce_ref is the right thing to do here for C++. If an
expression evaluates to a reference to a pointer, I would expect the
reference to be ignored and the referred-to pointer to be used instead.
However, the fact that the code is explicitly written to check
TYPE_CODE_REF and use value_ind gives me pause. If you change it to
unconditionally use coerce_ref, do any tests fail?
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-04-30 16:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-30 16:19 [RFC] examine for TYPE_CODE_REF in pascal language PR 11349 Pierre Muller
[not found] <17731.9300863475$1272644394@news.gmane.org>
2010-04-30 16:59 ` Tom 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).