From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by sourceware.org (Postfix) with ESMTPS id 85B4F3854838 for ; Fri, 29 Jan 2021 01:58:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 85B4F3854838 Received: by mail-il1-x12c.google.com with SMTP id g7so6111752iln.2 for ; Thu, 28 Jan 2021 17:58:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0dGfOcxDFviRKdTSeJabQa0Dh3HkAv5hrBcwJ4EN36M=; b=RGJR/w6zTV1eDu6ivjz16P7HutadFix1/FW1jo/5Uf3tsYWASvFVYvOCWY5GGVrxBU kzliqdes1jt0cJ2Nq9KArF9qMxEzXZiqVcJOIa/fYA+a4QxlIfH1U7fffholRbwf0quq zdLqV7wdMpwjsMquXx7GQCJH5K5pZp/JJWRwZ5DDr+LLg0G7WCW29vWd2O46xeOET24y ARkXTGV8qF1C3OEac6a7mrWUBxgGxOH3kE1DJ65D493rP9OWFnz2NGXpMswMnJ0RKz32 pB9JlMWMikdJTBzIYBQOj5z/H+jya8rR7rHTIwGT999spMhWnydkJp1Vy2aN73l3eOUi tuYg== X-Gm-Message-State: AOAM531NUWOJQQI/bHHGVHrljBH/OsO1oOCxJ12sRsHdnnb5Vlu6kC5y I2SIiizVMFhEphpv2YLIgvW+l3XyYHRHP9QeJJDNM6SC3eU= X-Google-Smtp-Source: ABdhPJxXE0cLIp07avzuYP7yia8dfFQJMidNfnkF1haoesSY+x6rYewUQdNR2kTXN15d00sHrMtIhf7Jg99qMHAeHqY= X-Received: by 2002:a05:6e02:154d:: with SMTP id j13mr1948739ilu.153.1611885492027; Thu, 28 Jan 2021 17:58:12 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a6b:c88b:0:0:0:0:0 with HTTP; Thu, 28 Jan 2021 17:58:11 -0800 (PST) In-Reply-To: <8ff04714-9feb-d13a-98e3-cede442e0eb8@palves.net> References: <8ff04714-9feb-d13a-98e3-cede442e0eb8@palves.net> From: Peng Yu Date: Thu, 28 Jan 2021 19:58:11 -0600 Message-ID: Subject: Re: How to display instructions around the current instuction? To: Pedro Alves Cc: gdb@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jan 2021 01:58:15 -0000 On 1/28/21, Pedro Alves 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 : mov %edi,-0x4(%rbp) > 0x40056d : mov %rsi,-0x10(%rbp) > 0x400571 : mov $0x40061c,%esi > 0x400576 : mov $0x2a,%edi > 0x40057b : > callq 0x400536 > ~~~~ 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 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