From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id C2TbNFfebWigSS8AWB0awg (envelope-from ) for ; Tue, 08 Jul 2025 23:13:27 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=f9Ri7Uhr; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C487E1E11C; Tue, 8 Jul 2025 23:13:27 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D329B1E0C2 for ; Tue, 8 Jul 2025 23:13:25 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 206423858429 for ; Wed, 9 Jul 2025 03:13:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 206423858429 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=f9Ri7Uhr Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id A55403858D32 for ; Wed, 9 Jul 2025 03:12:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A55403858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A55403858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::531 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1752030771; cv=none; b=SyFiUn0Z8HMxrDAUN0xctkbq1Pp5FVALzwDOF6n6K9EGW8nj9fu5dKuDTQpcJx/uhdO6tVXOngdow7r3C3SwnLOFD6OLLplJIbDe/CwAcugu7C/oc/HCjSiBJ62nbYTxiJHtx7Nz35AS0CEI18Za0Vluj1gEQrVYNP/p1C8n6WA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1752030771; c=relaxed/simple; bh=3V17S+YGLP1MFJWseBv4OiEpEPv6PyQDne1riIAMq/k=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=arPtLrOg8M8rCGRAG+lzAwCVVTejKm4e06cLDkUz0AOyPPqMy34QAydG/D/dOU2aWqeu7hTOH4y4NU2TF6AEmCUShVcBSQeV/+WCKG9I60mDr4wHM4jn6Gwj/rW6EpkS6olfbmdgTrVROFSYMDYFadzovfzLkx/TF7unw9tgyoc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A55403858D32 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-b391d6780d2so1827718a12.1 for ; Tue, 08 Jul 2025 20:12:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1752030770; x=1752635570; darn=sourceware.org; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=MP8R3LHlXDK/OtC6hnKoUd7+lCtx8sHZB6EUqK6IvSk=; b=f9Ri7UhraCKdHC404e3gXPCLkVDv4OV8a8YDbzJ1FpYJA2x+K31HvI588h41at+pia 0u5M2oD/ezPogC022Fq/ZEWvhznlWQJLZIssIQNzeBc2fcrDY81RBDur1/hVXYsr9qet 6pRF/eDUtd6GWdnrJSRTll15agbcHakPrBfjj2+iCn75YYCaZF9x1by6W/YJ17OlMM1g hwR9t+2EiZv6DBa8LvPs/or+Nfq+Z48x5d7yZJU9tP5vGLum4pcKGUev7H6vdbdwXhUi uof4M6o/wOtBZ7ap1GbpAfruwiHFFbzv9IhvnZZRRjShy+g+BvO+0pvPy8HZB+SKRM9r xHzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752030770; x=1752635570; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MP8R3LHlXDK/OtC6hnKoUd7+lCtx8sHZB6EUqK6IvSk=; b=E8p1snIKOa5ec1zvRRngpCVK2/KO8vmjl8gmlrvG4uzkK8ByofyLgFxU5C9lcRmfi7 1GM8cR+tr6Rm7xytLMl674wSbruhSx3PhFbasiHcyeteC83wTqHrMBvPXhcsIkfs/8II +wGpCl26j28VB9j5L9iclQx5MTwH1d7NowiUbXRN15KXPztpvSmSdviAdfTIgxlB3BOU vgHVvvxtaHoIiw2oalswUkhod1NqkB4VMqd8jPwsCMF/A+tHg4o9bJCxjnKyc01sA+S3 bh57AIRVmlxH79YNwOBdqVtophQZf3w0+l1k53aOS1OkvMwd/bUCaAiYSlSrRF6whC6v Jqog== X-Gm-Message-State: AOJu0YwVA4iRblJQn05AGaQGdE7II8DnZ4Ha0LpI+CQvZcbU75N7TpJV DNoWI0kyWsflDmynpjol0nuat7HF+fnIYY5khh5SzD0sxYaw79Pp5rVd3bqmVhNvTTw= X-Gm-Gg: ASbGncupNotDGmubDtqNLj43PxVfyNbsJHh4DMmlXY2Ep2PPlI2kadrkKc54k5DU5a/ bvSQ6bl5Jh29TubO4ZAPc3V1AaePZ7TvQGes5kA2LHSqIMnVh+DjpivMcEUES1FMJ3445LBzC5w Mq4pq3wOoczT2SmMK3FUceAEHeM7pweEunb/niITR6MlwsuYFEVVCSgzfa4SNcSQy/KM106O0R1 bhRaPfhzLZnpNgEtoacJ0m9KeF4CXrmCy+GYFAHvD8J9FNS/QMWG7BM7JU2FPhhYBIya4I+n4IH bvDTtK+xZXsQcEVWM0G39W2IMiVAS8TzePva7fqTBbJtuCG25Qg8MSF22xxP2/giIsXn8U4C X-Google-Smtp-Source: AGHT+IHVy7RU5qLR7AP6lUzFpZukIaBuprnx0R+MSapSBpUS+SROSS6/kEGn3lLm9Vs7fvhNWXE2Gw== X-Received: by 2002:a17:90b:1a91:b0:315:9cae:bd8 with SMTP id 98e67ed59e1d1-31c2fdbc482mr1275762a91.23.1752030769540; Tue, 08 Jul 2025 20:12:49 -0700 (PDT) Received: from localhost ([2804:14d:7e39:88d6:33cd:332d:bfee:26c6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-31c301f24b2sm595882a91.48.2025.07.08.20.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jul 2025 20:12:48 -0700 (PDT) From: Thiago Jung Bauermann To: Tankut Baris Aktemur Cc: gdb-patches@sourceware.org, Markus Metzger Subject: Re: [PATCH v2 08/47] gdb, intelgt: add disassemble feature for the Intel GT architecture. In-Reply-To: <20241213-upstream-intelgt-mvp-v2-8-5c4caeb7b33d@intel.com> (Tankut Baris Aktemur's message of "Fri, 13 Dec 2024 16:59:25 +0100") References: <20241213-upstream-intelgt-mvp-v2-0-5c4caeb7b33d@intel.com> <20241213-upstream-intelgt-mvp-v2-8-5c4caeb7b33d@intel.com> User-Agent: mu4e 1.12.11; emacs 30.1 Date: Wed, 09 Jul 2025 00:12:46 -0300 Message-ID: <87bjpuvyz5.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Tankut Baris Aktemur writes: > From: Albertano Caruso > > Disassembly of Intel GT programs is done via the Intel Gen Assembler > library. Add this library as an optional dependency. If the library > is not found, disassembly is disabled. There should be information about this optional dependency in the GDB documentation. It should be in the "Requirements for Building GDB" section of the manual, and/or (not sure which) in a new "Intel GPU" section under "Configuration-Specific Information". For example, one important piece of information that is missing is a link to where one can get the Intel Gen Assembler library. > diff --git a/gdb/intelgt-tdep.c b/gdb/intelgt-tdep.c > index 57c359bf355c5771db38b8d213f6681a043c2b33..7d0ae38480fe89b145c1c29be0e58c96480e3335 100755 > --- a/gdb/intelgt-tdep.c > +++ b/gdb/intelgt-tdep.c > @@ -31,6 +31,10 @@ > #include "inferior.h" > #include "user-regs.h" > #include > +#include "disasm.h" > +#if defined (HAVE_LIBIGA64) > +#include "iga/iga.h" > +#endif /* defined (HAVE_LIBIGA64) */ > > /* Global debug flag. */ > static bool intelgt_debug = false; > @@ -119,6 +123,11 @@ struct intelgt_gdbarch_tdep : gdbarch_tdep_base > gdb_assert (regset_ranges[intelgt::REGSET_GRF].end > 1); > return regset_ranges[intelgt::REGSET_GRF].end - 1; > } > + > +#if defined (HAVE_LIBIGA64) > + /* libiga context for disassembly. */ > + iga_context_t iga_ctx = nullptr; > +#endif > }; > > /* The 'register_type' gdbarch method. */ > @@ -511,13 +520,77 @@ intelgt_sw_breakpoint_from_kind (gdbarch *gdbarch, int kind, int *size) > return nullptr; > } > > +#if defined (HAVE_LIBIGA64) > +/* Map CORE_ADDR to symbol names for jump labels in an IGA disassembly. */ > + > +static const char * > +intelgt_disasm_sym_cb (int addr, void *ctx) > +{ > + disassemble_info *info = (disassemble_info *) ctx; > + symbol *sym = find_pc_function (addr + (uintptr_t) info->private_data); > + return sym ? sym->linkage_name () : nullptr; > +} As I mentioned in my review of patch 6, I think you could put the definition of get_xe_version inside an #if/#endif such as this one. > +#endif /* defined (HAVE_LIBIGA64) */ > + > /* Print one instruction from MEMADDR on INFO->STREAM. */ > > static int > intelgt_print_insn (bfd_vma memaddr, struct disassemble_info *info) > { > - /* Disassembler is to be added in a later patch. */ > + unsigned int full_length = intelgt::inst_length_full (); > + unsigned int compact_length = intelgt::inst_length_compacted (); > + > + std::unique_ptr insn (new bfd_byte[full_length]); > + > + int status = (*info->read_memory_func) (memaddr, insn.get (), > + compact_length, info); > + if (status != 0) > + { > + /* Aborts disassembling with a memory_error exception. */ > + (*info->memory_error_func) (status, memaddr, info); > + return -1; > + } > + if (!intelgt::is_compacted_inst (gdb::make_array_view (insn.get (), > + compact_length))) > + { > + status = (*info->read_memory_func) (memaddr, insn.get (), > + full_length, info); > + if (status != 0) > + { > + /* Aborts disassembling with a memory_error exception. */ > + (*info->memory_error_func) (status, memaddr, info); > + return -1; > + } > + } If GDB wasn't compiled with libiga64, then the only thing that this function can do is print an error message and return -1, as is done in the #else block below. Therefore, all the code above should be inside the #if below. > +#if defined (HAVE_LIBIGA64) > + char *dbuf; > + iga_disassemble_options_t dopts = IGA_DISASSEMBLE_OPTIONS_INIT (); > + gdb_disassemble_info *di > + = static_cast(info->application_data); > + struct gdbarch *gdbarch = di->arch (); > + > + iga_context_t iga_ctx > + = gdbarch_tdep (gdbarch)->iga_ctx; > + iga_status_t iga_status > + = iga_context_disassemble_instruction (iga_ctx, &dopts, insn.get (), > + intelgt_disasm_sym_cb, > + info, &dbuf); > + if (iga_status != IGA_SUCCESS) > + return -1; > + > + (*info->fprintf_func) (info->stream, "%s", dbuf); > + > + if (intelgt::is_compacted_inst (gdb::make_array_view (insn.get (), > + full_length))) > + return compact_length; > + else > + return full_length; > +#else > + gdb_printf (_("\nDisassemble feature not available: libiga64 " > + "is missing.\n")); Is the '\n' at the beginning of the message needed? > return -1; > +#endif /* defined (HAVE_LIBIGA64) */ > } > > /* Utility function to look up the pseudo-register number by name. Exact > @@ -864,6 +937,46 @@ intelgt_gdbarch_init (gdbarch_info info, gdbarch_list *arches) > intelgt_gdbarch_tdep *data > = gdbarch_tdep (gdbarch); > > +#if defined (HAVE_LIBIGA64) > + iga_gen_t iga_version = IGA_GEN_INVALID; > + > + if (tdesc != nullptr) > + { > + const tdesc_device *device_info = tdesc_device_info (tdesc); > + if (!(device_info->vendor_id.has_value () > + && device_info->target_id.has_value ())) > + { > + warning (_("Device vendor id and target id not found.")); > + gdbarch_free (gdbarch); > + return nullptr; > + } > + > + uint32_t vendor_id = *device_info->vendor_id; > + uint32_t device_id = *device_info->target_id; > + if (vendor_id != 0x8086) > + { > + warning (_("Device not recognized: vendor id=0x%04x," > + " device id=0x%04x"), vendor_id, device_id); > + gdbarch_free (gdbarch); > + return nullptr; > + } > + else > + { > + iga_version = (iga_gen_t) get_xe_version (device_id); > + if (iga_version == IGA_GEN_INVALID) > + warning (_("Intel GT device id is unrecognized: ID 0x%04x"), > + device_id); > + } > + } > + > + /* Take the best guess in case IGA_VERSION is still invalid. */ > + if (iga_version == IGA_GEN_INVALID) > + iga_version = IGA_XE_HPC; > + > + const iga_context_options_t options = IGA_CONTEXT_OPTIONS_INIT (iga_version); > + iga_context_create (&options, &data->iga_ctx); > +#endif > + > /* Initialize register info. */ > set_gdbarch_num_regs (gdbarch, 0); > set_gdbarch_register_name (gdbarch, tdesc_register_name); > diff --git a/gdb/top.c b/gdb/top.c > index d750f3305f2eef7c5a30cef7f647537916a80499..c27f7d60254a4d384dfd770ce98eb4f0923dee49 100644 > --- a/gdb/top.c > +++ b/gdb/top.c > @@ -1523,6 +1523,16 @@ This GDB was configured as follows:\n\ > ")); > #endif > > +#ifdef HAVE_LIBIGA64 > + gdb_printf (stream, _("\ > + --with-libiga64\n\ > +")); This patch adds a "--with-libiga64-prefix=..." configure option, right? So this should print "--with-libiga64-prefix=...". > +#else > + gdb_printf (stream, _("\ > + --without-libiga64\n\ > +")); > +#endif -- Thiago