Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Mark Kettenis <mark.kettenis@xs4all.nl>,
	aburgess@broadcom.com,        gdb-patches@sourceware.org
Subject: Re: [PATCH+DOC] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".
Date: Thu, 19 Sep 2013 16:58:00 -0000	[thread overview]
Message-ID: <523B2D39.8060303@redhat.com> (raw)
In-Reply-To: <83fvt1mems.fsf@gnu.org>

On 09/19/2013 08:53 AM, Eli Zaretskii wrote:
>> Date: Wed, 18 Sep 2013 22:47:24 +0200 (CEST)
>> From: Mark Kettenis <mark.kettenis@xs4all.nl>
>> CC: palves@redhat.com, aburgess@broadcom.com, gdb-patches@sourceware.org,
>>         mark.kettenis@xs4all.nl
>>
>>> Date: Wed, 18 Sep 2013 19:30:07 +0300
>>> From: Eli Zaretskii <eliz@gnu.org>
>>>
>>> Also, shouldn't we mention optimizations as (the main) reason for
>>> registers being unavailable?
>>
>> I don't consider optimisations as an important cause of registers not
>> being saved.
> 
> The question is: does it happen in practice?  If it does, I think we
> should mention that, because it's important to let the users know that
> recompiling without optimizations might remove this nuisance.

I think it's really independent of optimization.

Jan's comments at <https://sourceware.org/ml/gdb-patches/2012-08/msg00787.html>
help understand this.   Current/recent enough GCC doesn't mark variables/arguments
as being in call-clobbered registers in the ranges corresponding to function calls,
while older GCCs did.  Newer GCCs will just not say where the variable is, so GDB
will end up realizing the variable is optimized out.  In fact, if I build
an -O2 version of GDB, and do

 $ readelf --debug-dump=frames ./gdb | grep DW_CFA_undefined

nothing comes out.

Now, GDB itself could just assume that call-clobbered registers
are always <not saved> in frames other than the innermost, but
that'll be not very user friendly, I think.

