* [PATCH] c_value_print: Revert 'val' to a reference for TYPE_CODE_STRUCT
@ 2016-04-26 21:48 Martin Galvan
2016-04-27 10:01 ` Pedro Alves
0 siblings, 1 reply; 5+ messages in thread
From: Martin Galvan @ 2016-04-26 21:48 UTC (permalink / raw)
To: gdb-patches, palves, tom, daniel.gutson
Currently c_value_print will turn struct reference values into pointers before doing
a set of RTTI checks. This was introduced as a fix to PR c++/15401. If there's RTTI
the pointer will be adjusted and converted back to a reference. However, if there's
no RTTI the value will still be treated as a pointer during the remainder of the function.
This patch moves the conversion down so that it's always performed when needed.
I have write access and copyright assignment. Ok to commit?
gdb/ChangeLog:
2016-04-26 Martin Galvan <martin.galvan@tallertechnologies.com>
* c-valprint.c (c_value_print): Always convert val back to reference
type if we converted it to a pointer type.
---
gdb/c-valprint.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 62552ec..e1da3d5 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -611,7 +611,7 @@ c_value_print (struct value *val, struct ui_file *stream,
fprintf_filtered (stream, "(");
if (value_entirely_available (val))
- {
+ {
real_type = value_rtti_indirect_type (val, &full, &top,
&using_enc);
if (real_type)
@@ -623,18 +623,19 @@ c_value_print (struct value *val, struct ui_file *stream,
val = value_from_pointer (real_type,
value_as_address (val) - top);
- if (is_ref)
- {
- val = value_ref (value_ind (val));
- type = value_type (val);
- }
-
/* Note: When we look up RTTI entries, we don't get
any information on const or volatile
attributes. */
}
}
- type_print (type, "", stream, -1);
+
+ if (is_ref)
+ {
+ val = value_ref (value_ind (val));
+ type = value_type (val);
+ }
+
+ type_print (type, "", stream, -1);
fprintf_filtered (stream, ") ");
val_type = type;
}
--
2.8.1
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] c_value_print: Revert 'val' to a reference for TYPE_CODE_STRUCT
2016-04-26 21:48 [PATCH] c_value_print: Revert 'val' to a reference for TYPE_CODE_STRUCT Martin Galvan
@ 2016-04-27 10:01 ` Pedro Alves
2016-04-27 13:22 ` Martin Galvan
0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2016-04-27 10:01 UTC (permalink / raw)
To: Martin Galvan, gdb-patches, tom, daniel.gutson
On 04/26/2016 10:48 PM, Martin Galvan wrote:
> Currently c_value_print will turn struct reference values into pointers before doing
> a set of RTTI checks. This was introduced as a fix to PR c++/15401. If there's RTTI
> the pointer will be adjusted and converted back to a reference. However, if there's
> no RTTI the value will still be treated as a pointer during the remainder of the function.
> This patch moves the conversion down so that it's always performed when needed.
What's the motivation behind this? Does it change anything user visible?
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] c_value_print: Revert 'val' to a reference for TYPE_CODE_STRUCT
2016-04-27 10:01 ` Pedro Alves
@ 2016-04-27 13:22 ` Martin Galvan
2016-04-27 13:39 ` Pedro Alves
0 siblings, 1 reply; 5+ messages in thread
From: Martin Galvan @ 2016-04-27 13:22 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Tom Tromey, Daniel Gutson
On Wed, Apr 27, 2016 at 7:01 AM, Pedro Alves <palves@redhat.com> wrote:
> What's the motivation behind this? Does it change anything user visible?
AFAIK not directly, but I'm going to need it for the synthetic reference bug
fix. Since this is an isolated change I thought I could send it for
review now.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] c_value_print: Revert 'val' to a reference for TYPE_CODE_STRUCT
2016-04-27 13:22 ` Martin Galvan
@ 2016-04-27 13:39 ` Pedro Alves
2016-04-27 15:10 ` Martin Galvan
0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2016-04-27 13:39 UTC (permalink / raw)
To: Martin Galvan; +Cc: gdb-patches, Tom Tromey, Daniel Gutson
On 04/27/2016 02:21 PM, Martin Galvan wrote:
> On Wed, Apr 27, 2016 at 7:01 AM, Pedro Alves <palves@redhat.com> wrote:
>> What's the motivation behind this? Does it change anything user visible?
>
> AFAIK not directly, but I'm going to need it for the synthetic reference bug
> fix.
I see.
> Since this is an isolated change I thought I could send it for
> review now.
Since you didn't mention whether the change had any user-visible
impact, I was left wondering if we could add a testcase to
the testsuite that exposes the need for the change. From the original
log it kind of sounded like it would be possible.
It's better to be explicit in such cases, and say something like,
"this has no effect currently, so can be seen as a small code
cleanup, but once we do X, we'll print the wrong thing", or some such,
and mention that this causes no testsuite regressions, in the
email/commit log.
The code change is OK.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] c_value_print: Revert 'val' to a reference for TYPE_CODE_STRUCT
2016-04-27 13:39 ` Pedro Alves
@ 2016-04-27 15:10 ` Martin Galvan
0 siblings, 0 replies; 5+ messages in thread
From: Martin Galvan @ 2016-04-27 15:10 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Tom Tromey, Daniel Gutson
On Wed, Apr 27, 2016 at 10:39 AM, Pedro Alves <palves@redhat.com> wrote:
> It's better to be explicit in such cases, and say something like,
> "this has no effect currently, so can be seen as a small code
> cleanup, but once we do X, we'll print the wrong thing", or some such,
> and mention that this causes no testsuite regressions, in the
> email/commit log.
Indeed, you're right. I mentioned it in the commit log. Here's what I committed:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git&a=commit&h=476350ba4800f1144b125f6511a5e25b223cc90b
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-04-27 15:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-26 21:48 [PATCH] c_value_print: Revert 'val' to a reference for TYPE_CODE_STRUCT Martin Galvan
2016-04-27 10:01 ` Pedro Alves
2016-04-27 13:22 ` Martin Galvan
2016-04-27 13:39 ` Pedro Alves
2016-04-27 15:10 ` Martin Galvan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox