From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: <gdb-patches@sourceware.org>
Subject: [RFC] examine for TYPE_CODE_REF in pascal language PR 11349
Date: Fri, 30 Apr 2010 16:19:00 -0000 [thread overview]
Message-ID: <002a01cae880$ef397ae0$cdac70a0$@muller@ics-cnrs.unistra.fr> (raw)
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' && */
next reply other threads:[~2010-04-30 16:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-30 16:19 Pierre Muller [this message]
[not found] <17731.9300863475$1272644394@news.gmane.org>
2010-04-30 16:59 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='002a01cae880$ef397ae0$cdac70a0$@muller@ics-cnrs.unistra.fr' \
--to=pierre.muller@ics-cnrs.unistra.fr \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).