public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug mi/9752] New: MI -data-evaluate-expression prints optimized-out variable value as 0x0
@ 2009-01-16 21:04 rschooler at tilera dot com
  2009-01-16 22:17 ` [Bug mi/9752] " nickrob at snap dot net dot nz
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: rschooler at tilera dot com @ 2009-01-16 21:04 UTC (permalink / raw)
  To: gdb-prs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]

Eclipse/CDT, when hovering over a variable in a source pane, will display 0x0 as
the value for optimized-out variables that don't show up in the Variables pane.

This appears to be an underlying GDB problem with the MI interface it uses to
talk to external front ends.  Here's a transcript running “gdb -interpreter=mi”,
and typing a mix of normal and MI commands at it:

(gdb) p ecs

&"p ecs\n"

~"$1 = <value optimized out>\n"

^done

(gdb) -data-evaluate-expression ecs

^done,value="0x0"

So the normal command-line command does the right thing, but the MI version
does not.

This appears to be because the command-line path calls print_formatted(), which
calls value_print(), which calls value_check_printable(), which checks for
value_optimized_out().

The MI path calls val_print() directly, which doesn't check.

-- 
           Summary: MI -data-evaluate-expression prints optimized-out
                    variable value as 0x0
           Product: gdb
           Version: 6.8
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: mi
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: rschooler at tilera dot com
                CC: gdb-prs at sourceware dot org


http://sourceware.org/bugzilla/show_bug.cgi?id=9752

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug mi/9752] MI -data-evaluate-expression prints optimized-out variable value as 0x0
  2009-01-16 21:04 [Bug mi/9752] New: MI -data-evaluate-expression prints optimized-out variable value as 0x0 rschooler at tilera dot com
@ 2009-01-16 22:17 ` nickrob at snap dot net dot nz
  2009-01-19 18:40 ` rschooler at tilera dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: nickrob at snap dot net dot nz @ 2009-01-16 22:17 UTC (permalink / raw)
  To: gdb-prs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1784 bytes --]


------- Additional Comments From nickrob at snap dot net dot nz  2009-01-16 22:17 -------
Subject: Re:  New: MI -data-evaluate-expression prints optimized-out variable value as 0x0

 > Eclipse/CDT, when hovering over a variable in a source pane, will display
 > 0x0 as the value for optimized-out variables that don't show up in the
 > Variables pane.
 > 
 > This appears to be an underlying GDB problem with the MI interface it uses
 > to talk to external front ends.  Here's a transcript running “gdb
 > -interpreter=mi”, and typing a mix of normal and MI commands at it:
 > 
 > (gdb) p ecs
 > 
 > &"p ecs\n"
 > 
 > ~"$1 = <value optimized out>\n"
 > 
 > ^done
 > 
 > (gdb) -data-evaluate-expression ecs
 > 
 > ^done,value="0x0"

Does this change DTRT?

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


Index: mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.142
diff -p -u -p -r1.142 mi-main.c
--- mi-main.c	14 Jan 2009 15:21:55 -0000	1.142
+++ mi-main.c	16 Jan 2009 22:16:03 -0000
@@ -776,10 +776,7 @@ mi_cmd_data_evaluate_expression (char *c
   /* Print the result of the expression evaluation.  */
   get_user_print_options (&opts);
   opts.deref_ref = 0;
-  val_print (value_type (val), value_contents (val),
-	     value_embedded_offset (val), VALUE_ADDRESS (val),
-	     stb->stream, 0, &opts, current_language);
-
+  common_val_print (val, stb->stream, 0, &opts, current_language);
   ui_out_field_stream (uiout, "value", stb);
   ui_out_stream_delete (stb);


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=9752

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug mi/9752] MI -data-evaluate-expression prints optimized-out variable value as 0x0
  2009-01-16 21:04 [Bug mi/9752] New: MI -data-evaluate-expression prints optimized-out variable value as 0x0 rschooler at tilera dot com
  2009-01-16 22:17 ` [Bug mi/9752] " nickrob at snap dot net dot nz
