From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 78A5B3858D20 for ; Tue, 15 Oct 2024 22:45:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 78A5B3858D20 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 78A5B3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729032305; cv=none; b=q13FQvvR3wgs5n7UBOmS35NV9XQjkRWeSUQIjW5TDqvgeIHL9SU1/GSaeP0K4E5L1WLs/FzEDmz4g9PQ1n6Uy/HgT+JD5Il0A6Fgt1SmdTdj0QQOrzBWlmo6mjVSZXPcNNcYmoDeoGxAwLlB1FxRdwrvPy8btugqEDDj706mnE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729032305; c=relaxed/simple; bh=WNJM4lu6CsLiuvTs7u49TA1LOMUfzMhuI90+vwM8kzE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=oQvXg2Rptpk6u5AWeamlRcnOjw2SriJg074n9+t5OG8ubVCr113D68RO86XguySqZx3PVOccTf/eQJkf+AH0udFpJD+xhZaz/tonmbl/0r7/HeA++RHTqacFQtc6F0pQBG0TycyV7clciF7gyQUt6cEA1saIkaWUqEfBnhV9hwI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-71e6cec7227so1773523b3a.0 for ; Tue, 15 Oct 2024 15:45:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729032301; x=1729637101; darn=sourceware.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=z2JnFzrEkimY09SxxjSjTr057m+tWhnyKhZkazhgRYs=; b=oiKHMcvDaPGWLht9FDzTFquVHobuRZ3d5/+CD93RwmmVyqgWzK3XviN8z+sUX0rs9Z FHw3wnvZrukHQGW1T9Ndm9FfTSg2mpM+Yasu4USHsXfO5pFPu4tVdIyaXAWnWgS/fe72 ANlHP1yYCg0+UDBi9QDNKoMM7mXN1OoLBbp5J4ganhgH2qmEIIlS8aGbBVTfXsm9TAsR gfZzWp4DifGzSZc9vOoJHp4baY+j1MLGxjyLh647YpN4Z1Hq28gAcEt3/YM8oqj2+DIJ KzLVkoZo1kmhiCXLK3DgeNCA5REpDxapp+tNjzqhK9GlREbXjel5kDeTHkQNIL87GKbJ S7Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729032301; x=1729637101; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=z2JnFzrEkimY09SxxjSjTr057m+tWhnyKhZkazhgRYs=; b=IigMnaMZv3DdcnIU8arWA4w2pSefGnuX6BVItfgACOqTD6R+6zBGWrf1a5Sh8t4NiL XOXzJFzoqEaHB0g0lryC1gmYCF9uCuNxOYsWHHxlCop8l+YxyGItH59uiKozX29dc9J1 WYsmoIRgbkvdXUUYOhyl4qhAWci1+nGNmXlEJy0G5TPKwfPG6auazXqGc/hLqrlhaxYM CS9ffRqfuMtdk6k+1cbRmVX8znGXTlvdrNAfzsekFCmXB27nenfLUDgjFrv9ktRXT44j 8Z34yvguCC7Jold9/9lm7i8MkJlLWFZZjzJpyPZbUAX+JQ9vCjm0RdVfZx5AMBeRnY+d cM/A== X-Gm-Message-State: AOJu0Yz5x3s89J5g07qXNaItvZBHrteecW3K55lpml+4jkoBxxak99Sh f8jXRZQ0SPkCJK1Zx8WcrKpOVc3Z7Qztt15xxvWGMc5iiZBWUf6B++h8d61xuykRriy2+Y/ZBdo y X-Google-Smtp-Source: AGHT+IGBRPI3b8+8GAmVHiwKRvPgwzb9y57+n94i7SAh6OSf9xzbCmMsvbf5Dvi9TeyMQJMKNS4ifw== X-Received: by 2002:a05:6a00:1820:b0:71e:1722:d02c with SMTP id d2e1a72fcca58-71e7da06de1mr3017202b3a.3.1729032301254; Tue, 15 Oct 2024 15:45:01 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:a779:8a1f:deae:7dfb]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e773a2f7fsm1860403b3a.55.2024.10.15.15.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 15:45:00 -0700 (PDT) From: Thiago Jung Bauermann To: Tankut Baris Aktemur Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 05/46] gdb, arch, intelgt: add intelgt arch definitions In-Reply-To: <54915492db3e6c55648613410099141e3bcf112e.1719919039.git.tankut.baris.aktemur@intel.com> (Tankut Baris Aktemur's message of "Tue, 2 Jul 2024 13:42:36 +0200") References: <54915492db3e6c55648613410099141e3bcf112e.1719919039.git.tankut.baris.aktemur@intel.com> Date: Tue, 15 Oct 2024 19:44:58 -0300 Message-ID: <87sesxt28l.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tankut Baris Aktemur writes: > diff --git a/gdb/arch/intelgt.h b/gdb/arch/intelgt.h > new file mode 100644 > index 00000000000..a4154ddb8d3 > --- /dev/null > +++ b/gdb/arch/intelgt.h > @@ -0,0 +1,175 @@ > +/* Copyright (C) 2019-2024 Free Software Foundation, Inc. > + > + This file is part of GDB. > + > + This program is free software; you can redistribute it and/or modify > + it under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + This program is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + GNU General Public License for more details. > + > + You should have received a copy of the GNU General Public License > + along with this program. If not, see . */ > + > +#ifndef ARCH_INTELGT_H > +#define ARCH_INTELGT_H > + > +#include "gdbsupport/tdesc.h" > +#include > +#include > + > +namespace intelgt { > + > +/* Various arch constants. */ > + > +enum breakpoint_kind > +{ > + BP_INSTRUCTION = 1, > +}; > + > +/* The length of a full and compact IntelGT instruction in bytes. */ > + > +constexpr int MAX_INST_LENGTH = 16; > +constexpr int COMPACT_INST_LENGTH = 8; > + > +/* Feature names. > + > + They correspond to register sets defined in zet_intel_gpu_debug.h. We > + declare feature names in the order used in that header. > + > + The SBA register set consists of a set of base registers in the order > + defined in that header file. > + > + Not all registers have DWARF numbers. See DWARF_REGSETS below for a > + list of features that do. */ > +constexpr const char *feature_grf = "org.gnu.gdb.intelgt.grf"; > +constexpr const char *feature_addr = "org.gnu.gdb.intelgt.addr"; > +constexpr const char *feature_flag = "org.gnu.gdb.intelgt.flag"; > +constexpr const char *feature_ce = "org.gnu.gdb.intelgt.ce"; > +constexpr const char *feature_sr = "org.gnu.gdb.intelgt.sr"; > +constexpr const char *feature_cr = "org.gnu.gdb.intelgt.cr"; > +constexpr const char *feature_tdr = "org.gnu.gdb.intelgt.tdr"; > +constexpr const char *feature_acc = "org.gnu.gdb.intelgt.acc"; > +constexpr const char *feature_mme = "org.gnu.gdb.intelgt.mme"; > +constexpr const char *feature_sp = "org.gnu.gdb.intelgt.sp"; > +constexpr const char *feature_sba = "org.gnu.gdb.intelgt.sba"; > +constexpr const char *feature_dbg = "org.gnu.gdb.intelgt.dbg"; > +constexpr const char *feature_fc = "org.gnu.gdb.intelgt.fc"; > +constexpr const char *feature_debugger = "org.gnu.gdb.intelgt.debugger"; > + > +/* Register sets/groups needed for DWARF mapping. Used for > + declaring static arrays for various mapping tables. */ > + > +enum dwarf_regsets : int > +{ > + regset_sba = 0, > + regset_grf, > + regset_addr, > + regset_flag, > + regset_acc, > + regset_mme, > + regset_count > +}; > + > +/* Map of dwarf_regset values to the target description > + feature names. */ > + > +constexpr const char *dwarf_regset_features[regset_count] = { > + feature_sba, > + feature_grf, > + feature_addr, > + feature_flag, > + feature_acc, > + feature_mme > +}; > + > +/* Instruction details. */ > + > +enum > +{ > + /* The opcode mask for bits 6:0. */ > + opc_mask = 0x7f, > + > + /* Send instruction opcodes. */ > + opc_send = 0x31, > + opc_sendc = 0x32, > +}; > + > +/* Selected instruction control bit positions. */ > + > +enum > +{ > + /* The End Of Thread control. Only used for SEND and SENDC. */ > + ctrl_eot = 34, > +}; > + > +/* Get the bit at POS in INST. */ > + > +bool get_inst_bit (const gdb_byte inst[], int pos); > + > +/* Set the bit at POS in INST. */ > + > +bool set_inst_bit (gdb_byte inst[], int pos); > + > +/* Clear the bit at POS in INST. */ > + > +bool clear_inst_bit (gdb_byte inst[], int pos); > + > +static inline bool > +is_compacted_inst (const gdb_byte inst[]) > +{ > + /* Check the CmptCtrl flag (bit 29). */ > + return inst[3] & 0x20; > +} > + > +static inline int > +breakpoint_bit_offset (const gdb_byte inst[]) > +{ > + return (is_compacted_inst (inst) ? 7 : 30); > +} > + > +static inline bool > +set_breakpoint (gdb_byte inst[]) > +{ > + return set_inst_bit (inst, breakpoint_bit_offset (inst)); > +} > + > +static inline bool > +clear_breakpoint (gdb_byte inst[]) > +{ > + return clear_inst_bit (inst, breakpoint_bit_offset (inst)); > +} > + > +static inline bool > +has_breakpoint (const gdb_byte inst[]) > +{ > + return get_inst_bit (inst, breakpoint_bit_offset (inst)); > +} > + > +static inline unsigned int > +inst_length_compacted () > +{ > + return COMPACT_INST_LENGTH; > +} > + > +static inline unsigned int > +inst_length_full () > +{ > + return MAX_INST_LENGTH; > +} > + > +static inline unsigned int > +inst_length (const gdb_byte inst[]) > +{ > + return (is_compacted_inst (inst) > + ? inst_length_compacted () > + : inst_length_full ()); > +} > + > +} /* namespace intelgt */ > + > +#endif All these functions defined in the "arch/intelgt.h" header which take a gdb_byte inst[] as argument could be changed to take a gdb::array_view or gdb::array_view instead. The advantage is that the size of the array is passed along with the pointer, so the "if (pos < 0 || (MAX_INST_LENGTH * 8) <= pos)" checks can be changed to "if (pos < 0 || inst.size () <= pos)" instead. -- Thiago