aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-11-17RISC-V: Handle capability return values.users/jhb/cheri-gdb-12-branchJohn Baldwin1-3/+62
Add simple handling of capability function arguments (also used for return values) and update riscv_return_value to propagate tags.
2022-11-17Set is_tagged and FLAG_CAPABILITY in arch_capability/pointer_type.John Baldwin1-10/+6
2022-11-17Set tagged and FLAG_CAPABILITY on C++ reference types.John Baldwin1-0/+17
2022-11-17make_pointer_type: Set TYPE_INSTANCE_FLAG_CAPABILITY on cap pointers.John Baldwin1-0/+8
For purecap this isn't always set by DWARF attributes, and in particular it isn't for CHERI-RISC-V.
2022-11-15gdb tdesc: Handle mismatched pointer register types.John Baldwin1-1/+18
In the XML target descriptions, registers can be given a type of "code_ptr" or "data_ptr". GDB always uses the builtin type for "void *" for these registers. However, this is wrong if the register's size does not match (e.g. the legacy "sp" and "pc" ARM64 registers when using a purecap binary for which "void *" is a capability). If the sizes don't match, try to find a matching type such as "long" or "intcap_t" to use instead.
2022-10-13CHERI-RISC-V: Improve handling of hybrid binaries.John Baldwin1-0/+75
- Add CHERI to the RISC-V ISA features if an ELF file contains the "xcheri" attribute. This is set in both hybrid and purecap ELF files. This isn't needed for purecap ELF files but does enable capability types and the "__capability" keyword on hybrid binaries and libraries. - Add address_class gdbarch methods so that capability pointer types are tagged as capabilities in hybrid binaries. This is a bit gross. Ideally riscv_address_class_type_flags would only enable the TYPE_INSTANCE_FLAG_CAPABILITY if the passed in byte_size (from DW_ATTR_byte_size) was equal to riscv_isa_clen() (aka gdbarch_capability_bit()). However, for some reason this gdbarch method doesn't take the gdbarch member. For now, rely on the fact that it is only called if either there is a DW_ATTR_address_space attribute on a pointer, or if the byte_size doesn't match the default pointer size. Assuming there is no DW_ATTR_address_space defined for RISC-V yet, this means it should only be called for a size mismatch, and since we don't allow creating integer pointers in purecap, this means it can only be called for capability pointers for hybrid binaries.
2022-10-13CHERI-RISC-V: Support for displaying capability attributes.John Baldwin1-0/+185
This supports both the compact format (always used for annotating pointer variables) and the verbose format (available via set print compact-capabilities off) when displaying individual capabilities.
2022-10-13git subrepo clone https://github.com/CTSRD-CHERI/cheri-compressed-cap ↵John Baldwin59-0/+63095
gdb/cheri-compressed-cap subrepo: subdir: "gdb/cheri-compressed-cap" merged: "6762a19ba9f" upstream: origin: "https://github.com/CTSRD-CHERI/cheri-compressed-cap" branch: "master" commit: "6762a19ba9f" git-subrepo: version: "0.4.3" origin: "???" commit: "???"
2022-10-13Native support for FreeBSD CHERI-RISC-V.John Baldwin1-0/+32
2022-10-13bfd/binutils: Support for CHERI-RISC-V memory tag segments.John Baldwin3-0/+50
2022-10-13Add FreeBSD support for CHERI-RISC-V.John Baldwin2-7/+306
- Register maps and sets for the capability register set and support for them in core dumps. - A CheriABI signal frame unwinder. - Support CheriABI when fetching the address of TLS variables. - Extend fbsd_report_signal_info for CHERI exceptions to give the name of the relevant capability register.
2022-10-13riscv-tdep: Export riscv_features_from_bfd.John Baldwin2-1/+3
2022-10-13fbsd-tdep: Export fbsd_report_signal_info.John Baldwin2-2/+8
2022-10-13Don't call tag_map_regno twice for each index.John Baldwin2-4/+4
2022-10-13Handle JALR.CAP in riscv_next_pc().John Baldwin1-0/+10
This fixes stepping into some functions in purecap.
2022-10-13CHERI-RISC-V: Add basic hybrid and purecap support.John Baldwin1-3/+86
2022-10-13Add basic CHERI-RISC-V support including CHERI registers.Alex Richardson4-6/+203
Co-authored-by: John Baldwin <jhb@FreeBSD.org>
2022-10-13Add RISC-V CHERI register xml filesAlex Richardson5-0/+186
Co-authored-by: John Baldwin <jhb@FreeBSD.org>
2022-10-13Support for disassembling CHERI-RISC-V capmode instructions.John Baldwin3-1/+285
Add a separate table of capmode instructions and change riscv_disassemble_insn to look for a match in this table first when using capmode. If a match isn't found, fall back to the normal table. Capmode is currently enabled for any ELF file which has the capmode flag set in the ELF header flags.
2022-10-13Initial support for disassembling CHERI-RISC-V instructions.John Baldwin5-0/+603
This does not yet handle capability mode.
2022-10-12riscv_parsing_subset_version: Handle "0p0" version strings.John Baldwin1-12/+15
Use a boolean to determine if a version is present (similar to what is done in riscv_parse_prefixed_ext) rather than assuming that both versions set to 0 means no version was present. This fixes parsing of an attribute string of "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0_xcheri0p0" which previously failed with the error: BFD: x ISA extension `xcheri' must be set with the versions
2022-10-11Add CHERI-RISC-V ELF header flags.John Baldwin2-0/+12
2022-09-02corelow: Implement the target read_capability method.John Baldwin1-0/+39
This locates the relevant memtag.cheri section to fetch the tag and uses target_read_memory to fetch the rest of the capability's contents.
2022-09-02get_next_core_memtag_section: Accept section name as an argument.John Baldwin4-10/+12
This permits callers to search for other memory tag section types.
2022-09-01Retire gdbarch_get/set_cap_tag_from_address.John Baldwin6-141/+0
These methods are no longer used as core GDB code now reads and writes capabilities atomically.
2022-09-01bfd/binutils: Handle Morello memory tag core dump segments.John Baldwin3-5/+25
This is similar to the support for MTE core dump segments.
2022-09-01Don't treat *intcap_t as pointers.John Baldwin1-2/+1
TYPE_CODE_CAPABILITY is used for intcap_t and uintcap_t, whereas capability-sized pointers use TYPE_CODE_PTR with the TYPE_CAPABILITY flag. This avoids trying to indirect scalar capability values in some places. Cosmetically it stops the output of the '(intcap_t)' prefixes in front of capability values.
2022-09-01value_fetch_lazy_memory: Fetch tags for *intcap_t as well.John Baldwin1-2/+4
uintcap_t/intcap_t types don't have TYPE_CAPABILITY set, only pointer types have this flag set.
2022-09-01value_primitive_field: Always mark capabilities lazy.John Baldwin1-2/+3
value_primitive_field copies the subrange of a non-lazy value into the new value for a subobject. However, the value of outer objects never contain tags. Instead, always mark new values as lazy if they are a capability or are a structure containing a capability member.
2022-09-01eXamine: Update to support capabilities.John Baldwin1-3/+18
- For the address ('a') size, pick a suitable size corresponding to ptraddr_t for pure capability ABIs. - Add a new 'C' size flag that prints memory as capabilities, either in the default compact format, or as hex via 'x'. The hex format does not yet include tags.
2022-09-01Use PIOD_READ_CHERI_CAP to read memory capabilities from running processes.John Baldwin2-0/+27
2022-09-01x: Print CHERI memory tags using a similar format to MTE.John Baldwin1-0/+24
2022-09-01Default gdbarch_capability_bit to 0, not ptr_bit.John Baldwin4-37/+42
This allows testing for 0 to distinguish architectures without capabilities. Make use of this to only add in builtin types for architectures which support capabilities.
2022-09-01Write memory capabilities atomically.John Baldwin1-4/+10
Use target_write_capability to write a capability atomically in put_frame_register.
2022-09-01Read memory capabilities atomically.John Baldwin1-4/+13
When resolving a lazy memory capability value, use target_read_capability to read the entire capability directly rather than only using it to read the tag. Also, just use target_read_capability directly without requiring a gdbarch wrapper method.
2022-09-01Copy ELF header flags from executable to core file.John Baldwin1-3/+7
2022-09-01Add a 'set program-interpreter' command.John Baldwin1-0/+32
This is a bit of a hack, but it allows you to override the initial path to the runtime linker instead of having GDB always trust the contents of .interp. This is useful for running purecap binaries under a hybrid world or vice versa via 'run'.
2022-09-01aarch64-fbsd-nat: Support the capability register set for Morello.John Baldwin1-0/+20
2022-09-01aarch64-fbsd: Use a static regset for the TLS register set.John Baldwin3-49/+42
This uses custom collect/supply regset handlers which pass the TLS register number from the gdbarch_tdep as the base register number.
2022-09-01fbsd-nat: Add a have_register_set helper function.John Baldwin2-0/+24
This is similar to have_regset but is used for older register sets that pre-date PT_GETREGSET and use separate fetch and store ptrace operations.
2022-09-01Elide "__capability" modifier for purecap ABIs.John Baldwin1-1/+4
2022-09-01capability: Don't print redundant "sealed" for sentries.John Baldwin1-1/+1
2022-09-01Morello: Add gdbarch_print_cap* methods.John Baldwin1-0/+29
2022-09-01Add capability::metadata_str.John Baldwin2-51/+63
This returns a string of just the metadata for a capability. capability::to_str uses this method when outputting the compact form.
2022-09-01Use gdbarch_print_cap* methods when printing capabilities.John Baldwin2-42/+28
For pointers, use gdbarch_print_cap_attributes after printing the pointer's address normally. For printing a raw capability, use gdbarch_print_cap. I removed the fetch of the tag from memory explicitly in generic_value_print_capability as it should already be fetched for memory values in value_fetch_lazy_memory.
2022-09-01Add gdbarch methods for printing capabilities.John Baldwin5-0/+120
gdbarch_print_cap prints a full capability in either verbose or compat forms. gdbarch_print_cap_attributes prints just the metadata such as bounds and permissions of a capability without the address.
2022-09-01Morello: CheriBSD architecture support.John Baldwin2-5/+230
- Register set for NT_CAPREGS. - Signal frame unwinder. - Use CTPIDR instead of TPIDR to find the TCB for purecap when resolving TLS variables.
2022-09-01frame_unwind_register_unsigned: Return address from capabilities.John Baldwin1-2/+9
2022-09-01Make 'info sharedlibrary' more readable with CHERI.John Baldwin1-1/+2
In particular, use the smaller of address or pointer bit count to determine the size of the address field.
2022-09-01Update solib*.c to work with CHERI capabilities.John Baldwin2-1/+12
- Treat dyn_ptr members of .dynamic entries as addresses rather than pointers. - Don't truncate pointers in svr4_truncate_ptr() if the pointer size is larger than a CORE_ADDR as the truncation effectively sets them to zero in this case. This should perhaps be using gdbarch_integer_to_address() instead of it's own explicit truncation anyway.