@ 2009-01-19 18:40 ` rschooler at tilera dot com
  2009-01-19 20:29 ` nickrob at snap dot net dot nz
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rschooler at tilera dot com @ 2009-01-19 18:40 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From rschooler at tilera dot com  2009-01-19 18:40 -------
Subject: RE:  MI -data-evaluate-expression prints optimized-out variable value as 0x0

Yes and no.  Your source base seems to have changed from the 6.8 we
started with.  My diff is:

==== //tilera/main/tools/gnu/gdb/mi/mi-main.c#3 -
/u/rschooler/p4/tools/gnu/gdb/mi/mi-main.c ====
@@ -670,9 +670,7 @@
   val = evaluate_expression (expr);
 
   /* Print the result of the expression evaluation.  */
-  val_print (value_type (val), value_contents (val),
-	     value_embedded_offset (val), VALUE_ADDRESS (val),
-	     stb->stream, 0, 0, 0, 0);
+  common_val_print (val, stb->stream, 0, 0, 0, 0);
 
   ui_out_field_stream (uiout, "value", stb);
   ui_out_stream_delete (stb);

This worked for me.  Should I go with this change now, or wait for some
more official patch, with regression testing, etc.?

Thanks,	-- Richard

Richard Schooler
VP Software Engineering
Tilera Corp.
1900 West Park Drive, Westborough MA 01581
Tel.: +1 (508) 616 9300 x236
Cell: +1 (617) 233 8425
 

> -----Original Message-----
> From: nickrob at snap dot net dot nz [mailto:sourceware-
> bugzilla@sourceware.org]
> Sent: Friday, January 16, 2009 5:18 PM
> To: Richard Schooler
> Subject: [Bug mi/9752] MI -data-evaluate-expression prints
optimized-out
> variable value as 0x0
> 
> 
> ------- Additional Comments From nickrob at snap dot net dot nz
2009-01-
> 16 22:17 -------
> Subject: Re:  New: MI -data-evaluate-expression prints optimized-out
> variable value as 0x0
> 
>  > Eclipse/CDT, when hovering over a variable in a source pane, will
> display
>  > 0x0 as the value for optimized-out variables that don't show up in
the
>  > Variables pane.
>  >
>  > This appears to be an underlying GDB problem with the MI interface
it
> uses
>  > to talk to external front ends.  Here's a transcript running "gdb
>  > -interpreter=mi", and typing a mix of normal and MI commands at it:
>  >
>  > (gdb) p ecs
>  >
>  > &"p ecs\n"
>  >
>  > ~"$1 = <value optimized out>\n"
>  >
>  > ^done
>  >
>  > (gdb) -data-evaluate-expression ecs
>  >
>  > ^done,value="0x0"
> 
> Does this change DTRT?
> 
> --
> Nick
> http://www.inet.net.nz/~nickrob
> 
> 
> Index: mi-main.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
> retrieving revision 1.142
> diff -p -u -p -r1.142 mi-main.c
> --- mi-main.c	14 Jan 2009 15:21:55 -0000	1.142
> +++ mi-main.c	16 Jan 2009 22:16:03 -0000
> @@ -776,10 +776,7 @@ mi_cmd_data_evaluate_expression (char *c
>    /* Print the result of the expression evaluation.  */
>    get_user_print_options (&opts);
>    opts.deref_ref = 0;
> -  val_print (value_type (val), value_contents (val),
> -	     value_embedded_offset (val), VALUE_ADDRESS (val),
> -	     stb->stream, 0, &opts, current_language);
> -
> +  common_val_print (val, stb->stream, 0, &opts, current_language);
>    ui_out_field_stream (uiout, "value", stb);
>    ui_out_stream_delete (stb);
> 
> 
> --
> 
> 
> http://sourceware.org/bugzilla/show_bug.cgi?id=9752
> 
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=9752

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug mi/9752] MI -data-evaluate-expression prints optimized-out variable value as 0x0
  2009-01-16 21:04 [Bug mi/9752] New: MI -data-evaluate-expression prints optimized-out variable value as 0x0 rschooler at tilera dot com
  2009-01-16 22:17 ` [Bug mi/9752] " nickrob at snap dot net dot nz
  2009-01-19 18:40 ` rschooler at tilera dot com
