aboutsummaryrefslogtreecommitdiff
path: root/gdb/riscv-none-tdep.c
AgeCommit message (Collapse)AuthorFilesLines
2024-01-12Update copyright year range in header of all files managed by GDBAndrew Burgess1-1/+1
This commit is the result of the following actions: - Running gdb/copyright.py to update all of the copyright headers to include 2024, - Manually updating a few files the copyright.py script told me to update, these files had copyright headers embedded within the file, - Regenerating gdbsupport/Makefile.in to refresh it's copyright date, - Using grep to find other files that still mentioned 2023. If these files were updated last year from 2022 to 2023 then I've updated them this year to 2024. I'm sure I've probably missed some dates. Feel free to fix them up as you spot them.
2023-03-09gdb, gdbserver, gdbsupport: fix whitespace issuesSimon Marchi1-1/+1
Replace spaces with tabs in a bunch of places. Change-Id: If0f87180f1d13028dc178e5a8af7882a067868b0
2023-01-01Update copyright year range in header of all files managed by GDBJoel Brobecker1-1/+1
This commit is the result of running the gdb/copyright.py script, which automated the update of the copyright year range for all source files managed by the GDB project to be updated to include year 2023.
2022-01-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker1-1/+1
This commit brings all the changes made by running gdb/copyright.py as per GDB's Start of New Year Procedure. For the avoidance of doubt, all changes in this commits were performed by the script.
2021-03-05gdb/riscv: write CSRs into baremetal core dumpsAndrew Burgess1-0/+60
Use the current target description to include CSRs into the RISC-V baremetal core dumps. Every CSR declared in the current target description will be included in the core dump. It will be critical for users that they have the same target description in use when loading the core file as was in use when writing the core file. This should be fine if the user allows the target description to be written into the core file. In more detail, this commit adds a NT_RISCV_CSR note type. The contents of this section is a series of either 4-byte (on RV32 targets), or 8-byte (on RV64 targets) values. Every CSR that is mentioned in the current target description is written out in the order the registers appear in the target description. As a consequence it is critical that the exact same target description, including the same register order, is in use when the CSRs are loaded from the core file. gdb/ChangeLog: * riscv-none-tdep.c: Add 'user-regs.h' and 'target-description.h' includes. (riscv_csrset): New static global. (riscv_update_csrmap): New function. (riscv_iterate_over_regset_sections): Process CSRs.
2021-03-05gdb/riscv: introduce bare metal core dump supportAndrew Burgess1-0/+113
This commit adds the ability for bare metal RISC-V target to generate core files from within GDB. The intended use case is that a user will connect to a remote bare metal target, debug up to some error condition, then generate a core file in the normal way using: (gdb) generate-core-file This core file can then be used to revisit the state of the remote target without having to reconnect to the remote target. The core file creation code is split between two new files. In elf-none-tdep.c is code for any architecture with the none ABI (i.e. bare metal) when the BFD library is built with ELF support. In riscv-none-tdep.c are the RISC-V specific parts. This is where the regset and regcache_map_entry structures are defined that control how registers are laid out in the core file. As this file could (in theory at least) be used for a non-ELF bare metal RISC-V target, the calls into elf-none-tdep.c are guarded with '#ifdef HAVE_ELF'. Currently for RISC-V only the x-regs and f-regs (if present) are written out. In future commits I plan to add support for writing out the RISC-V CSRs. The core dump format is based around generating an ELF containing sections for the writable regions of memory that a user could be using. Which regions are dumped rely on GDB's existing common core dumping code, GDB will attempt to figure out the stack and heap as well as copying out writable data sections as identified by the original ELF. Register information is added to the core dump using notes, just as it is for Linux of FreeBSD core dumps. The note types used consist of the 3 basic types you would expect in a OS based core dump, NT_PRPSINFO, NT_PRSTATUS, NT_FPREGSET. The layout of these notes differs slightly (due to field sizes) between RV32 and RV64. Below I describe the data layout for each note. In all cases, all padding fields should be set to zero. Note NT_PRPSINFO is optional. Its data layout is: struct prpsinfo32_t /* For RV32. */ { uint8_t padding[32]; char fname[16]; char psargs[80]; } struct prpsinfo64_t /* For RV64. */ { uint8_t padding[40]; char fname[16]; char psargs[80]; } Field 'fname' - null terminated string consisting of the basename of (up to the fist 15 characters of) the executable. Any additional space should be set to zero. If there's no executable name then this field can be set to all zero. Field 'psargs' - a null terminated string up to 80 characters in length. Any additional space should be filled with zero. This field contains the full executable path and any arguments passed to the executable. If there's nothing sensible to write in this field then fill it with zero. Note NT_PRSTATUS is required, its data layout is: struct prstatus32_t /* For RV32. */ { uint8_t padding_1[12]; uint16_t sig; uint8_t padding_2[10]; uint32_t thread_id; uint8_t padding_3[44]; uint32_t x_regs[32]; uint8_t padding_4[4]; } struct prstatus64_t /* For RV64. */ { uint8_t padding_1[12]; uint16_t sig; uint8_t padding_2[18]; uint32_t thread_id; uint8_t padding_3[76]; uint64_t x_regs[32]; uint8_t padding_4[4]; } Field 'sig' - the signal that stopped this thread. It's implementation defined what this field actually means. Within GDB this will be the signal number that the remote target reports as the stop reason for this thread. Field 'thread_is' - the thread id for this thread. It's implementation defined what this field actually means. Within GDB this will be thread thread-id that is assigned to each remote thread. Field 'x_regs' - at index 0 we store the program counter, and at indices 1 to 31 we store x-registers 1 to 31. x-register 0 is not stored, its value is always zero anyway. Note NT_FPREGSET is optional, its data layout is: fpregset32_t /* For targets with 'F' extension. */ { uint32_t f_regs[32]; uint32_t fcsr; } fpregset64_t /* For targets with 'D' extension . */ { uint64_t f_regs[32]; uint32_t fcsr; } Field 'f_regs' - stores f-registers 0 to 31. Field 'fcsr' - stores the fcsr CSR register, and is always 4-bytes. The rules for ordering the notes is the same as for Linux. The NT_PRSTATUS note must come before any other notes about additional register sets. And for multi-threaded targets all registers for a single thread should be grouped together. This is because only NT_PRSTATUS includes a thread-id, all additional register notes after a NT_PRSTATUS are assumed to belong to the same thread until a different NT_PRSTATUS is seen. gdb/ChangeLog: * Makefile.in (ALL_TARGET_OBS): Add riscv-none-tdep.o. (ALLDEPFILES): Add riscv-none-tdep.c. * configure: Regenerate. * configure.ac (CONFIG_OBS): Add elf-none-tdep.o when BFD has ELF support. * configure.tgt (riscv*-*-*): Include riscv-none-tdep.c. * elf-none-tdep.c: New file. * elf-none-tdep.h: New file. * riscv-none-tdep.c: New file.