From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KDg+M1MKa2AOLAAAWB0awg (envelope-from ) for ; Mon, 05 Apr 2021 09:02:11 -0400 Received: by simark.ca (Postfix, from userid 112) id C6D3A1EF64; Mon, 5 Apr 2021 09:02:11 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [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 2B8D01E789 for ; Mon, 5 Apr 2021 09:02:10 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3A1AE384B106; Mon, 5 Apr 2021 13:02:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A1AE384B106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1617627729; bh=Pk4wRPcfBcsHv3Iwmm2TfWdsMo3l9Vc+Tg3XY7uc8Y8=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=n9C1pQCnvTtDOABVOiEs0exMpFnqsauMkbtWAgF+EmTPt3vftPcyfEW4fy2/bAGSM H0glCF79nzTGJtrz6nIBWC769HdD0QuqWuVdJ7QU0zHCloF3wvpFD0DRigff2jQK03 PCZn3FMySEphoJenCVF4RLqiHCuCfNwIa4O4Xp8c= Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by sourceware.org (Postfix) with ESMTPS id 5A979384B106 for ; Mon, 5 Apr 2021 13:02:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5A979384B106 Received: by mail-qv1-xf2d.google.com with SMTP id 30so5345452qva.9 for ; Mon, 05 Apr 2021 06:02:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Pk4wRPcfBcsHv3Iwmm2TfWdsMo3l9Vc+Tg3XY7uc8Y8=; b=T46im/n96so2nf31qNFi5iAGi1YjRYpjMzDjbpUwWybQcFUiHDuvkoESWWB8pkp4h9 D+waG/4zge5hWwpJ+Cy+weHxqAz6yHCmphtNytUE2BZgQcPp3VGy7rm5/zzy1WN4QlSG 9pTi/hTxiQcn5tMFYdeAwuLvKZp3HjWYNCgu9FrqR107uhEjypCBcTtrVgB3WwW0a829 voadw00C+yKOodIvXS0fn9uvTVycvOjHaKgWiqe7OZNjlJe5ZsbqNW1ANp4FTp96nV8p KzoW8TqLh+Qu/WwMWX5H82nD3RdWgZLy25kLAh8vpZZbhKuaiLEc4p/6jlyvdbrnSAnR XDaQ== X-Gm-Message-State: AOAM532ARKOOeKxZOuGw2A1+MG+l93q5UqQHKwWQPe+xfICLxnHeC6ar ddnTTva5qhLItTZahgCltmSQNZssh/qPXw== X-Google-Smtp-Source: ABdhPJyYotLaz/sT/E3buO7d2x9bsMOO3BDqe+tiABJserVpxymu6ikYbhC6oLnvTWlUnqSG+8KK2A== X-Received: by 2002:ad4:5cc7:: with SMTP id iu7mr1575491qvb.19.1617627719607; Mon, 05 Apr 2021 06:01:59 -0700 (PDT) Received: from ?IPv6:2804:7f0:4841:2841:2863:21b6:ccec:53b6? ([2804:7f0:4841:2841:2863:21b6:ccec:53b6]) by smtp.gmail.com with ESMTPSA id v128sm13545211qkc.127.2021.04.05.06.01.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Apr 2021 06:01:59 -0700 (PDT) Subject: Re: A lean way for getting the size of the instruction at a given address To: Zied Guermazi , "gdb@sourceware.org" References: <295a186e-0dd9-fb96-671a-3df0a5611dd9@trande.de> <442482d9-31bd-8101-38f0-fb7c7763e61c@trande.de> Message-ID: <476fcf13-8782-a69f-f43b-069497ba7e3b@linaro.org> Date: Mon, 5 Apr 2021 10:01:55 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <442482d9-31bd-8101-38f0-fb7c7763e61c@trande.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Luis Machado via Gdb Reply-To: Luis Machado Errors-To: gdb-bounces@sourceware.org Sender: "Gdb" Hi Zied, On 4/4/21 4:59 AM, Zied Guermazi wrote: > hi > > I need to get the size of the instruction at a given address. I am > currently using gdb_insn_length (struct gdbarch *gdbarch, CORE_ADDR > addr) which calls gdb_print_insn (struct gdbarch *gdbarch, CORE_ADDR > memaddr, struct ui_file *stream, int *branch_delay_insns). and this is > consuming a huge time, considering that this is used in branch tracing > and this gets repeated up to few millions times. > > > Is there a lean way for getting the size of the instruction at a given > address, I am using it for aarch64 and arm targets. At the moment I don't think there is an optimal solution for this. The instruction length is calculated as part of the disassemble process, and is tied to the function that prints instructions. One way to speed things up is to have a new member function in "class gdb_disassembler" to calculate the instruction length only. Another way is to have a new gdbarch hook that calculates the size of an instruction based on the current PC, mapping symbols etc. > > Kind Regards > > Zied Guermazi > >