@ 2009-01-19 20:29 ` nickrob at snap dot net dot nz
  2009-04-12 16:54 ` tromey at redhat dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: nickrob at snap dot net dot nz @ 2009-01-19 20:29 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From nickrob at snap dot net dot nz  2009-01-19 20:29 -------
Subject: RE:  MI -data-evaluate-expression prints optimized-out variable value as 0x0

Richard Schooler writes:
 > Yes and no.  Your source base seems to have changed from the 6.8 we
 > started with.

I've started with gdb in current CVS.

 >                  My diff is:
 >
 > ==== //tilera/main/tools/gnu/gdb/mi/mi-main.c#3 -
 > /u/rschooler/p4/tools/gnu/gdb/mi/mi-main.c ====
 > @@ -670,9 +670,7 @@
 >    val = evaluate_expression (expr);
 >  
 >    /* Print the result of the expression evaluation.  */
 > -  val_print (value_type (val), value_contents (val),
 > -	     value_embedded_offset (val), VALUE_ADDRESS (val),
 > -	     stb->stream, 0, 0, 0, 0);
 > +  common_val_print (val, stb->stream, 0, 0, 0, 0);
 >  
 >    ui_out_field_stream (uiout, "value", stb);
 >    ui_out_stream_delete (stb);
 > 
 > This worked for me.  Should I go with this change now, or wait for some
 > more official patch, with regression testing, etc.?

Well, there probably won't be a backport to 6.8, so if that's what you're
using, you need to make your own patch.  For my patch to get into GDB for
the next release (7.0), it needs to be approved by the MI or a global
maintainer.




-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=9752

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug mi/9752] MI -data-evaluate-expression prints optimized-out variable value as 0x0
  2009-01-16 21:04 [Bug mi/9752] New: MI -data-evaluate-expression prints optimized-out variable value as 0x0 rschooler at tilera dot com
                   ` (2 preceding siblings ...)
  2009-01-19 20:29 ` nickrob at snap dot net dot nz
@ 2009-04-12 16:54 ` tromey at redhat dot com
  2009-04-13  2:23 ` nickrob at snap dot net dot nz
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tromey at redhat dot com @ 2009-04-12 16:54 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From tromey at redhat dot com  2009-04-12 16:54 -------
Is this patch still pending?

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=9752

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug mi/9752] MI -data-evaluate-expression prints optimized-out variable value as 0x0
  2009-01-16 21:04 [Bug mi/9752] New: MI -data-evaluate-expression prints optimized-out variable value as 0x0 rschooler at tilera dot com
                   ` (3 preceding siblings ...)
  2009-04-12 16:54 ` tromey at redhat dot com
@ 2009-04-13  2:23 ` nickrob at snap dot net dot nz
  2009-04-13 21:58 ` tromey at redhat dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: nickrob at snap dot net dot nz @ 2009-04-13  2:23 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From nickrob at snap dot net dot nz  2009-04-13 02:23 -------
Subject:  MI -data-evaluate-expression prints optimized-out variable value as 0x0

 > Is this patch still pending?

I probably should have confirmed the bug and changed the status to NEW but pending is not listed
as a status.  It's not been resolved in bugzilla and it's quite easy to see that it's not been
fixed: compile a simple program with function calls with -O (or -O2), stop in main using GDB
with MI and you should see something like:

-stack-list-locals 1
^done,locals=[{name="n1",value="0"},{name="n2",value="4195696"},{name="n3",value="0"},{name="ptr",value="<value optimized out>"},{name="a",value="<value optimized out>"}]
(gdb) 
-data-evaluate-expression ptr
^done,value="0x0"
(gdb) 

where (in this case) ptr and a are the arguments of function calls.



-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=9752

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug mi/9752] MI -data-evaluate-expression prints optimized-out variable value as 0x0
  2009-01-16 21:04 [Bug mi/9752] New: MI -data-evaluate-expression prints optimized-out variable value as 0x0 rschooler at tilera dot com
                   ` (4 preceding siblings ...)
  2009-04-13  2:23 ` nickrob at snap dot net dot nz
