From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 335CD3858D37 for ; Mon, 4 Apr 2022 22:20:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 335CD3858D37 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-253-ZSWrfhsHNnOQqdyZAPXgXw-1; Mon, 04 Apr 2022 18:20:04 -0400 X-MC-Unique: ZSWrfhsHNnOQqdyZAPXgXw-1 Received: by mail-wm1-f69.google.com with SMTP id bg8-20020a05600c3c8800b0038e6a989925so1285529wmb.3 for ; Mon, 04 Apr 2022 15:20:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n7fDc3ZlEdjWyExEWJFcVEJ2qH95bodLyNYIbhFTIhA=; b=dWilbEacqUBIX49cO9dZ0uKUc3UnN01UO+81yY3xM9aNGDqFHU6cUymZjGfd0ldjkK dgG+nbxgSKxtJynQR1MHxiBHrJhjNEDx3oqM6M3XM8yoL08Aazyxp12ALaBvzFsOcHfV XGrtJB60FM3kDPqFB65Zq4/cjrQW53ZVyfVMnKPslBYahBBhkl4/yA46g3sdjzMKPp92 3kUYaE46FC92HLzjy9IOpNshiPmfJSG9MpXLHBxJchWNxN65bpADGhgyN5qdTDUXoMKj 2JtAU0zgJZQSopIlqxaBFPsuMWLqga4Lx7Dqy8dB6pqUVtWrjgK7Su6/x4ivKGrJR/OH lkfg== X-Gm-Message-State: AOAM533PdRUTyWWyBXeCoJIHtv3wAQ4TciVQW3Iam/psKInGDl6n3cc8 EG7mFKCZFJ4+UOyDavi1WUTybMEMyj4z/FYvyS++cq1b5GeHLBCgVwP2OM6WXmClFEComaX4I5h omr9RIOpR0gOgDeIMEQHTMrU60uBsfb27mMnFR/txeAbFXG761IQfycFs+X+Zj1mRBt/PxFPR6A == X-Received: by 2002:adf:c188:0:b0:1e6:8ecb:ea5a with SMTP id x8-20020adfc188000000b001e68ecbea5amr243742wre.711.1649110803110; Mon, 04 Apr 2022 15:20:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx26wkQkSUx4eVP5V8M47jSCaI34IjWZxl56a+jN5By1Ul2gfeDdyfawiaXMSr+BPA/uKiGhA== X-Received: by 2002:adf:c188:0:b0:1e6:8ecb:ea5a with SMTP id x8-20020adfc188000000b001e68ecbea5amr243730wre.711.1649110802798; Mon, 04 Apr 2022 15:20:02 -0700 (PDT) Received: from localhost (host86-169-131-113.range86-169.btcentralplus.com. [86.169.131.113]) by smtp.gmail.com with ESMTPSA id v5-20020adfe4c5000000b001edc1e5053esm10226585wrm.82.2022.04.04.15.20.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 15:20:02 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv3 0/6] Add Python API for the disassembler Date: Mon, 4 Apr 2022 23:19:53 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Apr 2022 22:20:09 -0000 Changes in v3: - Rebased to current master, and retested, - Patch #1 is new in this series, - Patch #2 is changed slightly from v2, I've reworked the disassembler classes in a slightly different way now, in order to prepare for patches #5 and #6. - Patch #3 is unchanged from v2, - Patch #4 is unchanged from v2, - Patch #5 is new in v3. I've included it here as the changes in #2 only make sense knowing that patch #5 is coming, - Patch #6 is a small cleanup only possible after #2 and #5 have landed. Changes in v2: - The first 3 patches from the v1 series were merged a while back, these were all refactoring, or auxiliary features, - There's a new #1 patch in the v2 series that does some new refactoring of GDB's disassembler classes, this was required in order to simplify the #3 patch, - Patch #2 in the v2 series is largely unchanged from patch #4 in the v1 series, - The syntax highlighting work that was in the v1 series was spun out into its own patch, and has been merged separately, - The format_address helper function that appeared in the v1 series, and that Simon suggested I make more general, was spun out into its own patch, and merged separately, - Finally, patch #3 in the v2 series is pretty much a complete rewrite from the v1 series in order to follow the approach suggested by Simon. Results are now returned directly, either via 'return' or by raising an exception, in contrast to the original approach which involved "setting" the result into an existing state object. --- Andrew Burgess (6): gdb: move gdb_disassembly_flag into a new disasm-flags.h file gdb: add new base class to gdb_disassembler gdb: add extension language print_insn hook gdb/python: implement the print_insn extension language hook gdb: refactor the non-printing disassemblers gdb: unify two dis_asm_read_memory functions in disasm.c gdb/Makefile.in | 2 + gdb/NEWS | 34 + gdb/arc-linux-tdep.c | 16 +- gdb/arc-tdep.c | 29 +- gdb/arc-tdep.h | 5 - gdb/arm-tdep.c | 4 +- gdb/data-directory/Makefile.in | 1 + gdb/disasm-flags.h | 40 + gdb/disasm-selftests.c | 70 +- gdb/disasm.c | 172 ++--- gdb/disasm.h | 221 ++++-- gdb/doc/python.texi | 248 +++++++ gdb/extension-priv.h | 15 + gdb/extension.c | 20 + gdb/extension.h | 17 + gdb/guile/guile.c | 6 +- gdb/mep-tdep.c | 1 - gdb/mips-tdep.c | 4 +- gdb/python/lib/gdb/disassembler.py | 109 +++ gdb/python/py-disasm.c | 970 +++++++++++++++++++++++++ gdb/python/py-registers.c | 1 - gdb/python/python-internal.h | 16 + gdb/python/python.c | 3 + gdb/s12z-tdep.c | 27 +- gdb/target.h | 2 +- gdb/testsuite/gdb.python/py-disasm.c | 25 + gdb/testsuite/gdb.python/py-disasm.exp | 150 ++++ gdb/testsuite/gdb.python/py-disasm.py | 456 ++++++++++++ 28 files changed, 2451 insertions(+), 213 deletions(-) create mode 100644 gdb/disasm-flags.h create mode 100644 gdb/python/lib/gdb/disassembler.py create mode 100644 gdb/python/py-disasm.c create mode 100644 gdb/testsuite/gdb.python/py-disasm.c create mode 100644 gdb/testsuite/gdb.python/py-disasm.exp create mode 100644 gdb/testsuite/gdb.python/py-disasm.py -- 2.25.4