Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Peng Yu via Gdb <gdb@sourceware.org>
To: Pedro Alves <pedro@palves.net>
Cc: gdb@sourceware.org
Subject: Re: How to display instructions around the current instuction?
Date: Thu, 28 Jan 2021 19:58:11 -0600	[thread overview]
Message-ID: <CABrM6w=40RLHFwoxMquB-iF=c5S3qxa43H9_vrnyq41tjgj_HQ@mail.gmail.com> (raw)
In-Reply-To: <8ff04714-9feb-d13a-98e3-cede442e0eb8@palves.net>

On 1/28/21, Pedro Alves <pedro@palves.net> wrote:
>
> On 27/01/21 23:12, Peng Yu via Gdb wrote:
>> Hi,
>>
>> The following command will disply instructions below the current
>> instructions. Is there a way to display around the current instruction
>> (e.g., 5 instructions above and 5 instructions below)?
>>
>> display/10i $rip
>>
>
> From gdb/NEWS:
>
> ~~~~
> *** Changes in GDB 7.12
>
> * GDB now supports a negative repeat count in the 'x' command to examine
>   memory backward from the given address.  For example:
>
> ...
>     (gdb) x/-5i 0x0000000000400580
>        0x40056a <main(int, char**)+8>:      mov    %edi,-0x4(%rbp)
>        0x40056d <main(int, char**)+11>:     mov    %rsi,-0x10(%rbp)
>        0x400571 <main(int, char**)+15>:     mov    $0x40061c,%esi
>        0x400576 <main(int, char**)+20>:     mov    $0x2a,%edi
>        0x40057b <main(int, char**)+25>:
>         callq  0x400536 <Func1(int, char const*)>
> ~~~~

Is there a documentation problem in gdb regarding this feature. I
don't see this feature is documented.

$ gdb --version
GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

(gdb) help display
Print value of expression EXP each time the program stops.
Usage: display[/FMT] EXP
/FMT may be used before EXP as in the "print" command.
/FMT "i" or "s" or including a size-letter is allowed,
as in the "x" command, and then EXP is used to get the address to examine
and examining is done as in the "x" command.

With no argument, display all currently requested auto-display expressions.
Use "undisplay" to cancel display requests previously made.
(gdb) help print
...
EXP may be preceded with /FMT, where FMT is a format letter
but no count or size letter (see "x" command).

> There's also this:
>
> ~~~~
> (gdb) help set disassemble-next-line
> Set whether to disassemble next source line or insn when execution stops.
> If ON, GDB will display disassembly of the next source line, in addition
> to displaying the source line itself.  If the next source line cannot
> be displayed (e.g., source is unavailable or there's no line info), GDB
> will display disassembly of next instruction instead of showing the
> source line.
> If AUTO, display disassembly of next instruction only if the source line
> cannot be displayed.
> If OFF (which is the default), never display the disassembly of the next
> source line.
> (gdb)
> ~~~~
>


-- 
Regards,
Peng

  reply	other threads:[~2021-01-29  1:58 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27 23:12 Peng Yu via Gdb
2021-01-28  8:48 ` Andreas Schwab
2021-01-28 17:08   ` Peng Yu via Gdb
2021-01-28 18:44     ` Andreas Schwab
2021-01-29 17:38       ` Tavis Ormandy via Gdb
2021-01-28  9:19 ` Stefan Puiu via Gdb
2021-01-28 17:06   ` Peng Yu via Gdb
2021-01-28 17:26     ` Eli Zaretskii via Gdb
2021-01-28 17:37       ` Peng Yu via Gdb
2021-01-28 17:41         ` Christian Biesinger via Gdb
2021-01-29  2:07           ` Peng Yu via Gdb
2021-01-29  2:22             ` Sterling Augustine via Gdb
2021-01-29  2:32               ` Peng Yu via Gdb
2021-01-29  2:47                 ` Sterling Augustine via Gdb
2021-01-28 17:57         ` Eli Zaretskii via Gdb
2021-01-28 18:00     ` Stefan Puiu via Gdb
2021-01-29  2:15       ` Peng Yu via Gdb
2021-01-28 13:11 ` Christian Biesinger via Gdb
2021-01-28 16:50   ` Peng Yu via Gdb
2021-01-28 16:53     ` Christian Biesinger via Gdb
2021-01-28 17:16       ` Peng Yu via Gdb
2021-01-28 17:16         ` Christian Biesinger via Gdb
2021-01-28 17:00     ` Sterling Augustine via Gdb
     [not found]       ` <CAGOmfbFh+6AJZFsDP8nFH1bs6kntC4khO+YmPkn3LUfcLAspZw@mail.gmail.com>
2021-01-28 17:45         ` Peng Yu via Gdb
2021-01-28 18:27 ` Pedro Alves
2021-01-29  1:58   ` Peng Yu via Gdb [this message]
2021-01-29  7:18     ` Eli Zaretskii via Gdb

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='CABrM6w=40RLHFwoxMquB-iF=c5S3qxa43H9_vrnyq41tjgj_HQ@mail.gmail.com' \
    --to=gdb@sourceware.org \
    --cc=pedro@palves.net \
    --cc=pengyu.ut@gmail.com \
    /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