aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport/tdesc.h
AgeCommit message (Collapse)AuthorFilesLines
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-01-01Update copyright year range in all GDB filesJoel Brobecker1-1/+1
This commits the result of running gdb/copyright.py as per our Start of New Year procedure... gdb/ChangeLog Update copyright year range in copyright header of all GDB files.
2020-10-08gdb: Have allocate_target_description return a unique_ptrAndrew Burgess1-1/+1
Update allocate_target_description to return a target_desc_up, a specialisation of unique_ptr. This commit does not attempt to make use of the unique_ptr in the best possible way, in almost all cases we immediately release the pointer from within the unique_ptr and then continue as before. There are a few places where it was easy to handle the unique_ptr, and in these cases I've done that. Everything under gdb/features/* is auto-regenerated. There should be no user visible changes after this commit. gdb/ChangeLog: * arch/aarch32.c (aarch32_create_target_description): Release unique_ptr returned from allocate_target_description. * arch/aarch64.c (aarch64_create_target_description): Likewise. * arch/amd64.c (amd64_create_target_description): Likewise. * arch/arc.c (arc_create_target_description): Likewise. * arch/arm.c (arm_create_target_description): Likewise. * arch/i386.c (i386_create_target_description): Likewise. * arch/riscv.c (riscv_create_target_description): Update return type. Handle allocate_target_description returning a unique_ptr. (riscv_lookup_target_description): Update to handle unique_ptr. * arch/tic6x.c (tic6x_create_target_description): Release unique_ptr returned from allocate_target_description. * features/microblaze-with-stack-protect.c: Regenerate. * features/microblaze.c: Regenerate. * features/mips-dsp-linux.c: Regenerate. * features/mips-linux.c: Regenerate. * features/mips64-dsp-linux.c: Regenerate. * features/mips64-linux.c: Regenerate. * features/nds32.c: Regenerate. * features/nios2.c: Regenerate. * features/or1k.c: Regenerate. * features/rs6000/powerpc-32.c: Regenerate. * features/rs6000/powerpc-32l.c: Regenerate. * features/rs6000/powerpc-403.c: Regenerate. * features/rs6000/powerpc-403gc.c: Regenerate. * features/rs6000/powerpc-405.c: Regenerate. * features/rs6000/powerpc-505.c: Regenerate. * features/rs6000/powerpc-601.c: Regenerate. * features/rs6000/powerpc-602.c: Regenerate. * features/rs6000/powerpc-603.c: Regenerate. * features/rs6000/powerpc-604.c: Regenerate. * features/rs6000/powerpc-64.c: Regenerate. * features/rs6000/powerpc-64l.c: Regenerate. * features/rs6000/powerpc-7400.c: Regenerate. * features/rs6000/powerpc-750.c: Regenerate. * features/rs6000/powerpc-860.c: Regenerate. * features/rs6000/powerpc-altivec32.c: Regenerate. * features/rs6000/powerpc-altivec32l.c: Regenerate. * features/rs6000/powerpc-altivec64.c: Regenerate. * features/rs6000/powerpc-altivec64l.c: Regenerate. * features/rs6000/powerpc-e500.c: Regenerate. * features/rs6000/powerpc-e500l.c: Regenerate. * features/rs6000/powerpc-isa205-32l.c: Regenerate. * features/rs6000/powerpc-isa205-64l.c: Regenerate. * features/rs6000/powerpc-isa205-altivec32l.c: Regenerate. * features/rs6000/powerpc-isa205-altivec64l.c: Regenerate. * features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c: Regenerate. * features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c: Regenerate. * features/rs6000/powerpc-isa205-vsx32l.c: Regenerate. * features/rs6000/powerpc-isa205-vsx64l.c: Regenerate. * features/rs6000/powerpc-isa207-htm-vsx32l.c: Regenerate. * features/rs6000/powerpc-isa207-htm-vsx64l.c: Regenerate. * features/rs6000/powerpc-isa207-vsx32l.c: Regenerate. * features/rs6000/powerpc-isa207-vsx64l.c: Regenerate. * features/rs6000/powerpc-vsx32.c: Regenerate. * features/rs6000/powerpc-vsx32l.c: Regenerate. * features/rs6000/powerpc-vsx64.c: Regenerate. * features/rs6000/powerpc-vsx64l.c: Regenerate. * features/rs6000/rs6000.c: Regenerate. * features/rx.c: Regenerate. * features/s390-gs-linux64.c: Regenerate. * features/s390-linux32.c: Regenerate. * features/s390-linux32v1.c: Regenerate. * features/s390-linux32v2.c: Regenerate. * features/s390-linux64.c: Regenerate. * features/s390-linux64v1.c: Regenerate. * features/s390-linux64v2.c: Regenerate. * features/s390-te-linux64.c: Regenerate. * features/s390-tevx-linux64.c: Regenerate. * features/s390-vx-linux64.c: Regenerate. * features/s390x-gs-linux64.c: Regenerate. * features/s390x-linux64.c: Regenerate. * features/s390x-linux64v1.c: Regenerate. * features/s390x-linux64v2.c: Regenerate. * features/s390x-te-linux64.c: Regenerate. * features/s390x-tevx-linux64.c: Regenerate. * features/s390x-vx-linux64.c: Regenerate. * mips-tdep.c (_initialize_mips_tdep): Release unique_ptr returned from allocate_target_description. * target-descriptions.c (allocate_target_description): Update return type. (print_c_tdesc::visit_pre): Release unique_ptr returned from allocate_target_description. gdbserver/ChangeLog: * linux-low.cc (linux_process_target::handle_extended_wait): Release the unique_ptr returned from allocate_target_description. * linux-riscv-low.cc (riscv_target::low_arch_setup): Likewise. * linux-x86-low.cc (tdesc_amd64_linux_no_xml): Change type. (tdesc_i386_linux_no_xml): Change type. (x86_linux_read_description): Borrow pointer from unique_ptr object. (x86_target::get_ipa_tdesc_idx): Likewise. (initialize_low_arch): Likewise. * tdesc.cc (allocate_target_description): Update return type. gdbsupport/ChangeLog: * tdesc.h (allocate_target_description): Update return type.
2020-09-11Add bfloat16 support for AVX512 register view.Felix Willgerodt1-0/+1
This adds support for the bfloat16 datatype, which can be seen as a short version of FP32, skipping the least significant 16 bits of the mantissa. Since the datatype is currently only supported by the AVX512 registers, the printing of bfloat16 values is only supported for xmm, ymm and zmm registers. gdb/ChangeLog: 2020-09-11 Moritz Riesterer <moritz.riesterer@intel.com> Felix Willgerodt <Felix.Willgerodt@intel.com> * gdbarch.sh: Added bfloat16 type. * gdbarch.c: Regenerated. * gdbarch.h: Regenerated. * gdbtypes.c (floatformats_bfloat16): New struct. (gdbtypes_post_init): Add builtin_bfloat16. * gdbtypes.h (struct builtin_type) <builtin_bfloat16>: New member. (floatformats_bfloat16): New struct. * i386-tdep.c (i386_zmm_type): Add field "v32_bfloat16" (i386_ymm_type): Add field "v16_bfloat16" (i386_gdbarch_init): Add set_gdbarch_bfloat16_format. * target-descriptions.c (make_gdb_type): Add case TDESC_TYPE_BFLOAT16. * gdbsupport/tdesc.cc (tdesc_predefined_types): New member bfloat16. * gdbsupport/tdesc.h (tdesc_type_kind): New member TDESC_TYPE_BFLOAT16. * features/i386/64bit-avx512.xml: Add bfloat16 type. * features/i386/64bit-avx512.c: Regenerated. * features/i386/64bit-sse.xml: Add bfloat16 type. * features/i386/64bit-sse.c: Regenerated. gdb/testsuite/ChangeLog: 2020-09-11 Moritz Riesterer <moritz.riesterer@intel.com> Felix Willgerodt <Felix.Willgerodt@intel.com> * x86-avx512bf16.c: New file. * x86-avx512bf16.exp: Likewise. * lib/gdb.exp (skip_avx512bf16_tests): New function.
2020-07-17gdb/riscv: delete target descriptions when gdb exitsAndrew Burgess1-0/+14
It was pointed out on IRC that the RISC-V target allocates target descriptions and stores them in a global map, and doesn't delete these target descriptions when GDB shuts down. This isn't a particular problem, the total number of target descriptions we can create is very limited so creating these on demand and holding them for the entire run on GDB seems reasonable. However, not deleting these objects on GDB exit means extra warnings are printed from tools like valgrind, and the address sanitiser, making it harder to spot real issues. As it's reasonably easy to have GDB correctly delete these objects on exit, lets just do that. I started by noticing that we already have a target_desc_up type, a wrapper around unique_ptr that calls a function that will correctly delete target descriptions, so I want to use that, but.... ...that type is declared in gdb/target-descriptions.h. If I try to include that file in gdb/arch/riscv.c I run into a problem, that file is compiled into both GDB and GDBServer. OK, I could guard the include with #ifdef, but surely we can do better. So then I decided to move the target_desc_up type into gdbsupport/tdesc.h, this is the interface file for generic code shared between GDB and GDBserver (relating to target descriptions). The actual implementation for the delete function still lives in gdb/target-description.c, but now gdb/arch/riscv.c can see the declaration. Problem solved.... ... but, though RISC-V doesn't use it I've now exposed the target_desc_up type to gdbserver, so in future someone _might_ start using it, which is fine, except right now there's no definition of the delete function - remember the delete I used is only defined in GDB code. No problem, I add an implementation of the delete operator into gdbserver/tdesc.cc, and all is good..... except.... I start getting this error from GCC: tdesc.cc:109:10: error: deleting object of polymorphic class type ‘target_desc’ which has non-virtual destructor might cause undefined behavior [-Werror=delete-non-virtual-dtor] Which is caused because gdbserver's target_desc type inherits from tdesc_element which has a virtual method, and so GCC worries that target_desc might be used as a base class. The solution is to declare gdbserver's target_desc class as final. This is fine so long as we never intent to inherit from target_desc (in gdbserver). But if we did then we'd want to make target_desc's destructor virtual anyway, so the error above would be resolved, and there wouldn't be an issue. gdb/ChangeLog: * arch/riscv.c (riscv_tdesc_cache): Change map type. (riscv_lookup_target_description): Return pointer out of unique_ptr. * target-descriptions.c (allocate_target_description): Add comment. (target_desc_deleter::operator()): Likewise. * target-descriptions.h (struct target_desc_deleter): Moved to gdbsupport/tdesc.h. (target_desc_up): Likewise. gdbserver/ChangeLog: * tdesc.cc (allocate_target_description): Add header comment. (target_desc_deleter::operator()): New function. * tdesc.h (struct target_desc): Declare as final. gdbsupport/ChangeLog: * tdesc.h (struct target_desc_deleter): Moved here from gdb/target-descriptions.h, extend comment. (target_desc_up): Likewise.
2020-06-27gdbsupport: add format attribute to print_xml_feature::add_lineSimon Marchi1-1/+1
Fixes this clang error: CXX tdesc.o /home/smarchi/src/binutils-gdb/gdbsupport/tdesc.cc:444:25: error: format string is not a string literal [-Werror,-Wformat-nonliteral] string_vappendf (tmp, fmt, ap); ^~~ There is already a but about GCC not emitting this warning: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82206 gdbsupport/ChangeLog: * tdesc.h (class print_xml_feature) <add_line>: Add ATTRIBUTE_PRINTF. Change-Id: I7014075e83717f6d7e19d044a3675ff9981ebe17
2020-06-23gdb: New maintenance command to print XML target descriptionAndrew Burgess1-1/+22
This commit adds a new maintenance command that dumps the current target description as an XML document. This is a maintenance command as I currently only see this being useful for GDB developers, or for people debugging a new remote target. By default the command will print whatever the current target description is, whether this was delivered by the remote, loaded by the user from a file, or if it is a built in target within GDB. The command can also take an optional filename argument. In this case GDB loads a target description from the file, and then reprints it. This could be useful for testing GDB's parsing of target descriptions, or to check that GDB can successfully parse a particular XML description. It is worth noting that the XML description printed will not be an exact copy of the document fed into GDB. For example this minimal input file: <target> <feature name="abc"> <reg name="r1" bitsize="32"/> </feature> </target> Will produce this output: (gdb) maint print xml-tdesc path/to/file.xml <?xml version="1.0"?> <!DOCTYPE target SYSTEM "gdb-target.dtd"> <target> <feature name="abc"> <reg name="r1" bitsize="32" type="int" regnum="0"/> </feature> </target> Notice that GDB filled in both the 'type' and 'regnum' fields of the <reg>. I think this is actually a positive as it means we get to really understand how GDB processed the document, if GDB made some assumptions that differ to those the user expected then hopefully this will bring those issues to the users attention. To implement this I have tweaked the output produced by the print_xml_feature which is defined within the gdbsupport/ directory. The changes I have made to this class are: 1. The <architecture>...</architecture> tags are now not produced if the architecture name is NULL. 2. The <osabi>...</osabi> tags get a newline at the end. 3. And, the whole XML document is indented using white space in a nested fashion (as in the example output above). I think that these changes should be fine, the print_xml_feature class is used: 1. In gdbserver to generate an XML document to send as the target description to GDB. 2. In GDB as part of a self-check function, a target_desc is converted to XML then parsed back into a target_desc. We then check the before and after target_desc objects are the same. 3. In the new 'maint print xml-tdesc' command. In all of these use cases adding the extra white space should be fine. gdbsupport/ChangeLog: * tdesc.cc (print_xml_feature::visit_pre): Use add_line to add output content, and call indent as needed in all overloaded variants. (print_xml_feature::visit_post): Likewise. (print_xml_feature::visit): Likewise. (print_xml_feature::add_line): Two new overloaded functions. * tdesc.h (print_xml_feature::indent): New member function. (print_xml_feature::add_line): Two new overloaded member functions. (print_xml_feature::m_depth): New member variable. gdb/ChangeLog: * target-descriptions.c (tdesc_architecture_name): Protect against NULL pointer dereference. (maint_print_xml_tdesc_cmd): New function. (_initialize_target_descriptions): Register new 'maint print xml-tdesc' command and give it the filename completer. * NEWS: Mention new 'maint print xml-tdesc' command. gdb/testsuite/ChangeLog: * gdb.xml/tdesc-reload.c: New file. * gdb.xml/tdesc-reload.exp: New file. * gdb.xml/maint-xml-dump-01.xml: New file. * gdb.xml/maint-xml-dump-02.xml: New file. * gdb.xml/maint-xml-dump.exp: New file. gdb/doc/ChangeLog: * gdb.texinfo (Maintenance Commands): Document new 'maint print xml-desc' command.
2020-06-23gdb: Print compatible information within print_xml_featureAndrew Burgess1-0/+21
The gdbsupport directory contains a helper class print_xml_feature that is shared between gdb and gdbserver. This class is used for printing an XML representation of a target_desc object. Currently this class doesn't have the ability to print the <compatible> entities that can appear within a target description, I guess no targets have needed that functionality yet. The print_xml_feature classes API is based around operating on the target_desc class, however, the sharing between gdb and gdbserver is purely textural, we rely on their being a class called target_desc in both gdb and gdbserver, but there is no shared implementation. We then have a set of functions declared that operate on an object of type target_desc, and again these functions have completely separate implementations. Currently then the gdb version of target_desc contains a vector of bfd_arch_info pointers which represents the compatible entries from a target description. The gdbserver version of target_desc has no such information. Further, the gdbserver code doesn't seem to include the bfd headers, and so doesn't know about the bfd types. I was reluctant to include the bfd headers into gdbserver just so I can reference the compatible information, which isn't (currently) even needed in gdbserver. So, the approach I take in this patch is to wrap the compatible information into a new helper class. This class is declared in the gdbsupport library, but implemented separately in both gdb and gdbserver. In gdbserver the class is empty. The compatible information within the gdbserver is an empty list, of empty classes. In gdb the class contains a pointer to the bfd_arch_info object. With this in place we can now add support to print_xml_feature for printing the compatible information if it is present. In the gdbserver code this will never happen, as the gdbserver never has any compatible information. But in gdb, this code will trigger when appropriate. gdb/ChangeLog: * target-descriptions.c (class tdesc_compatible_info): New class. (struct target_desc): Change type of compatible vector. (tdesc_compatible_p): Update for change in type of target_desc::compatible. (tdesc_compatible_info_list): New function. (tdesc_compatible_info_arch_name): New function. (tdesc_add_compatible): Update for change in type of target_desc::compatible. (print_c_tdesc::visit_pre): Likewise. gdbserver/ChangeLog: * tdesc.cc (struct tdesc_compatible_info): New struct. (tdesc_compatible_info_list): New function. (tdesc_compatible_info_arch_name): New function. gdbsupport/ChangeLog: * tdesc.cc (print_xml_feature::visit_pre): Print compatible information. * tdesc.h (struct tdesc_compatible_info): Declare new struct. (tdesc_compatible_info_up): New typedef. (tdesc_compatible_info_list): Declare new function. (tdesc_compatible_info_arch_name): Declare new function.
2020-01-14Move gdbsupport to the top levelTom Tromey1-0/+408
This patch moves the gdbsupport directory to the top level. This is the next step in the ongoing project to move gdbserver to the top level. The bulk of this patch was created by "git mv gdb/gdbsupport gdbsupport". This patch then adds a build system to gdbsupport and wires it into the top level. Then it changes gdb to use the top-level build. gdbserver, on the other hand, is not yet changed. It still does its own build of gdbsupport. ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * src-release.sh (GDB_SUPPORT_DIRS): Add gdbsupport. * MAINTAINERS: Add gdbsupport. * configure: Rebuild. * configure.ac (configdirs): Add gdbsupport. * gdbsupport: New directory, move from gdb/gdbsupport. * Makefile.def (host_modules, dependencies): Add gnulib. * Makefile.in: Rebuild. gdb/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * nat/x86-linux-dregs.c: Include configh.h. * nat/linux-ptrace.c: Include configh.h. * nat/linux-btrace.c: Include configh.h. * defs.h: Include config.h, bfd.h. * configure.ac: Don't source common.host. (CONFIG_OBS, CONFIG_SRCS): Remove gdbsupport files. * configure: Rebuild. * acinclude.m4: Update path. * Makefile.in (SUPPORT, LIBSUPPORT, INCSUPPORT): New variables. (CONFIG_SRC_SUBDIR): Remove gdbsupport. (INTERNAL_CFLAGS_BASE): Add INCSUPPORT. (CLIBS): Add LIBSUPPORT. (CDEPS): Likewise. (COMMON_SFILES): Remove gdbsupport files. (HFILES_NO_SRCDIR): Likewise. (stamp-version): Update path to create-version.sh. (ALLDEPFILES): Remove gdbsupport files. gdb/gdbserver/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * server.h: Include config.h. * gdbreplay.c: Include config.h. * configure: Rebuild. * configure.ac: Don't source common.host. * acinclude.m4: Update path. * Makefile.in (INCSUPPORT): New variable. (INCLUDE_CFLAGS): Add INCSUPPORT. (SFILES): Update paths. (version-generated.c): Update path to create-version.sh. (gdbsupport/%-ipa.o, gdbsupport/%.o): Update paths. gdbsupport/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * common-defs.h: Add GDBSERVER case. Update includes. * acinclude.m4, aclocal.m4, config.in, configure, configure.ac, Makefile.am, Makefile.in, README: New files. * Moved from ../gdb/gdbsupport/ Change-Id: I07632e7798635c1bab389bf885971e584fb4bb78