aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2020-05-25Use construct_inferior_arguments which handles special charsMichael Weghorn5-4/+17
Use the construct_inferior_arguments function instead of stringify_argv to construct a string from the program arguments in those places where that one is then passed to fork_inferior (linux-low, lyn-low), since construct_inferior_arguments properly takes care of special characters, while stringify_argv does not. Using construct_inferior_arguments seems "natural", since its documentation also mentions that it "does the same shell processing as fork_inferior". Since construct_inferior_args has been extended to do proper quoting for Windows shells in commit 5d60742e2dd3c9b475dce54b56043a358751bbb8 ("Fix quoting of special characters for the MinGW build.", 2012-06-12), use it for the Windows case as well. (I could not test that case myself, though.) Adapt handling of empty args in function 'handle_v_run' in gdbserver/server.cc to just insert an empty string for an empty arg, since that one is now properly handled in 'construct_inferior_arguments' already (and inserting a "''" string in 'handle_v_run' would otherwise cause that one to be treated as a string literally containing two quote characters, which 'construct_inferior_args' would preserve by adding extra escaping). This makes gdbserver properly handle program args containing special characters (like spaces), e.g. (example from PR25893) $ gdbserver localhost:50505 myprogram "hello world" now properly handles "hello world" as a single arg, not two separate ones ("hello", "world"). gdbserver/ChangeLog: PR gdbserver/25893 * linux-low.cc (linux_process_target::create_inferior), lynx-low.cc (lynx_process_target::create_inferior), win32-low.cc (win32_process_target::create_inferior): Use construct_inferior_arguments instead of stringify_argv to get string representation which properly escapes special characters. * server.cc (handle_v_run): Just pass empty program arg as such, since any further processing is now handled via construct_inferior_arguments. Change-Id: Ibf963fcd51415c948840fb463289516b3479b0c3
2020-05-25nto_process_target::create_inferior: Pass args as char **Michael Weghorn2-2/+6
According to [1], the fifth parameter to the 'spawnp' function is 'char * const argv[]', so just pass the args contained in the vector as an array right away, rather than converting that to a C string first and passing that one. With commit 2090129c36c7e582943b7d300968d19b46160d84 ("Share fork_inferior et al with gdbserver", 2016-12-22) the type had changed from 'char **' to 'char *', but I can't see an apparent reason for that, and 'nto_procfs_target::create_inferior' (in gdb/nto-procfs.c) also passes a 'char **' to 'spawnp' instead. I do not know much about that target and cannot actually test this, however. The main motivation to look at this was identifying and replacing the remaining uses of the 'stringify_argv' function which does not properly do escaping. [1] http://www.qnx.com/developers/docs/7.0.0/#com.qnx.doc.neutrino.lib_ref/topic/s/spawnp.html gdbserver/ChangeLog: * nto-low.cc (nto_process_target::create_inferior): Pass argv to spawnp function as char **. Change-Id: Ic46fe745c2aa1118114240d149d4156032f84344
2020-05-25gdbserver: Don't add extra NULL to program argsMichael Weghorn2-2/+5
The vector holding the program args is passed as a parameter to target_create_inferior, which then passes it to stringify_argv for all platforms, where any NULL entry in the vector is ignored, so there seems to be no reason to actually add one after all. (Since the intention is to replace uses of stringify_argv with construct_inferior_arguments in a follow-up commit and that function doesn't currently handle such NULL arguments, it would otherwise have to be extended.) gdbserver/ChangeLog: * server.cc (captured_main), (handle_v_run): No longer insert extra NULL element to args vector. Change-Id: Ia2ef6d36814a6b11ce8b0d6e3b33248a7945e825
2020-05-25gdbsupport: Let construct_inferior_arguments take gdb::array_view paramMichael Weghorn4-12/+20
Adapt the construct_inferior_arguments function to take a gdb::array_view<char * const> parameter instead of a char * array and an int indicating the length and adapt the only call site. This will allow calling it more simply in a follow-up patch introducing more uses of the function. gdbsupport/ChangeLog: * common-inferior.cc, common-inferior.h (construct_inferior_arguments): Adapt to take a gdb::array_view<char * const> parameter. Adapt call site. Change-Id: I1c6496c8c0b0eb3ef3fda96e9e3bd64c5e6cac3c
2020-05-25gdbsupport: Adapt construct_inferior_argumentsMichael Weghorn4-50/+32
Allow construct_inferior_arguments to handle zero args and have it return a std::string, similar to how stringify_argv in gdbsupport/common-utils does. Also, add a const qualifier for the second parameter, since it is only read, not written to. The intention is to replace existing uses of stringify_argv by construct_inferior_arguments in a subsequent step, since construct_inferior_arguments properly handles special characters, while stringify_argv doesn't. gdbsupport/ChangeLog: * common-inferior.cc, common-inferior.h (construct_inferior_arguments): Adapt to handle zero args and return a std::string. Adapt call site. Change-Id: I126c4390a1018c7527b0b8fd545252ab8a5a7adc
2020-05-25gdb: Move construct_inferior_arguments to gdbsupportMichael Weghorn6-126/+136
This moves the function construct_inferior_arguments from gdb/inferior.h and gdb/infcmd.c to gdbsupport/common-inferior.{h,cc}. While at it, also move the function's comment to the header file to align with current standards. The intention is to use it from gdbserver in a follow-up commit. gdb/ChangeLog: * infcmd.c, inferior.h: (construct_inferior_arguments): Moved function from here to gdbsupport/common-inferior.{h,cc} gdbsupport/ChangeLog: * common-inferior.h, common-inferior.cc: (construct_inferior_arguments): Move function here from gdb/infcmd.c, gdb/inferior.h Change-Id: Ib9290464ce8c0872f605d8829f88352d064c30d6
2020-05-25[gdb/testsuite] Add comment in exec_is_pieTom de Vries2-0/+7
Add comment to exec_is_pie explaining why readelf -d output is not used. gdb/testsuite/ChangeLog: 2020-05-25 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (exec_is_pie): Add comment.
2020-05-25ld-x86-64: Pass -z notext to linker for tests with DT_TEXTRELH.J. Lu2-2/+6
* testsuite/ld-x86-64/x86-64.exp: Pass -z notext to linker.
2020-05-25ld: Pass -z notext to linker for tests with DT_TEXTRELH.J. Lu35-49/+101
Some linker tests need DT_TEXTREL. Pass -z notext to linker for these tests so that they will pass with DT_TEXTREL check defaulting to warning or error. * testsuite/ld-elf/eh6.d: Pass -z notext to linker. * testsuite/ld-elf/ehdr_start-shared.d: Likewise. * testsuite/ld-elf/pr19539.d: Likewise. * testsuite/ld-elfvers/vers.exp: Likewise. * testsuite/ld-elfvsb/elfvsb.exp: Likewise. * testsuite/ld-i386/i386.exp: Likewise. * testsuite/ld-i386/nogot1.d: Likewise. * testsuite/ld-i386/pr19539.d: Likewise. * testsuite/ld-i386/pr19636-2a.d: Likewise. * testsuite/ld-i386/pr19636-2b.d: Likewise. * testsuite/ld-i386/pr19636-2c.d: Likewise. * testsuite/ld-i386/pr19636-2d.d: Likewise. * testsuite/ld-i386/pr19636-2e.d: Likewise. * testsuite/ld-i386/pr19636-3d.d: Likewise. * testsuite/ld-i386/pr19636-3e.d: Likewise. * testsuite/ld-i386/pr19939b.d: Likewise. * testsuite/ld-i386/undefweaka.d: Likewise. * testsuite/ld-i386/undefweakb.d: Likewise. * testsuite/ld-shared/shared.exp: Likewise. * testsuite/ld-size/size.exp: Likewise. * testsuite/ld-unique/unique.exp: Likewise. * testsuite/ld-x86-64/pie1.d: Likewise. * testsuite/ld-x86-64/pr19539a.d: Likewise. * testsuite/ld-x86-64/pr19539b.d: Likewise. * testsuite/ld-x86-64/pr19636-1d.d: Likewise. * testsuite/ld-x86-64/pr19636-1e.d: Likewise. * testsuite/ld-x86-64/pr19807-1a.d: Likewise. * testsuite/ld-x86-64/pr19807-1b.d: Likewise. * testsuite/ld-x86-64/pr19807-2b.d: Likewise. * testsuite/ld-x86-64/pr19807-2c.d: Likewise. * testsuite/ld-x86-64/pr19807-2d.d: Likewise. * testsuite/ld-x86-64/pr19807-2e.d: Likewise. * testsuite/ld-x86-64/pr19939b.d: Likewise. * testsuite/ld-x86-64/x86-64.exp: Likewise.
2020-05-25gas: Update fr_literal access in frag for GCC 10H.J. Lu4-3/+10
When access fr_literal in struct frag { ... /* Data begins here. */ char fr_literal[1]; }; with char *buf = fragp->fr_fix + fragp->fr_literal; GCC 10 gave gas/config/tc-csky.c: In function ‘md_convert_frag’: gas/config/tc-csky.c:4507:9: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] 4507 | buf[1] = BYTE_1 (CSKYV1_INST_SUBI | (7 << 4)); | ^ Change char *buf = fragp->fr_fix + fragp->fr_literal; to char *buf = fragp->fr_fix + &fragp->fr_literal[0]; to silence GCC 10 warning. * config/tc-csky.c (md_convert_frag): Replace fragp->fr_literal with &fragp->fr_literal[0]. * config/tc-microblaze.c (md_apply_fix): Likewise. * config/tc-sh.c (md_convert_frag): Likewise.
2020-05-25[gdb/testsuite] Fix var use in compile_and_download_n_jit_soTom de Vries2-1/+6
In commit 1b59ca1cf1 "[gdb/testsuite] Fix tcl error in jit-elf-helpers.exp", I introduced a variable f in compile_and_download_n_jit_so, to be used in the untested message, but actually variable binfile was used instead: ... + set f [file tail $binfile] + untested "failed to compile shared library $binfile" ... Fix this by using $f in the untested message. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-25 Tom de Vries <tdevries@suse.de> * lib/jit-elf-helpers.exp (compile_and_download_n_jit_so): Use $f instead of $binfile in the untested message.
2020-05-25[gdb/testsuite] Fix exec_is_pie with gold linkerTom de Vries2-2/+8
When running test-case gdb.base/break-interp.exp with target board gold, we run into: ... gdb compile failed, pie failed to generate PIE executable ... The problem is that the proc exec_is_pie uses the PIE flag in the readelf -d output, which doesn't seem to be set by the gold linker. Instead, use the "Type" field in the readelf -h output. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-25 Tom de Vries <tdevries@suse.de> PR testsuite/26031 * lib/gdb.exp (exec_is_pie): Test readelf -h output.
2020-05-25[gdb/testsuite] Add target board goldTom de Vries2-0/+36
Add a target board that uses the gold linker. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-25 Tom de Vries <tdevries@suse.de> * boards/gold.exp: New file.
2020-05-24Revert "Add completion styling"Tom Tromey10-148/+32
This reverts commit eca1f90cf47a2edc1a1cd22e12c6c0f3b900654e. Several changes were requested, and it seemed simplest to revert it. gdb/ChangeLog 2020-05-23 Tom Tromey <tom@tromey.com> Revert commit eca1f90c: * NEWS: Remove entry for completion styling. * completer.c (_rl_completion_prefix_display_length): Move declaration later. (gdb_fnprint): Revert. (gdb_display_match_list_1): Likewise. * cli/cli-style.c (completion_prefix_style) (completion_difference_style, completion_suffix_style): Remove. (_initialize_cli_style): Revert. * cli/cli-style.h (completion_prefix_style) (completion_difference_style, completion_suffix_style): Don't declare. gdb/doc/ChangeLog 2020-05-23 Tom Tromey <tom@tromey.com> * gdb.texinfo (Output Styling): Don't mention completion styling. (Editing): Don't mention readline completion styling. gdb/testsuite/ChangeLog 2020-05-23 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Remove completion styling test. * lib/gdb-utils.exp (style): Remove completion styles.
2020-05-25Automatic date update in version.inGDB Administrator1-1/+1
2020-05-24RISC-V: Gas inserts cfa relocs in wrong section.Jim Wilson2-1/+19
The frag code makes a distinction between inserting frags before the frag chains are chained together and afterward. After chaining, we need to set now_seg before creating the frag. tc-xtensa.c has a function called fix_new_exp_in_seg that handles this right, but switches segments twice each time it is called. In this case, we can inline it and pull the save and restore out of the loop to get better code. gas/ PR 26025 * config/tc-riscv.c (riscv_pre_output_hook): Change s type from const asection to segT. New locals seg and subseg. Call subseg_set before fix_new_exp. Call subseg_set after loop to restore original values.
2020-05-24gdb: make gdbarch.sh write gdbarch.{c,h} directlySimon Marchi3-55/+8
It was suggested in this thread [1] that gdbarch.sh should write to gdbarch.h and gdbarch.c directly. This patch implements that. When running gdbarch.sh, we currently need to move new-gdbarch.c over gdbarch.c and new-gdbarch.h over gdbarch.h. It might have been useful at some point to not have gdbarch.sh overwrite gdbarch.h and gdbarch.c, but with git it's really unnecessary. Any changes to gdbarch.sh can be inspected using `git diff`. A next step would be to have the Makefile automatically run gdbarch.sh if it sees that gdbarch.c and gdbarch.h are out of date. Or maybe even remove gdbarch.c and gdbarch.h from the tree and generate them in the build directory when building. But that requires more thinking and discussions, and I think that this change is already useful in itself. [1] https://sourceware.org/pipermail/gdb-patches/2020-May/168265.html gdb/ChangeLog; * gdbarch.sh: Write to gdbarch.c/gdbarch.h directly. Don't compare old and new versions. (compare_new): Remove. Change-Id: I7970a9e8af0afc0145cb5a28e73d94fbaa1e25b9
2020-05-24Don't remove C++ aliases from completions if symbol doesn't matchPedro Alves3-7/+19
completion_list_add_symbol currently tries to remove C++ function aliases from the completions match list even if the symbol passed down wasn't successfully added to the completion list because it didn't match. I.e., we call cp_canonicalize_string_no_typedefs for each and every C++ function in the program, which is useful work. This patch skips that useless work. gdb/ChangeLog: 2020-05-24 Pedro Alves <palves@redhat.com> * symtab.c (completion_list_add_name): Return boolean indication of whether the symbol matched. (completion_list_add_symbol): Don't try to remove C++ aliases if the symbol didn't match in the first place. * symtab.h (completion_list_add_name): Return bool.
2020-05-24ld: Handle --dynamic-list* before -Bsymbolic -Bsymbolic-functionsFangrui Song4-25/+37
--dynamic-list* should work both before and after -Bsymbolic and -Bsymbolic-functions. PR ld/26018 * lexsup.c (parse_args): Simplify. * testsuite/ld-elf/dl4e.out: New. * testsuite/ld-elf/shared.exp: Updated for PR ld/26018 tests.
2020-05-23ld: Add -Bsymbolic-functions testsH.J. Lu6-0/+49
PR ld/26018 * testsuite/ld-i386/i386.exp: Add a -Bsymbolic-functions test. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-i386/pr26018.d: New file. * testsuite/ld-x86-64/pr26018.d: Likewise. * testsuite/ld-x86-64/pr26018.s: Likewise.
2020-05-24Automatic date update in version.inGDB Administrator1-1/+1
2020-05-23gdb: remove TYPE_FIELD macroSimon Marchi31-81/+84
Replace all uses of it by type::field. Note that since type::field returns a reference to the field, some spots are used to assign the whole field structure. See ctfread.c, function attach_fields_to_type, for example. This is the same as was happening with the macro, so I don't think it's a problem, but if anybody sees a really nicer way to do this, now could be a good time to implement it. gdb/ChangeLog: * gdbtypes.h (TYPE_FIELD): Remove. Replace all uses with type::field.
2020-05-23Document the GDB 9.2 release in gdb/ChangeLogJoel Brobecker1-0/+4
gdb/ChangeLog: GDB 9.2 released.
2020-05-23Add completion stylingTom Tromey10-7/+172
Readline has a styling feature for completion -- if it is enabled, the common prefix of completions will be displayed in a different style. This doesn't work in gdb, because gdb implements its own completer. This patch implements the feature. However, it doesn't directly use the Readline feature, because gdb can do a bit better: it can let the user control the styling using the existing mechanisms. This version incorporates an Emacs idea, via Eli: style the prefix, the "difference character", and the suffix differently. gdb/ChangeLog 2020-05-23 Tom Tromey <tom@tromey.com> * NEWS: Add entry for completion styling. * completer.c (_rl_completion_prefix_display_length): Move declaration earlier. (gdb_fnprint): Use completion_style. (gdb_display_match_list_1): Likewise. * cli/cli-style.c (completion_prefix_style) (completion_difference_style, completion_suffix_style): New globals. (_initialize_cli_style): Register new globals. * cli/cli-style.h (completion_prefix_style) (completion_difference_style, completion_suffix_style): Declare. gdb/doc/ChangeLog 2020-05-23 Tom Tromey <tom@tromey.com> * gdb.texinfo (Output Styling): Mention completion styling. (Editing): Mention readline completion styling. gdb/testsuite/ChangeLog 2020-05-23 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Add completion styling test. * lib/gdb-utils.exp (style): Add completion styles.
2020-05-23Use safe-ctype.h (ISSPACE etc.) in symbol parsing & comparisonPedro Alves4-23/+88
This patch avoids depending on the current locale when parsing & comparing symbol names, by using libiberty's safe-ctype.h uppercase TOLOWER, ISXDIGIT, etc. macros instead of the standard ctype.h tolower, isxdigit, etc. macros/functions. This commit: commit b1b60145aedb8adcb0b9dcf43a5ae735c2f03b51 Author: Pedro Alves <palves@redhat.com> AuthorDate: Tue May 22 17:35:38 2018 +0100 Support UTF-8 identifiers in C/C++ expressions (PR gdb/22973) did something similar, except in the expression parser. This can improve GDB's symbol loading performance significantly. Currently strcmp_iw_ordered can show up high on profiles (called from sort_pst_symbols -> std::sort) because of the isspace and tolower functions. Hannes mentions seeing it as high as in ~24% of the profiling samples on Windows (https://sourceware.org/pipermail/gdb-patches/2020-May/168858.html). I tested GDB's performance (built with "-g -O2") loading a "-g -O0" build of gdb. I ran GDB 10 times like: /bin/time -f %e \ ./gdb/gdb --data-directory ./gdb/data-directory -nx \ -batch /tmp/gdb-g-O0 Then I computed the mean time. The baseline mean time was gdb 2.515 This patch brings the number down to gdb 2.096 Which is an around 16% improvement. gdb/ChangeLog: 2020-05-23 Pedro Alves <palves@redhat.com> * utils.c: Include "gdbsupport/gdb-safe-ctype.h". (parse_escape): Use ISDIGIT instead of isdigit. (puts_debug): Use gdb_isprint instead of isprint. (fprintf_symbol_filtered): Use ISALNUM instead of isalnum. (cp_skip_operator_token, skip_ws, strncmp_iw_with_mode): Use ISSPACE instead of isspace. (strncmp_iw_with_mode): Use TOLOWER instead of tolower and ISSPACE instead of isspace. (strcmp_iw_ordered): Use ISSPACE instead of isspace. (string_to_core_addr): Use TOLOWER instead of tolower, ISXDIGIT instead of isxdigit and ISDIGIT instead of isdigit. gdbsupport/ChangeLog: 2020-05-23 Pedro Alves <palves@redhat.com> * gdb-safe-ctype.h: New.
2020-05-23Fix potential segfaultAlan Modra2-2/+7
Code in vms-lib.c leaves arch_header NULL. * bfdio.c (bfd_get_file_size): Don't segfault on NULL arch_header.
2020-05-23ar many_files testAlan Modra2-0/+60
This tests for the issue fixed with git commit 0490dd41ae. * testsuite/binutils-all/ar.exp (many_files): New test.
2020-05-23Automatic date update in version.inGDB Administrator1-1/+1
2020-05-22gdb: remove TYPE_FIELDS macroSimon Marchi12-32/+42
Remove all uses of the `TYPE_FIELDS` macro. Replace them with either: 1) type::fields, to obtain a pointer to the fields array (same as TYPE_FIELDS yields) 2) type::field, a new convenience method that obtains a reference to one of the type's field by index. It is meant to replace TYPE_FIELDS (type)[idx] with type->field (idx) gdb/ChangeLog: * gdbtypes.h (struct type) <field>: New method. (TYPE_FIELDS): Remove, replace all uses with either type::fields or type::field. Change-Id: I49fba10114417deb502060c6156aa5f7fc62462f
2020-05-22gdb: add type::fields / type::set_fieldsSimon Marchi14-86/+114
Add the `fields` and `set_fields` methods on `struct type`, in order to remove the `TYPE_FIELDS` macro. In this patch, the `TYPE_FIELDS` macro is changed to the `type::fields`, so all the call sites that use it to set the fields array are changed to use `type::set_fields`. The next patch will remove `TYPE_FIELDS` entirely. gdb/ChangeLog: * gdbtypes.h (struct type) <fields, set_fields>: New methods. (TYPE_FIELDS): Use type::fields. Change all call sites that modify the propery to use type::set_fields instead. Change-Id: I05174ce68f2ce3fccdf5d8b469ff141f14886b33
2020-05-22gdb: remove TYPE_NFIELDS macroSimon Marchi68-318/+322
Remove `TYPE_NFIELDS`, changing all the call sites to use `type::num_fields` directly. This is quite a big diff, but this was mostly done using sed and coccinelle. A few call sites were done by hand. gdb/ChangeLog: * gdbtypes.h (TYPE_NFIELDS): Remove. Change all cal sites to use type::num_fields instead. Change-Id: Ib73be4c36f9e770e0f729bac3b5257d7cb2f9591
2020-05-22gdb: add type::num_fields / type::set_num_fieldsSimon Marchi14-43/+62
Add the `num_fields` and `set_num_fields` methods on `struct type`, in order to remove the `TYPE_NFIELDS` macro. In this patch, the `TYPE_NFIELDS` macro is changed to use `type::num_fields`, so all the call sites that are used to set the number of fields are changed to use `type::set_num_fields`. The next patch will remove `TYPE_NFIELDS` completely. I think that in the future, we should consider making the interface of `struct type` better. For example, right now it's possible for the number of fields property and the actual number of fields set to be out of sync. However, I want to keep the existing behavior in this patch, just translate from macros to methods. gdb/ChangeLog: * gdbtypes.h (struct type) <num_fields, set_num_fields>: New methods. (TYPE_NFIELDS): Use type::num_fields. Change all call sites that modify the number of fields to use type::set_num_fields instead. Change-Id: I5ad9de5be4097feaf942d111077434bf91d13dc5
2020-05-22Remove obsolete declarationTom Tromey2-1/+5
Commit c9e0a7e3331 ("Remove munmap_listp_free_cleanup") removed munmap_listp_free, but missed a declaration. This patch removes that as well. gdb/ChangeLog 2020-05-22 Tom Tromey <tromey@adacore.com> * compile/compile-object-load.h (munmap_list_free): Don't declare.
2020-05-22gdb: Restore old annotations behaviour when printing frame infoAndrew Burgess9-20/+73
This undoes most of the changes from these commits: commit ec8e2b6d3051f0b4b2a8eee9917898e95046c62f Date: Fri Jun 14 23:43:00 2019 +0100 gdb: Don't allow annotations to influence what else GDB prints commit 0d3abd8cc936360f8c46502135edd2e646473438 Date: Wed Jun 12 22:34:26 2019 +0100 gdb: Remove an update of current_source_line and current_source_symtab as a result of the discussion here: https://sourceware.org/pipermail/gdb/2020-April/048468.html Having taken time to reflect on the discussion, and reading the documentation again I believe we should revert GDB's behaviour back to how it used to be. The original concern that triggered the initial patch was that when annotations were on the current source and line were updated (inside the annotation code), while when annotations are off this update would not occur. This was incorrect, as printing the source with the call to print_source_lines does also update the current source and line. Further, the documentation here: https://sourceware.org/gdb/current/onlinedocs/gdb/Source-Annotations.html#Source-Annotations Clearly states: "The following annotation is used instead of displaying source code: ^Z^Zsource filename:line:character:middle:addr ..." So it is documented that the 'source' annotation is a replacement for, and not in addition to, actually printing the source lie. There are still a few issues that I can see, these are: 1. In source.c:info_line_command, when annotations are on we call annotate_source_line, however, if annotations are off then there is no corresponding call to print the source line. This means that a if a user uses 'info line ...' with annotations on, and then does a 'list', they will get different results than if they had done this with annotations off. 2. It bothers me that the call to annotate_source_line returns a boolean, and that this controls a call to print_source_line (in stack.c:print_frame_info). The reason for this is that the source line annotation will only print something if the file is found, and the line number is in range for the file. It seems to me like an annotation should always be printed, either one that identifies the file and line, or one that identifies the file and line GDB would like to access, but couldn't. I considered changing this, but in the end decided not too, if I extend the existing 'source' annotation to print something in all cases then I risk breaking existing UIs that rely on the file and line always being valid. If I add a new annotation then this might also break existing UIs that rely on GDB itself printing the error from within print_source_line. Given that annotations is deprecated (as I understand it) mechanism for UIs to interact with GDB (in favour of MI) I figure we should just restore the old behaviour, and leave the mini-bugs in until someone actually complains. This isn't a straight revert of the two commits mentioned above. I've left annotate_source_line instead of going back to the original identify_source_line, which lived in source.c, but was really annotation related. The API for setting the current source and line has changed since the original patches, so I updated for that change too. Finally I wrote the code in stack.c so that we avoided an extra level of indentation, which I felt made things easier to read. gdb/ChangeLog: * annotate.c (annotate_source_line): Update return type, add call to update current symtab and line. * annotate.h (annotate_source_line): Update return type, and extend header comment. * source.c (info_line_command): Check annotation_level before calling annotate_source_line. * stack.c (print_frame_info): If calling annotate_source_line returns true, then don't print any other source line information. gdb/testsuite/ChangeLog: * gdb.base/annota1.exp: Update expected results. * gdb.cp/annota2.exp: Update expected results, remove duplicate test name. * gdb.cp/annota3.exp: Update expected results.
2020-05-22PowerPC: downgrade FP mismatch error for shared libraries to a warningAlan Modra4-28/+73
PR 25882 bfd/ * elf32-ppc.c (_bfd_elf_ppc_merge_fp_attributes): Don't init FP attributes from shared libraries, and do not return an error if they don't match. gold/ * powerpc.cc (merge_object_attributes): Replace name param with obj param. Update callers. Don't init FP attributes from shared libraries, and do not emit an error if they don't match.
2020-05-22Automatic date update in version.inGDB Administrator1-1/+1
2020-05-21gdb: fix -Wtautological-overlap-compare error in lm32-tdep.cSimon Marchi2-1/+5
Building with clang 11, we get: /home/smarchi/src/binutils-gdb/gdb/lm32-tdep.c:84:44: error: overlapping comparisons always evaluate to false [-Werror,-Wtautological-overlap-compare] return ((regnum >= SIM_LM32_EA_REGNUM) && (regnum <= SIM_LM32_BA_REGNUM)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Indeed, this doesn't make sense, as EA_REGNUM is greater than BA_REGNUM. I'll assume that it was just a mistake and that these two should be swapped. The regnums for BA and EA are contiguous, so ultimately this particular part of the condition is only true if regnum is == EA or == BA. These registers are Exception Address and Breakpoint Address, so I guess it makes sense for them to be in the system register group. The relevant reference is here: https://www.latticesemi.com/-/media/LatticeSemi/Documents/UserManuals/JL/LatticeMico32ProcessorReferenceManual39.ashx?document_id=52077 gdb/ChangeLog: * lm32-tdep.c (lm32_register_reggroup_p): Fix condition.
2020-05-21gdb: remove unnecessary NULL checks before xfreeSimon Marchi11-22/+24
I was inspired by a series of patches merged by Alan Modra in the other projects, so I did the same in GDB with a bit of Coccinelle and grep. This patch removes the unnecessary NULL checks before calls to xfree. They are unnecessary because xfree already does a NULL check. Since free is supposed to handle NULL values correctly, the NULL check in xfree itself is also questionable, but I've left it there for now. gdb/ChangeLog: * coffread.c (patch_type): Remove NULL check before xfree. * corefile.c (set_gnutarget): Likewise. * cp-abi.c (set_cp_abi_as_auto_default): Likewise. * exec.c (build_section_table): Likewise. * remote.c (remote_target::pass_signals): Likewise. * utils.c (n_spaces): Likewise. * cli/cli-script.c (document_command): Likewise. * i386-windows-tdep.c (core_process_module_section): Likewise. * linux-fork.c (struct fork_info) <~fork_info>: Likewise.
2020-05-21Re: PR25993, read of freed memoryAlan Modra2-0/+34
git commit 7b958a48e132 put the bfd filename in the bfd objalloc memory. That means the filename is freed by _bfd_free_cached_info. Which is called by _bfd_compute_and_write_armap to tidy up symbol tables after they are done with. Unfortunately, _bfd_write_archive_contents wants to seek and read from archive elements after that point, and if the number of elements exceeds max_open_files in cache.c then some of those elements will have their files closed. To reopen, you need the filename. PR 25993 * opncls.c (_bfd_free_cached_info): Keep a copy of the bfd filename. (_bfd_delete_bfd): Free the copy. (_bfd_new_bfd): Free nbfd->memory on error.
2020-05-21Replace "if (x) free (x)" with "free (x)", opcodesAlan Modra22-196/+94
cpu/ * mep.opc (mep_cgen_expand_macros_and_parse_operand): Replace "if (x) free (x)" with "free (x)". opcodes/ * arc-ext.c: Replace "if (x) free (x)" with "free (x)" throughout. * sparc-dis.c: Likewise. * tic4x-dis.c: Likewise. * xtensa-dis.c: Likewise. * bpf-desc.c: Regenerate. * epiphany-desc.c: Regenerate. * fr30-desc.c: Regenerate. * frv-desc.c: Regenerate. * ip2k-desc.c: Regenerate. * iq2000-desc.c: Regenerate. * lm32-desc.c: Regenerate. * m32c-desc.c: Regenerate. * m32r-desc.c: Regenerate. * mep-asm.c: Regenerate. * mep-desc.c: Regenerate. * mt-desc.c: Regenerate. * or1k-desc.c: Regenerate. * xc16x-desc.c: Regenerate. * xstormy16-desc.c: Regenerate.
2020-05-21Replace "if (x) free (x)" with "free (x)", ldAlan Modra14-84/+56
* deffilep.y: Replace "if (x) free (x)" with "free (x)" thoughout. * emultempl/elf.em: Likewise. * emultempl/msp430.em: Likewise. * emultempl/pe.em: Likewise. * emultempl/pep.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/xtensaelf.em: Likewise. * ldelf.c: Likewise. * ldfile.c: Likewise. * ldmain.c: Likewise. * ldmisc.c: Likewise. * lexsup.c: Likewise. * pe-dll.c: Likewise.
2020-05-21Replace "if (x) free (x)" with "free (x)", gprofAlan Modra2-4/+6
* utils.c (print_name_only): Free demangled without checking first for non-NULL.
2020-05-21Replace "if (x) free (x)" with "free (x)", gasAlan Modra13-52/+41
* atof-generic.c: Replace "if (x) free (x)" with "free (x)" throughout. * config/obj-elf.c: Likewise. * config/tc-aarch64.c: Likewise. * config/tc-arm.c: Likewise. * config/tc-m68k.c: Likewise. * config/tc-nios2.c: Likewise. * config/tc-tic30.c: Likewise. * ecoff.c: Likewise. * read.c: Likewise. * stabs.c: Likewise. * symbols.c: Likewise. * testsuite/gas/all/test-gen.c: Likewise.
2020-05-21Replace "if (x) free (x)" with "free (x)", binutilsAlan Modra10-176/+92
* addr2line.c: Replace "if (x) free (x)" with "free (x)" throughout. * dlltool.c: Likewise. * elfcomm.c: Likewise. * rddbg.c: Likewise. * readelf.c: Likewise. * stabs.c: Likewise. * windmc.c: Likewise. * windres.c: Likewise. * wrstabs.c: Likewise.
2020-05-21Replace "if (x) free (x)" with "free (x)", bfdAlan Modra79-1285/+657
* aoutx.h: Replace "if (x) free (x)" with "free (x)" throughout. * archive.c, * bfd.c, * bfdio.c, * coff-alpha.c, * coff-ppc.c, * coff-sh.c, * coff-stgo32.c, * coffcode.h, * coffgen.c, * cofflink.c, * cpu-arm.c, * doc/chew.c, * dwarf2.c, * ecoff.c, * ecofflink.c, * elf-eh-frame.c, * elf-m10200.c, * elf-m10300.c, * elf-strtab.c, * elf.c, * elf32-arc.c, * elf32-arm.c, * elf32-avr.c, * elf32-bfin.c, * elf32-cr16.c, * elf32-crx.c, * elf32-epiphany.c, * elf32-ft32.c, * elf32-h8300.c, * elf32-ip2k.c, * elf32-m32c.c, * elf32-m68hc11.c, * elf32-m68k.c, * elf32-microblaze.c, * elf32-msp430.c, * elf32-nds32.c, * elf32-nios2.c, * elf32-ppc.c, * elf32-pru.c, * elf32-rl78.c, * elf32-rx.c, * elf32-sh.c, * elf32-spu.c, * elf32-v850.c, * elf32-xtensa.c, * elf64-alpha.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mips.c * elf64-mmix.c, * elf64-ppc.c, * elf64-sparc.c, * elfcode.h, * elflink.c, * elfnn-ia64.c, * elfnn-riscv.c, * elfxx-mips.c, * elfxx-x86.c, * format.c, * ihex.c, * libbfd.c, * linker.c, * mmo.c, * opncls.c, * pdp11.c, * peXXigen.c, * pef.c, * peicode.h, * simple.c, * som.c, * srec.c, * stabs.c, * syms.c, * targets.c, * vms-lib.c, * xcofflink.c, * xtensa-isa.c: Likewise.
2020-05-21asan: readelf: wild read in get_num_dynamic_symsAlan Modra2-1/+7
* readelf.c (get_num_dynamic_syms): Bounds check mipsxlat array access.
2020-05-21Automatic date update in version.inGDB Administrator1-1/+1
2020-05-20gdb: reset/recompute objfile section offsets in reread_symbolsSimon Marchi2-0/+14
This patch started as an investigation of this bug, where the program is re-compiled between two "start" runs: $ ./gdb -nx --data-directory=data-directory -q a.out Reading symbols from a.out... (gdb) start Temporary breakpoint 1 at 0x1131: file test.c, line 1. Starting program: /home/smarchi/build/wt/test/gdb/a.out Temporary breakpoint 1, main () at test.c:1 1 int main() { return 0; } *** re-compile a.out *** (gdb) start The program being debugged has been started already. Start it from the beginning? (y or n) y `/home/smarchi/build/wt/test/gdb/a.out' has changed; re-reading symbols. Temporary breakpoint 2 at 0x555555555129: file test.c, line 1. Starting program: /home/smarchi/build/wt/test/gdb/a.out warning: Probes-based dynamic linker interface failed. Reverting to original interface. Temporary breakpoint 2, main () at test.c:1 1 int main() { return 0; } (gdb) To reproduce the bug, a.out needs to be a position-independent executable (PIE). Here's what happens: 1) We first read the symbols of a.out. The section offsets in the objfile are all 0, so the symbols are created unrelocated. 2) The breakpoint on main is created, as you can see the breakpoint address (derived from the `main` symbol with value 0x1129) is still unrelocated (0x1131). Since the program is not yet started, we don't know at which base address the executable is going to end at. Everything good so far. 3) The execution starts, GDB finds out the executable's base address, fills the objfile's section_offsets vector with a bunch of offsets, and relocates the symbols with those offsets. The latter modifies the symbol values (the `main` symbol is changed from 0x1129 to 0x555555555129). 4) We `start` again, we detect that `a.out` has changed, the `reread_symbols` function kicks in. It tries to reset everything in the `struct objfile` corresponding to `a.out`, except that it leaves the `section_offsets` vector there. 5) `reread_symbols` reads the debug info (calls `read_symbols`). As the DWARF info is read, symbols are created using the old offsets still in `section_offsets`. For example, the `main` symbol is created with the value 0x555555555129. Even though at this point there is no process, so that address is bogus. There's probably more that depends on section_offsets that is not done correctly. 6) Something in the SVR4 solib handling goes wrong, probably because of something that went wrong in (5). I can't quite explain it (if somebody would like to provide a more complete analysis, please go ahead). But this is where it takes a wrong turn: #0 elf_locate_base () at /home/smarchi/src/wt/test/gdb/solib-svr4.c:799 #1 0x000055f0a5bee6d5 in locate_base (info=<optimized out>) at /home/smarchi/src/wt/test/gdb/solib-svr4.c:848 #2 0x000055f0a5bf1771 in svr4_handle_solib_event () at /home/smarchi/src/wt/test/gdb/solib-svr4.c:1955 #3 0x000055f0a5c0ff92 in handle_solib_event () at /home/smarchi/src/wt/test/gdb/solib.c:1258 In the non-working case (without this patch), elf_locate_base returns 0, whereas in the working case (with this patch) it returns a valid address, as we should expect. This patch fixes this by making reread_symbols clear the `section_offsets` vector, and re-create it by calling `sym_offsets`. This is analogous to what syms_from_objfile_1 does. I didn't seem absolutely necessary, but I also made it clear the various `sect_index_*` fields, since their values no longer make sense (they describe the old executable, and are indices in the now cleared sections/section_offsets arrays). I don't really like the approach taken by reread_symbols, trying to reset everything manually on the objfile object, instead of, for example, creating a new one from scratch. But I don't know enough yet to propose a better solution. One more reason I think this patch is needed is that the number of sections of the new executable could be different from the number of sections of the old executable. So if we don't re-create the section_offsets array, not only we'll have wrong offsets, but we could make accesses past the array. Something else that silently fails (but doesn't seem to have consequences) is the prologue analysis when we try to create the breakpoint on `main`. Since the `main` symbol has the wrong value 0x555555555129, we try to access memory in that area, which fails. This can be observed by debugging gdb and using `catch throw`. Before the process is started, we need to access the memory at its unrelocated address, 0x1129, which will read memory from the ELF file. This is now what happens, with this patch applied. It silently fails, probably because commit 46a62268b, "Catch exceptions thrown from gdbarch_skip_prologue", papered over the problem and added an empty catch clause. I'm quite sure that the root cause then was the one fixed by this patch. This fixes tests gdb.ada/exec_changed.exp and gdb.base/reread.exp for me. gdb/ChangeLog: * symfile.c (reread_symbols): Clear objfile's section_offsets vector and section indices, re-compute them by calling sym_offsets.
2020-05-20[PATCH v2 0/9] RISC-V: Support version controling for ISA standard ↵Nelson Chu71-4344/+7015
extensions and CSR 1. Remove the -mriscv-isa-version and --with-riscv-isa-version options. We can still use -march to choose the version for each extensions, so there is no need to add these. 2. Change the arguments of options from [1p9|1p9p1|...] to [1.9|1.9.1|...]. Unlike the architecture string has specified by spec, ther is no need to do the same thing for options. 3. Spilt the patches to reduce the burdens of review. [PATCH 3/7] RISC-V: Support new GAS options and configure options to set ISA versions to [PATCH v2 3/9] RISC-V: Support GAS option -misa-spec to set ISA versions [PATCH v2 4/9] RISC-V: Support configure options to set ISA versions by default. [PATCH 4/7] RISC-V: Support version checking for CSR according to privilege version. to [PATCH v2 5/9] RISC-V: Support version checking for CSR according to privilege spec version. [PATCH v2 6/9] RISC-V: Support configure option to choose the privilege spec version. 4. Use enum class rather than string to compare the choosen ISA spec in opcodes/riscv-opc.c. The behavior is same as comparing the choosen privilege spec. include * opcode/riscv.h: Include "bfd.h" to support bfd_boolean. (enum riscv_isa_spec_class): New enum class. All supported ISA spec belong to one of the class (struct riscv_ext_version): New structure holds version information for the specific ISA. * opcode/riscv-opc.h (DECLARE_CSR): There are two version information, define_version and abort_version. The define_version means which privilege spec is started to define the CSR, and the abort_version means which privilege spec is started to abort the CSR. If the CSR is valid for the newest spec, then the abort_version should be PRIV_SPEC_CLASS_DRAFT. (DECLARE_CSR_ALIAS): Same as DECLARE_CSR, but only for the obselete CSR. * opcode/riscv.h (enum riscv_priv_spec_class): New enum class. Define the current supported privilege spec versions. (struct riscv_csr_extra): Add new fields to store more information about the CSR. We use these information to find the suitable CSR address when user choosing a specific privilege spec. binutils * dwarf.c: Updated since DECLARE_CSR is changed. opcodes * riscv-opc.c (riscv_ext_version_table): The table used to store all information about the supported spec and the corresponding ISA versions. Currently, only Zicsr is supported to verify the correctness of Z sub extension settings. Others will be supported in the future patches. (struct isa_spec_t, isa_specs): List for all supported ISA spec classes and the corresponding strings. (riscv_get_isa_spec_class): New function. Get the corresponding ISA spec class by giving a ISA spec string. * riscv-opc.c (struct priv_spec_t): New structure. (struct priv_spec_t priv_specs): List for all supported privilege spec classes and the corresponding strings. (riscv_get_priv_spec_class): New function. Get the corresponding privilege spec class by giving a spec string. (riscv_get_priv_spec_name): New function. Get the corresponding privilege spec string by giving a CSR version class. * riscv-dis.c: Updated since DECLARE_CSR is changed. * riscv-dis.c: Add new disassembler option -Mpriv-spec to dump the CSR according to the chosen version. Build a hash table riscv_csr_hash to store the valid CSR for the chosen pirv verison. Dump the direct CSR address rather than it's name if it is invalid. (parse_riscv_dis_option_without_args): New function. Parse the options without arguments. (parse_riscv_dis_option): Call parse_riscv_dis_option_without_args to parse the options without arguments first, and then handle the options with arguments. Add the new option -Mpriv-spec, which has argument. * riscv-dis.c (print_riscv_disassembler_options): Add description about the new OBJDUMP option. ld * testsuite/ld-riscv-elf/attr-merge-arch-01.d: Updated priv attributes according to the -mpriv-spec option. * testsuite/ld-riscv-elf/attr-merge-arch-02.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-arch-03.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-a.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec-b.s: Likewise. * testsuite/ld-riscv-elf/attr-merge-priv-spec.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-stack-align.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-01.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-02.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-03.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-04.d: Likewise. * testsuite/ld-riscv-elf/attr-merge-strict-align-05.d: Likewise. bfd * elfxx-riscv.h (riscv_parse_subset_t): Add new callback function get_default_version. It is used to find the default version for the specific extension. * elfxx-riscv.c (riscv_parsing_subset_version): Remove the parameters default_major_version and default_minor_version. Add new bfd_boolean parameter *use_default_version. Set it to TRUE if we need to call the callback rps->get_default_version to find the default version. (riscv_parse_std_ext): Call rps->get_default_version if we fail to find the default version in riscv_parsing_subset_version, and then call riscv_add_subset to add the subset into subset list. (riscv_parse_prefixed_ext): Likewise. (riscv_std_z_ext_strtab): Support Zicsr extensions. * elfnn-riscv.c (riscv_merge_std_ext): Use strcasecmp to compare the strings rather than characters. riscv_merge_arch_attr_info): The callback function get_default_version is only needed for assembler, so set it to NULL int the linker. * elfxx-riscv.c (riscv_estimate_digit): Remove the static. * elfxx-riscv.h: Updated. gas * testsuite/gas/riscv/priv-reg-fail-read-only-01.s: Updated. * config/tc-riscv.c (default_arch_with_ext, default_isa_spec): Static variables which are used to set the ISA extensions. You can use -march (or ELF build attributes) and -misa-spec to set them, respectively. (ext_version_hash): The hash table used to handle the extensions with versions. (init_ext_version_hash): Initialize the ext_version_hash according to riscv_ext_version_table. (riscv_get_default_ext_version): The callback function of riscv_parse_subset_t. According to the choosed ISA spec, get the default version for the specific extension. (riscv_set_arch): Set the callback function. (enum options, struct option md_longopts): Add new option -misa-spec. (md_parse_option): Do not call riscv_set_arch for -march. We will call it later in riscv_after_parse_args. Call riscv_get_isa_spec_class to set default_isa_spec class. (riscv_after_parse_args): Call init_ext_version_hash to initialize the ext_version_hash, and then call riscv_set_arch to set the architecture with versions according to default_arch_with_ext. * testsuite/gas/riscv/attribute-02.d: Set 0p0 as default version for x extensions. * testsuite/gas/riscv/attribute-03.d: Likewise. * testsuite/gas/riscv/attribute-09.d: New testcase. For i-ext, we already set it's version to 2p1 by march, so no need to use the default 2p2 version. For m-ext, we do not set the version by -march and ELF arch attribute, so set the default 2p0 to it. For zicsr, it is not defined in ISA spec 2p2, so set 0p0 to it. * testsuite/gas/riscv/attribute-10.d: New testcase. The version of zicsr is 2p0 according to ISA spec 20191213. * config/tc-riscv.c (DEFAULT_RISCV_ARCH_WITH_EXT) (DEFAULT_RISCV_ISA_SPEC): Default configure option settings. You can set them by configure options --with-arch and --with-isa-spec, respectively. (riscv_set_default_isa_spec): New function used to set the default ISA spec. (md_parse_option): Call riscv_set_default_isa_spec rather than call riscv_get_isa_spec_class directly. (riscv_after_parse_args): If the -isa-spec is not set, then we set the default ISA spec according to DEFAULT_RISCV_ISA_SPEC by calling riscv_set_default_isa_spec. * testsuite/gas/riscv/attribute-01.d: Add -misa-spec=2.2, since the --with-isa-spec may be set to different ISA spec. * testsuite/gas/riscv/attribute-02.d: Likewise. * testsuite/gas/riscv/attribute-03.d: Likewise. * testsuite/gas/riscv/attribute-04.d: Likewise. * testsuite/gas/riscv/attribute-05.d: Likewise. * testsuite/gas/riscv/attribute-06.d: Likewise. * testsuite/gas/riscv/attribute-07.d: Likewise. * configure.ac: Add configure options, --with-arch and --with-isa-spec. * configure: Regenerated. * config.in: Regenerated. * config/tc-riscv.c (default_priv_spec): Static variable which is used to check if the CSR is valid for the chosen privilege spec. You can use -mpriv-spec to set it. (enum reg_class): We now get the CSR address from csr_extra_hash rather than reg_names_hash. Therefore, move RCLASS_CSR behind RCLASS_MAX. (riscv_init_csr_hashes): Only need to initialize one hash table csr_extra_hash. (riscv_csr_class_check): Change the return type to void. Don't check the ISA dependency if -mcsr-check isn't set. (riscv_csr_version_check): New function. Check and find the CSR address from csr_extra_hash, according to default_priv_spec. Report warning for the invalid CSR if -mcsr-check is set. (reg_csr_lookup_internal): Updated. (reg_lookup_internal): Likewise. (md_begin): Updated since DECLARE_CSR and DECLARE_CSR_ALIAS are changed. (enum options, struct option md_longopts): Add new GAS option -mpriv-spec. (md_parse_option): Call riscv_set_default_priv_version to set default_priv_spec. (riscv_after_parse_args): If -mpriv-spec isn't set, then set the default privilege spec to the newest one. (enum riscv_csr_class, struct riscv_csr_extra): Move them to include/opcode/riscv.h. * testsuite/gas/riscv/priv-reg-fail-fext.d: This test case just want to check the ISA dependency for CSR, so fix the spec version by adding -mpriv-spec=1.11. * testsuite/gas/riscv/priv-reg-fail-fext.l: Likewise. There are some version warnings for the test case. * gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.d: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-read-only-02.d: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.d: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d: New test case. Check whether the CSR is valid when privilege version 1.9 is choosed. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d: New test case. Check whether the CSR is valid when privilege version 1.9.1 is choosed. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d: New test case. Check whether the CSR is valid when privilege version 1.10 is choosed. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l: Likewise. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d: New test case. Check whether the CSR is valid when privilege version 1.11 is choosed. * gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l: Likewise. * config/tc-riscv.c (DEFAULT_RISCV_ISA_SPEC): Default configure option setting. You can set it by configure option --with-priv-spec. (riscv_set_default_priv_spec): New function used to set the default privilege spec. (md_parse_option): Call riscv_set_default_priv_spec rather than call riscv_get_priv_spec_class directly. (riscv_after_parse_args): If -mpriv-spec isn't set, then we set the default privilege spec according to DEFAULT_RISCV_PRIV_SPEC by calling riscv_set_default_priv_spec. * testsuite/gas/riscv/csr-dw-regnums.d: Add -mpriv-spec=1.11, since the --with-priv-spec may be set to different privilege spec. * testsuite/gas/riscv/priv-reg.d: Likewise. * configure.ac: Add configure option --with-priv-spec. * configure: Regenerated. * config.in: Regenerated. * config/tc-riscv.c (explicit_attr): Rename explicit_arch_attr to explicit_attr. Set it to TRUE if any ELF attribute is found. (riscv_set_default_priv_spec): Try to set the default_priv_spec if the priv attributes are set. (md_assemble): Set the default_priv_spec according to the priv attributes when we start to assemble instruction. (riscv_write_out_attrs): Rename riscv_write_out_arch_attr to riscv_write_out_attrs. Update the arch and priv attributes. If we don't set the corresponding ELF attributes, then try to output the default ones. (riscv_set_public_attributes): If any ELF attribute or -march-attr options is set (explicit_attr is TRUE), then call riscv_write_out_attrs to update the arch and priv attributes. (s_riscv_attribute): Make sure all arch and priv attributes are set before any instruction. * testsuite/gas/riscv/attribute-01.d: Update the priv attributes if any ELF attribute or -march-attr is set. If the priv attributes are not set, then try to update them by the default setting (-mpriv-spec or --with-priv-spec). * testsuite/gas/riscv/attribute-02.d: Likewise. * testsuite/gas/riscv/attribute-03.d: Likewise. * testsuite/gas/riscv/attribute-04.d: Likewise. * testsuite/gas/riscv/attribute-06.d: Likewise. * testsuite/gas/riscv/attribute-07.d: Likewise. * testsuite/gas/riscv/attribute-08.d: Likewise. * testsuite/gas/riscv/attribute-09.d: Likewise. * testsuite/gas/riscv/attribute-10.d: Likewise. * testsuite/gas/riscv/attribute-unknown.d: Likewise. * testsuite/gas/riscv/attribute-05.d: Likewise. Also, the priv spec set by priv attributes must be supported. * testsuite/gas/riscv/attribute-05.s: Likewise. * testsuite/gas/riscv/priv-reg-fail-version-1p9.d: Likewise. Updated priv attributes according to the -mpriv-spec option. * testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d: Likewise. * testsuite/gas/riscv/priv-reg-fail-version-1p10.d: Likewise. * testsuite/gas/riscv/priv-reg-fail-version-1p11.d: Likewise. * testsuite/gas/riscv/priv-reg.d: Removed. * testsuite/gas/riscv/priv-reg-version-1p9.d: New test case. Dump the CSR according to the priv spec 1.9. * testsuite/gas/riscv/priv-reg-version-1p9p1.d: New test case. Dump the CSR according to the priv spec 1.9.1. * testsuite/gas/riscv/priv-reg-version-1p10.d: New test case. Dump the CSR according to the priv spec 1.10. * testsuite/gas/riscv/priv-reg-version-1p11.d: New test case. Dump the CSR according to the priv spec 1.11. * config/tc-riscv.c (md_show_usage): Add descriptions about the new GAS options. * doc/c-riscv.texi: Likewise.
2020-05-20gdb/testsuite: check mmap ret val against MAP_FAILEDSimon Marchi5-3/+19
Fixup a few spots in the testsuite that use mmap to consistently check the return value against MAP_FAILED. One spot in gdb.base/coredump-filter.c checked against NULL, that is wrong. The other spots either didn't check, or checked against -1. MAP_FAILED has the value -1, at least on Linux, but it's better to check against the documented define. gdb/testsuite/ChangeLog: PR gdb/26016 * gdb.base/coredump-filter.c (do_mmap): Check mmap ret val against MAP_FAILED. * gdb.base/coremaker.c (mmapdata): Likewise. * gdb.base/jit-reader-host.c (main): Likewise. * gdb.base/sym-file-loader.c (load): Likewise. (load_shlib): Likewise.