@ 2009-04-13 21:58 ` tromey at redhat dot com
  2009-04-14  6:50 ` nickrob at snap dot net dot nz
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tromey at redhat dot com @ 2009-04-13 21:58 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From tromey at redhat dot com  2009-04-13 21:58 -------
Ok, thanks.
I didn't see this on gdb-patches.
Anyway, it is ok with a test case.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=9752

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug mi/9752] MI -data-evaluate-expression prints optimized-out variable value as 0x0
  2009-01-16 21:04 [Bug mi/9752] New: MI -data-evaluate-expression prints optimized-out variable value as 0x0 rschooler at tilera dot com
                   ` (5 preceding siblings ...)
  2009-04-13 21:58 ` tromey at redhat dot com
@ 2009-04-14  6:50 ` nickrob at snap dot net dot nz
  2009-04-14 16:20 ` tromey at redhat dot com
  2009-04-15  6:54 ` nickrob at snap dot net dot nz
  8 siblings, 0 replies; 10+ messages in thread
From: nickrob at snap dot net dot nz @ 2009-04-14  6:50 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From nickrob at snap dot net dot nz  2009-04-14 06:50 -------
Subject:  MI -data-evaluate-expression prints optimized-out variable value as 0x0

 > Ok, thanks.
 > I didn't see this on gdb-patches.
 > Anyway, it is ok with a test case.

This patch just replaces the call to val_print with one to common_val_print.
There's no test for the MI command -stack-list-locals when values are
optimized out and presumably existing tests will pick up any regressions for
this circumstance.  So, what would the be the purpose of a test case in this
particular instance?



-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=9752

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug mi/9752] MI -data-evaluate-expression prints optimized-out variable value as 0x0
  2009-01-16 21:04 [Bug mi/9752] New: MI -data-evaluate-expression prints optimized-out variable value as 0x0 rschooler at tilera dot com
                   ` (6 preceding siblings ...)
  2009-04-14  6:50 ` nickrob at snap dot net dot nz
@ 2009-04-14 16:20 ` tromey at redhat dot com
  2009-04-15  6:54 ` nickrob at snap dot net dot nz
  8 siblings, 0 replies; 10+ messages in thread
From: tromey at redhat dot com @ 2009-04-14 16:20 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From tromey at redhat dot com  2009-04-14 16:20 -------
The purpose of a test in this case is to prevent regressions
in the future.


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=9752

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug mi/9752] MI -data-evaluate-expression prints optimized-out variable value as 0x0
  2009-01-16 21:04 [Bug mi/9752] New: MI -data-evaluate-expression prints optimized-out variable value as 0x0 rschooler at tilera dot com
                   ` (7 preceding siblings ...)
  2009-04-14 16:20 ` tromey at redhat dot com
@ 2009-04-15  6:54 ` nickrob at snap dot net dot nz
  8 siblings, 0 replies; 10+ messages in thread
From: nickrob at snap dot net dot nz @ 2009-04-15  6:54 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From nickrob at snap dot net dot nz  2009-04-15 06:54 -------
Subject:  MI -data-evaluate-expression prints optimized-out variable value as 0x0

 > The purpose of a test in this case is to prevent regressions
 > in the future.

Apart from the fact that a test here would involve far more work than the patch
itself (as it probably needs a separate executable compiled with
optimisation), every test adds to the time it takes the testsuite to run.  I
have written many test cases in the past, but I can't see the point here,
so I don't plan to write one.



-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=9752

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

end of thread, other threads:[~2009-04-15  6:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-16 21:04 [Bug mi/9752] New: MI -data-evaluate-expression prints optimized-out variable value as 0x0 rschooler at tilera dot com
2009-01-16 22:17 ` [Bug mi/9752] " nickrob at snap dot net dot nz
2009-01-19 18:40 ` rschooler at tilera dot com
2009-01-19 20:29 ` nickrob at snap dot net dot nz
2009-04-12 16:54 ` tromey at redhat dot com
2009-04-13  2:23 ` nickrob at snap dot net dot nz
2009-04-13 21:58 ` tromey at redhat dot com
2009-04-14  6:50 ` nickrob at snap dot net dot nz
2009-04-14 16:20 ` tromey at redhat dot com
2009-04-15  6:54 ` nickrob at snap dot net dot nz

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).