Perhaps... we should completely toss out this patch, and go
the other way around.  When printing registers of an outer
frame, ignore DW_CFA_undefined, and read the registers
from the inner frame anyway...  IOW, define the values of
call-clobbered registers in outer frames as "the values the
registers would have if the inner frame returned _now_".
Mark, what do you think?
(I didn't try implementing that, but I think that'll just
mean ignoring the optimized_out flag when dumping registers
(but not when printing variables marked as living in "optimized
out" registers).

I wondered what would the "return" command do if forcing
a return to a function where we current show registers
as "<optimized out>/<not saved>", to see if that
would through a "value optimized out" error or some such.
It actually doesn't:

Breakpoint 2, stop_frame () at dw2-reg-undefined.c:22
22      in dw2-reg-undefined.c
(gdb) info registers
rax            0x0      0
rbx            0x0      0
rcx            0x400552 4195666
rdx            0x7fffffffdb18   140737488345880
rsi            0x7fffffffdb08   140737488345864
rdi            0x1      1
rbp            0x7fffffffda00   0x7fffffffda00
rsp            0x7fffffffda00   0x7fffffffda00
r8             0x323d7b1f40     215779843904
r9             0x323d00f310     215771837200
r10            0x7fffffffd880   140737488345216
r11            0x323d421640     215776106048
r12            0x400430 4195376
r13            0x7fffffffdb00   140737488345856
r14            0x0      0
r15            0x0      0
rip            0x400540 0x400540 <stop_frame+4>
eflags         0x246    [ PF ZF IF ]
cs             0x33     51
ss             0x2b     43
ds             0x0      0
es             0x0      0
fs             0x0      0
gs             0x0      0
(gdb) up
#1  0x0000000000400550 in first_frame () at dw2-reg-undefined.c:27
27      in dw2-reg-undefined.c
(gdb) info registers
rax            <optimized out>
rbx            <optimized out>
rcx            <optimized out>
rdx            <optimized out>
rsi            <optimized out>
rdi            <optimized out>
rbp            0x7fffffffda10   0x7fffffffda10
rsp            <optimized out>
r8             0x323d7b1f40     215779843904
r9             0x323d00f310     215771837200
r10            0x7fffffffd880   140737488345216
r11            0x323d421640     215776106048
r12            0x400430 4195376
r13            0x7fffffffdb00   140737488345856
r14            0x0      0
r15            0x0      0
rip            0x400550 0x400550 <first_frame+14>
eflags         0x246    [ PF ZF IF ]
cs             0x33     51
ss             0x2b     43
ds             0x0      0
es             0x0      0
fs             0x0      0
gs             0x0      0
(gdb) down
#0  stop_frame () at dw2-reg-undefined.c:22
22      in dw2-reg-undefined.c
(gdb) return
Make stop_frame return now? (y or n) y
#0  first_frame () at dw2-reg-undefined.c:28
28      in dw2-reg-undefined.c
(gdb) info registers
rax            0x0      0
rbx            0x0      0
rcx            0x400552 4195666
rdx            0x7fffffffdb18   140737488345880
rsi            0x7fffffffdb08   140737488345864
rdi            0x1      1
rbp            0x7fffffffda10   0x7fffffffda10
rsp            0x7fffffffda00   0x7fffffffda00
r8             0x323d7b1f40     215779843904
r9             0x323d00f310     215771837200
r10            0x7fffffffd880   140737488345216
r11            0x323d421640     215776106048
r12            0x400430 4195376
r13            0x7fffffffdb00   140737488345856
r14            0x0      0
r15            0x0      0
rip            0x400550 0x400550 <first_frame+14>
eflags         0x246    [ PF ZF IF ]
cs             0x33     51
ss             0x2b     43
ds             0x0      0
es             0x0      0
fs             0x0      0
gs             0x0      0
(gdb)

In case that isn't clear, GDB did fetch the values of
call-clobbered registers from the inner frame.  I didn't
check where/how that happens.

-- 
Pedro Alves


  reply	other threads:[~2013-09-19 16:58 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-06 13:09 [PATCH] Consistent display " Andrew Burgess
2013-08-06 13:18 ` Mark Kettenis
2013-08-06 13:49   ` Andrew Burgess
2013-08-06 15:41     ` Mark Kettenis
2013-08-06 16:02       ` Andrew Burgess
2013-08-06 18:39       ` Pedro Alves
2013-08-12 13:32         ` Andrew Burgess
2013-08-12 13:55           ` Pedro Alves
2013-08-12 14:01             ` Andrew Burgess
2013-08-12 20:01             ` Mark Kettenis
2013-08-13  8:27               ` Andrew Burgess
2013-08-16 18:41               ` Pedro Alves
2013-08-16 20:28                 ` Pedro Alves
2013-08-19 10:25                 ` Andrew Burgess
2013-09-05 16:29                   ` [PATCH] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>". (was: Re: [PATCH] Consistent display of "<optimized out>") Pedro Alves
2013-09-05 16:35                     ` [PATCH] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>" Andrew Burgess
2013-09-16 19:05                       ` Pedro Alves
2013-09-18 14:04                         ` Andrew Burgess
2013-09-18 15:54                           ` [PATCH+DOC] " Pedro Alves
2013-09-18 16:30                             ` Eli Zaretskii
2013-09-18 17:35                               ` Pedro Alves
2013-09-18 19:35                                 ` Eli Zaretskii
2013-09-18 20:47                               ` Mark Kettenis
2013-09-19  7:53                                 ` Eli Zaretskii
2013-09-19 16:58                                   ` Pedro Alves [this message]
2013-09-19 19:15                                     ` [PATCH] Always print call-clobbered registers in outer frames. (was: Re: [PATCH+DOC] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".) Pedro Alves
2013-09-19 19:35                                       ` Eli Zaretskii
2013-09-19 23:13                                       ` Doug Evans
2013-09-19 23:22                                       ` Doug Evans
2013-09-20 11:04                                       ` [PATCH] Always print call-clobbered registers in outer frames Andrew Burgess
2013-09-24 12:07                                         ` Pedro Alves
2013-09-24 12:56                                           ` Andrew Burgess
2013-09-24 13:43                                             ` Pedro Alves
2013-09-24 15:18                                               ` Andrew Burgess
2013-09-24 19:36                                                 ` Pedro Alves
2013-09-24 23:22                                                   ` Andrew Burgess
2013-10-02 16:05                                                     ` Pedro Alves
2013-10-02 19:07                                                       ` Doug Evans
2013-09-20 12:28                                       ` [PATCH] Always print call-clobbered registers in outer frames. (was: Re: [PATCH+DOC] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>".) Mark Kettenis
2013-09-24 12:06                                         ` [PATCH] Always print call-clobbered registers in outer frames Pedro Alves
2013-10-02 16:17                                     ` [PATCH+DOC] Print registers not saved in the frame as "<not saved>", instead of "<optimized out>" Pedro Alves
2013-09-18 16:30                             ` Andreas Schwab
2013-09-18 17:36                               ` Pedro Alves

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=523B2D39.8060303@redhat.com \
    --to=palves@redhat.com \
    --cc=aburgess@broadcom.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    /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