From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108159 invoked by alias); 6 Dec 2017 20:21:04 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 108146 invoked by uid 89); 6 Dec 2017 20:21:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.1 required=5.0 tests=BAYES_00,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=H*F:U*tim, H*c:alternative X-HELO: mail-ot0-f173.google.com Received: from mail-ot0-f173.google.com (HELO mail-ot0-f173.google.com) (74.125.82.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Dec 2017 20:21:01 +0000 Received: by mail-ot0-f173.google.com with SMTP id o23so4488070otd.1 for ; Wed, 06 Dec 2017 12:21:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=366k1FPR3BbEvSlUt2VNrN0kvl1su1o2ZWMdPrVDrzw=; b=O9Qr15X+7nIjK8TfaPRyCMlkKk/wcCtUD1cP/lsoXvxzLrQVcgu8OA1jTm4N6yKc+o phR8yCvK4XnHHoNVAFwVL+BuCXB5hF16ZW7ZTy2KEPhmACM4dUQGp9U6y3BurG6Rkz21 twPI4mrhI87APi8u+fGiezVtiOrFKQcZF2TyVFG3bHF1t1vVdKmPgH4gUJhYVgvaH9OM z1hPKo1FUgcNkzBMkprKXoZKcSwg1/ahLnWzZM6dWOin/xsAm8qIN4+kqwgsVm+jhb+0 eSI4NCTsX+VJkCZ33bnFa9le8xA36AOlu692uI+KFgZOERb+LrhQPFNRROZbOQ9rTxpZ 7yXw== X-Gm-Message-State: AKGB3mKLSVniQPUji1fIdSm3HA2w+ST6cvbt6bESg/c03wxnAwcrUVg8 g6mu50jZAZqCvK8ynJo51J79+KMPYhmKznt5vQWOY+XuZd8= X-Google-Smtp-Source: AGs4zMbJZU1uWx3xsh6RbZcBZnIVtL8C1mpuSIw63uRAv2QIkIn8LgHnKZWxSuslPJKiKaWvbliJJ7XjNm/Tsm16lYQ= X-Received: by 10.157.34.37 with SMTP id o34mr2888086ota.237.1512591659864; Wed, 06 Dec 2017 12:20:59 -0800 (PST) MIME-Version: 1.0 Received: by 10.168.66.197 with HTTP; Wed, 6 Dec 2017 12:20:59 -0800 (PST) From: Tim Newsome Date: Wed, 06 Dec 2017 20:21:00 -0000 Message-ID: Subject: gdbarch_init, ABI, and registers To: gdb Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg00004.txt.bz2 Still working on RISC-V support=E2=80=A6 I=E2=80=99ve taught OpenOCD to provide a target description, so now when co= nnecting to a target that doesn=E2=80=99t have an FPU, the FPU registers don=E2=80= =99t show up. Obviously I want this reflected in gdb, and I=E2=80=99ve managed to make th= at work in some cases. However, it doesn=E2=80=99t always work. Sometimes my target= appears to revert to the case where it just uses the built-in list of registers, despite being connected to an OpenOCD that I know provides the target description. My confusion comes from when riscv_gdbarch_init() is called, and how. With a bit of instrumenting, I get this output: + /opt/riscv/bin/riscv64-unknown-elf-gdb >>> riscv_gdbarch_init() >>> bits_per_word=3D64 >>> tdesc_has_register() -> 0 >>> info.abfd=3D(nil) >>> abi=3D1073741824 GNU gdb (GDB) 8.0.50.20170724-git ... (gdb) target extended-remote localhost:38295 target extended-remote localhost:38295 Remote debugging using localhost:38295 >>> riscv_gdbarch_init() >>> bits_per_word=3D64 >>> tdesc_has_register() -> 1 >>> info.abfd=3D(nil) >>> abi=3D1073741824 warning: No executable has been specified and target does not support determining executable automatically. Try using the "file" command. 0x00000000800009f0 in ?? () (gdb) file HiFive1_debug-32 >>> riscv_gdbarch_init() >>> bits_per_word=3D32 >>> tdesc_has_register() -> 1 >>> info.abfd=3D0x55a8a1f4e7f0 >>> flavour=3D5 >>> abi=3D0 >>> riscv_gdbarch_init() >>> bits_per_word=3D32 >>> tdesc_has_register() -> 0 >>> info.abfd=3D0x55a8a1f4e7f0 >>> flavour=3D5 >>> abi=3D0 Reading symbols from HiFive1_debug-32...done. (gdb) set arch riscv:rv32 >>> riscv_gdbarch_init() >>> bits_per_word=3D32 >>> tdesc_has_register() -> 1 >>> info.abfd=3D0x55a8a1f4e7f0 >>> flavour=3D5 >>> abi=3D0 The target architecture is assumed to be riscv:rv32 It almost feels like I=E2=80=99m on completely the wrong track by initializ= ing registers in riscv_gdbarch_init(), but that=E2=80=99s what the ARM and MIPS= targets do. A lot of code in their gdbarch_init() is dedicated to figuring out the ABI in use. How are ABIs and registers related? In my world view the hardware has certain registers, and how the software chooses to use those registers is the ABI. But changing the ABI doesn=E2=80=99t change what regi= sters exist. Are there callbacks I can use that are called when we connect to/disconnect from a remote server like OpenOCD? Thank you, Tim =E2=80=8B