From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id VWKUO0rvEmBkeAAAWB0awg (envelope-from ) for ; Thu, 28 Jan 2021 12:07:22 -0500 Received: by simark.ca (Postfix, from userid 112) id E61001EF80; Thu, 28 Jan 2021 12:07:22 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 9006A1E945 for ; Thu, 28 Jan 2021 12:07:22 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D96D839960D2; Thu, 28 Jan 2021 17:07:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D96D839960D2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611853641; bh=qDqJeXZiQGb5ZV2TYexQb655LCXrk3tkpWWwnU0ZADA=; h=In-Reply-To:References:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=xeRmQaLuakEyPQt1kNRWTY4vTNpBVex3YCWeYng7sM2RFLRm73zskhJxOWS+eTDYL DMO0VUm5GR9hXNLQkAoiz74U7OTfSqlpoyZVOTtp5Xq6iArkxggYkiOOwFB2tyw/T4 hhj0ddIajOdJDK31dEkLgHfJxusu73b9BxD9vfIk= Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id 5A8713861802 for ; Thu, 28 Jan 2021 17:06:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5A8713861802 Received: by mail-il1-x12b.google.com with SMTP id y17so5885885ili.12 for ; Thu, 28 Jan 2021 09:06:57 -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=qDqJeXZiQGb5ZV2TYexQb655LCXrk3tkpWWwnU0ZADA=; b=DwH9tzS8fYT9h+oQHoOSoxdIEiwZ9tttB/Gk3XpXE8f7fJv65sLizCKp5wptH7Ji4v lAR4j6fzs2jF0VXe7fTBnGhh00y4FfEON9uO9hCnLIDwEZXP+yxbq4dUoYkHubm47eUm sT1bWJdaWMU/NFBkcx9zim/YHk4xhR0segvWwvXrvJp3GS0JD6fBYLiSR7yMEb8w+jEv iqxGEZ0Bsbp6ucAprhiGCxpgJjXt9OnYzznLmP0zkh7Mg4A5gPbDnrMexBVqM/vGlyT6 RHnZLIKcFHq/turc9dzPUxKpkZLCEYRl5kv3Q7rMdnIIa1kvkN0et7GUMGq+eNsvM0UR M+MQ== X-Gm-Message-State: AOAM533/UNGPJZOoHgiJ9JodVT4a63rQImU65IK0B6cO11JGjjLcFbyC mpvHK5nhIXUA9d/LEBSPUMjxdyBLYWhzidh1tjc= X-Google-Smtp-Source: ABdhPJxE4k/FHZfQ76oMSC6mQ2/ILXQRaUx26ceYbU08IsoUtW2Ar3kL5cwDq6n48gdjXyhiyFLWvyXko2o644u/nXQ= X-Received: by 2002:a05:6e02:1bad:: with SMTP id n13mr11124ili.260.1611853616911; Thu, 28 Jan 2021 09:06:56 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a6b:c88b:0:0:0:0:0 with HTTP; Thu, 28 Jan 2021 09:06:55 -0800 (PST) In-Reply-To: References: Date: Thu, 28 Jan 2021 11:06:55 -0600 Message-ID: Subject: Re: How to display instructions around the current instuction? To: Stefan Puiu Content-Type: text/plain; charset="UTF-8" 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: , From: Peng Yu via Gdb Reply-To: Peng Yu Cc: gdb@sourceware.org Errors-To: gdb-bounces@sourceware.org Sender: "Gdb" Hi Stefan, > display/10i $rip-10 > > I don't think x86-64 instructions have fixed width, so that won't > always print the same number of instructions before the current one, > but it's probably a good approximation. Have you tried it? If $rip-5 is not right at the start of an instruction, it does not even disassmble correctly. Please test your recommendation before sending it out. It is not appropriate to waste other people's time. (gdb) 1: x/10i $rip-5 (gdb) Temporary breakpoint 1 at 0x401134 Starting program: /mnt/macosx/pengy/mrrdir/test/gnu/gdb/cmd/display/main.exe Temporary breakpoint 1, 0x0000000000401134 in main () 1: x/10i $rip-5 0x40112f : add BYTE PTR [rbp+0x48],dl 0x401132 : mov ebp,esp => 0x401134 : sub rsp,0x10 0x401138 : movabs rdi,0x402004 0x401142 : mov al,0x0 0x401144 : call 0x401030 0x401149 : xor ecx,ecx 0x40114b : mov DWORD PTR [rbp-0x4],eax 0x40114e : mov eax,ecx 0x401150 : add rsp,0x10 (gdb) 0x0000000000401138 in main () 1: x/10i $rip-5 0x401133 : in eax,0x48 0x401135 : sub esp,0x10 => 0x401138 : movabs rdi,0x402004 0x401142 : mov al,0x0 0x401144 : call 0x401030 0x401149 : xor ecx,ecx 0x40114b : mov DWORD PTR [rbp-0x4],eax 0x40114e : mov eax,ecx 0x401150 : add rsp,0x10 0x401154 : pop rbp (gdb) 0x0000000000401142 in main () 1: x/10i $rip-5 0x40113d : add BYTE PTR [rax],al 0x40113f : add BYTE PTR [rax],al 0x401141 : add BYTE PTR [rax-0x1181800],dh 0x401147 : (bad) 0x401148 : push QWORD PTR [rcx] 0x40114a : leave 0x40114b : mov DWORD PTR [rbp-0x4],eax 0x40114e : mov eax,ecx 0x401150 : add rsp,0x10 0x401154 : pop rbp -- Regards, Peng