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 2086C3959E72 for ; Tue, 31 May 2022 14:30:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2086C3959E72 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-513-idHcIowhMReBgKCLoyAnfg-1; Tue, 31 May 2022 10:30:57 -0400 X-MC-Unique: idHcIowhMReBgKCLoyAnfg-1 Received: by mail-wm1-f70.google.com with SMTP id k5-20020a05600c1c8500b003974c5d636dso1396119wms.1 for ; Tue, 31 May 2022 07:30:57 -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:mime-version :content-transfer-encoding; bh=v2e8aDOz2t9tIakOlMy6bpvRLqPLG2eHb/ORLaQkuRQ=; b=K32gOathN6FDPrtWWgYPOkLNRlG4HdqTnXCfGcYh6FoGEYOUoZwPhr+NJ9JJAVHBic zP0VK8TvwmLCUm+dqW88ir8yzYtXgtzcYkvhX1R2/tA1pX3YX6NKVQ2C6bxHT5rlFBmV R7j/ZtHNlrRgz2a5dLAgxv7eOXWlFt2FJ1PFp9MY70eldJYd9Xaax7kMqr4oLAPaHgEY iswX50zvZgH48WhXVphnEH6c8FjmLUuugz46Kslor14cszTav49TPcZCFwHB0xVMPTMn vsH2OueQMUbmlmt6ZSWIdUbCZM0X2+reA/YjdMTYopd6Wg1YBE3u1oVJJdBtNaAPAaux pc6w== X-Gm-Message-State: AOAM533NjsC9gPpzIiO87lM8sUa7lonoGCN3WULsZr0fqK90J55KXWSv CShAIPs8VA2gkNtmXsFUOUub6Ycue2J4qfqTUjTYAYsWFJoIs9G2sgR3ytnXxfKOCpruBtoa/Wb lUmE1gAwyHlrBVcGHGKrPWye8fZRXPB8xRQHxYgVy8X/E2LdO89tHH1wX5PaoZxlEEdnTvmODyw == X-Received: by 2002:adf:e605:0:b0:20d:889:ec5a with SMTP id p5-20020adfe605000000b0020d0889ec5amr50931237wrm.429.1654007453649; Tue, 31 May 2022 07:30:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzz1Mz1qxqD61zc848m9UTlz/9KiU0Fu6dblxaYm+FvS7fKazHDznL+Yg3GsjnPetXPqhSjFQ== X-Received: by 2002:adf:e605:0:b0:20d:889:ec5a with SMTP id p5-20020adfe605000000b0020d0889ec5amr50931224wrm.429.1654007453400; Tue, 31 May 2022 07:30:53 -0700 (PDT) Received: from localhost (host109-152-215-36.range109-152.btcentralplus.com. [109.152.215.36]) by smtp.gmail.com with ESMTPSA id v1-20020a5d4b01000000b0020d0435c97bsm11912063wrq.92.2022.05.31.07.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 07:30:53 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 0/5] Handle trying to use a native target with the wrong binary Date: Tue, 31 May 2022 15:30:45 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 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=-3.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Tue, 31 May 2022 14:31:00 -0000 This started when I accidentally tried to run a RISC-V binary on an x86-64 native target and discovered that GDB died with an assertion. I thought surely it must be easy to spot when a user makes this mistake, right... Patches #1 and #2 are nice cleanups in their own right, but are required to allow patch #4. Patches #3 and #4 are not actually required to solve the original problem, but were a part of my journey to figuring this out, and will, I think help catch any future issues in this area (of architecture mismatch). Patch #5 solves the original problem. Thanks, Andrew --- Andrew Burgess (5): gdb/arm: move fetch of arm_gdbarch_tdep to a more inner scope gdb/mips: rewrite show_mask_address gdb: move the type cast into gdbarch_tdep gdb: ensure the cast in gdbarch_tdep is valid gdb: native target invalid architecture detection gdb/aarch64-fbsd-nat.c | 4 +- gdb/aarch64-fbsd-tdep.c | 6 +- gdb/aarch64-linux-nat.c | 16 ++--- gdb/aarch64-linux-tdep.c | 10 +-- gdb/aarch64-newlib-tdep.c | 2 +- gdb/aarch64-tdep.c | 48 +++++++------- gdb/aix-thread.c | 28 ++++---- gdb/alpha-linux-tdep.c | 2 +- gdb/alpha-netbsd-tdep.c | 2 +- gdb/alpha-obsd-tdep.c | 2 +- gdb/alpha-tdep.c | 14 ++-- gdb/amd64-darwin-tdep.c | 2 +- gdb/amd64-fbsd-nat.c | 4 +- gdb/amd64-fbsd-tdep.c | 4 +- gdb/amd64-linux-tdep.c | 8 +-- gdb/amd64-netbsd-tdep.c | 2 +- gdb/amd64-obsd-tdep.c | 2 +- gdb/amd64-sol2-tdep.c | 2 +- gdb/amd64-tdep.c | 34 +++++----- gdb/amd64-windows-tdep.c | 2 +- gdb/arc-linux-tdep.c | 4 +- gdb/arc-newlib-tdep.c | 2 +- gdb/arc-tdep.c | 8 +-- gdb/arch-utils.c | 14 +++- gdb/arch-utils.h | 5 ++ gdb/arm-fbsd-nat.c | 4 +- gdb/arm-fbsd-tdep.c | 6 +- gdb/arm-linux-nat.c | 8 +-- gdb/arm-linux-tdep.c | 4 +- gdb/arm-netbsd-nat.c | 8 +-- gdb/arm-netbsd-tdep.c | 4 +- gdb/arm-none-tdep.c | 2 +- gdb/arm-obsd-tdep.c | 2 +- gdb/arm-tdep.c | 130 ++++++++++++++++++------------------ gdb/arm-wince-tdep.c | 2 +- gdb/avr-tdep.c | 12 ++-- gdb/bfin-tdep.c | 4 +- gdb/cris-linux-tdep.c | 2 +- gdb/cris-tdep.c | 18 ++--- gdb/frv-tdep.c | 4 +- gdb/ft32-tdep.c | 2 +- gdb/gdbarch.h | 26 +++++++- gdb/hppa-bsd-tdep.c | 2 +- gdb/hppa-linux-tdep.c | 4 +- gdb/hppa-tdep.c | 12 ++-- gdb/i386-bsd-tdep.c | 2 +- gdb/i386-darwin-tdep.c | 4 +- gdb/i386-fbsd-tdep.c | 4 +- gdb/i386-gnu-tdep.c | 2 +- gdb/i386-go32-tdep.c | 2 +- gdb/i386-linux-tdep.c | 4 +- gdb/i386-netbsd-tdep.c | 4 +- gdb/i386-nto-tdep.c | 6 +- gdb/i386-obsd-tdep.c | 2 +- gdb/i386-sol2-tdep.c | 2 +- gdb/i386-tdep.c | 98 +++++++++++++-------------- gdb/i386-windows-tdep.c | 2 +- gdb/i387-tdep.c | 20 +++--- gdb/ia64-linux-tdep.c | 2 +- gdb/ia64-tdep.c | 12 ++-- gdb/inf-child.c | 19 ++++++ gdb/inf-child.h | 2 + gdb/infcmd.c | 8 +++ gdb/loongarch-linux-nat.c | 6 +- gdb/loongarch-linux-tdep.c | 8 +-- gdb/loongarch-tdep.c | 10 +-- gdb/m32c-tdep.c | 58 ++++++++-------- gdb/m68hc11-tdep.c | 12 ++-- gdb/m68k-bsd-tdep.c | 2 +- gdb/m68k-linux-tdep.c | 2 +- gdb/m68k-tdep.c | 38 +++++------ gdb/mep-tdep.c | 6 +- gdb/mips-linux-tdep.c | 4 +- gdb/mips-tdep.c | 85 ++++++++++++------------ gdb/mn10300-tdep.c | 2 +- gdb/mn10300-tdep.h | 2 +- gdb/msp430-tdep.c | 12 ++-- gdb/nds32-tdep.c | 20 +++--- gdb/nios2-linux-tdep.c | 2 +- gdb/nios2-tdep.c | 4 +- gdb/or1k-tdep.c | 8 +-- gdb/ppc-fbsd-nat.c | 4 +- gdb/ppc-fbsd-tdep.c | 8 +-- gdb/ppc-linux-nat.c | 22 +++---- gdb/ppc-linux-tdep.c | 18 ++--- gdb/ppc-netbsd-nat.c | 6 +- gdb/ppc-netbsd-tdep.c | 2 +- gdb/ppc-obsd-nat.c | 4 +- gdb/ppc-obsd-tdep.c | 2 +- gdb/ppc-sysv-tdep.c | 22 +++---- gdb/ppc64-tdep.c | 2 +- gdb/riscv-linux-tdep.c | 2 +- gdb/riscv-tdep.c | 26 ++++---- gdb/rl78-tdep.c | 8 +-- gdb/rs6000-aix-nat.c | 6 +- gdb/rs6000-aix-tdep.c | 16 ++--- gdb/rs6000-lynx178-tdep.c | 4 +- gdb/rs6000-tdep.c | 132 ++++++++++++++++++------------------- gdb/rx-tdep.c | 2 +- gdb/s390-linux-tdep.c | 20 +++--- gdb/s390-tdep.c | 42 ++++++------ gdb/sh-linux-tdep.c | 2 +- gdb/sh-netbsd-tdep.c | 2 +- gdb/sh-tdep.c | 8 +-- gdb/sparc-linux-tdep.c | 4 +- gdb/sparc-netbsd-tdep.c | 2 +- gdb/sparc-sol2-tdep.c | 2 +- gdb/sparc-tdep.c | 14 ++-- gdb/sparc64-fbsd-tdep.c | 2 +- gdb/sparc64-linux-tdep.c | 4 +- gdb/sparc64-netbsd-tdep.c | 2 +- gdb/sparc64-obsd-tdep.c | 2 +- gdb/sparc64-sol2-tdep.c | 2 +- gdb/sparc64-tdep.c | 10 +-- gdb/target-delegates.c | 28 ++++++++ gdb/target.h | 13 +++- gdb/tic6x-linux-tdep.c | 6 +- gdb/tic6x-tdep.c | 6 +- gdb/v850-tdep.c | 6 +- gdb/windows-nat.c | 2 +- gdb/xtensa-linux-nat.c | 4 +- gdb/xtensa-linux-tdep.c | 2 +- gdb/xtensa-tdep.c | 54 +++++++-------- gdb/z80-tdep.c | 8 +-- 124 files changed, 799 insertions(+), 693 deletions(-) -- 2.25.4