aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2019-12-20ubsan: or1k: left shift of negative valueAlan Modra4-4/+12
cpu/ * or1korbis.cpu (f-disp26, f-disp21): Don't left shift negative values. opcodes/ * or1k-ibld.c: Regenerate.
2019-12-20ubsan: xtensa: left shift cannot be represented in type 'int'Alan Modra2-1/+5
* xtensa-isa.c (xtensa_insnbuf_from_chars): Avoid signed overflow.
2019-12-20ubsan: hppa: left shift of negative valueAlan Modra4-60/+56
bfd/ * libhppa.h (hppa_field_adjust, bfd_hppa_insn2fmt): Delete forward declaration. Move ATTRIBUTE_UNUSED to definition. (sign_extend, low_sign_extend, sign_unext, low_sign_unext), (re_assemble_3, re_assemble_12, re_assemble_14, re_assemble_16), (re_assemble_17, re_assemble_21, re_assemble_22): Likewise. Make args and return value unsigned. Use unsigned variables. (hppa_rebuild_insn): Similarly. opcodes/ * hppa-dis.c (extract_16, extract_21, print_insn_hppa): Use unsigned variables.
2019-12-20ubsan: m68hc1x: left shift of negative valueAlan Modra2-105/+81
* m68hc11-dis.c (read_memory): Delete forward decls. (print_indexed_operand, print_insn): Likewise. (print_indexed_operand): Formatting. Don't rely on short being exactly 16 bits, make sign extension explicit. (print_insn): Likewise. Avoid signed overflow.
2019-12-20bfd_check_format memory leakAlan Modra2-0/+7
* format.c (bfd_check_format_matches): Free matching_vector when not returning matching target strings.
2019-12-20coff-alpha memory leakAlan Modra2-1/+8
* coff-alpha.c (alpha_ecoff_read_ar_hdr): Free ar_hdr on error return.
2019-12-20Automatic date update in version.inGDB Administrator1-1/+1
2019-12-19Consistently quote variables used with "test"Christian Biesinger7-72/+83
This ensures that empty variables and variables with spaces are handled correctly. Code was inconsistent on whether the constant string (e.g. yes/no) should also be quoted; I tried to be consistent with surrounding code. This fixes the error Eli reported during configure with mingw (though that was not fatal). gdb/ChangeLog: 2019-12-19 Christian Biesinger <cbiesinger@google.com> * configure: Regenerate. * configure.ac: Quote variable arguments of test. * gdbsupport/common.m4: Likewise. gdb/gdbserver/ChangeLog: 2019-12-19 Christian Biesinger <cbiesinger@google.com> * configure: Regenerate. * configure.ac: Quote variable arguments of test. Change-Id: I220e78b52c7db88b9dd058eda604635b03464fac
2019-12-19Fix build with GNU Make 3.81Bernd Edlinger2-4/+8
GNU Make 3.81 is apparently confused when the same source file is processed by a pattern rule and an explicit rule at the same time with different output file. The pattern %.o: ../%.c and alloc-ipa.o: ../alloc.c both have the source ../alloc.c but two independent object files alloc.o and alloc-ipa.o, so while building gdbserver I see the following message: make[4]: Circular alloc-ipa.o <- ../alloc.c dependency dropped. CXX alloc-ipa.o g++: warning: '-x c++' after last input file has no effect g++: fatal error: no input files compilation terminated. In the make debug output I see the pattern is first correct: alloc-ipa.o: ../alloc.c | config.h build-gnulib-gdbserver/import/string.h $(IPAGENT_COMPILE) $(WARN_CFLAGS_NO_FORMAT) $< $(POSTCOMPILE) But after the "Circular" dependency is dropped, the pattern is changed to: alloc-ipa.o: | config.h build-gnulib-gdbserver/import/string.h $(IPAGENT_COMPILE) $(WARN_CFLAGS_NO_FORMAT) $< $(POSTCOMPILE) So indeed now $< is empty, and the build step fails. This happens only when alloc.o needs to be built, when alloc.o was already built, the build succeeds, but it takes often several attempts until the build succeeds. By rewriting the alloc-ipa.c: ../alloc.c rule into a pattern rule, the problem goes away. While already at it, this patch removes also the $(WARN_CFLAGS_NO_FORMAT) from the build rule, which is just a copy/paste thing that is not necessary for alloc.c at all.
2019-12-19Make the literal argument to pow a double, not an integerChristian Biesinger2-2/+9
Since pow takes doubles, pass 2.0 instead of 2 to pow (). Conveniently, this fixes the ambiguous call to pow on Solaris 11 with gcc 5.5 (gcc211 on the compile farm), which has a "using std::pow" directive in a system header, which brings in float/double/long double overloads. Fixes the build on Solaris with enable-targets=all. gdb/ChangeLog: 2019-12-19 Christian Biesinger <cbiesinger@google.com> * score-tdep.c (score7_analyze_prologue): Pass 2.0 instead of 2 to pow (). Change-Id: Ib18e7e4749ddcbff0727b72a31198f8cb84d1993
2019-12-19Cast the log10 argument to double to disambiguate itChristian Biesinger2-1/+8
On Solaris 11 with gcc 5.5.0 (gcc211 on the compile farm), math.h has a using std::log10; directive. This is unfortunate because std::log10 has overloads for float/double/long double. To disambiguate this call, cast the argument to double to fix the build. gdb/ChangeLog: 2019-12-19 Christian Biesinger <cbiesinger@google.com> * tui/tui-source.c (tui_source_window::set_contents): Cast argument of log10 to double to fix Solaris 11 with gcc 5.5. Change-Id: I6c0c52e9c172b529c899a435d430e5916aeef69f
2019-12-19Rename "sun" variable to avoid conflicts on SolarisChristian Biesinger2-4/+9
A Solaris system header has a #define for "sun". This renames that variable to avoid the conflict, fixing a build error with --enable-targets=all on Solaris. gdb/ChangeLog: 2019-12-19 Christian Biesinger <cbiesinger@google.com> * fbsd-tdep.c (fbsd_info_proc_files_entry): Rename local var "sun" to "saddr_un". Change-Id: I07a5cd801db1e28ccab8a473ebad74d7afe017c2
2019-12-19Add install-strip to sim/Tom Tromey10-0/+43
PR build/24572 notes that "make install-strip" fails. For me, it works in every directory except "sim", so this patch adds install-strip targets to the Makefiles that appear there. sim/ChangeLog 2019-12-19 Tom Tromey <tromey@adacore.com> PR build/24572: * Makefile.in (install-strip): New target. sim/common/ChangeLog 2019-12-19 Tom Tromey <tromey@adacore.com> PR build/24572: * Makefile.in (install-strip): New target. sim/igen/ChangeLog 2019-12-19 Tom Tromey <tromey@adacore.com> PR build/24572: * Makefile.in (install-strip): New target. sim/ppc/ChangeLog 2019-12-19 Tom Tromey <tromey@adacore.com> PR build/24572: * Makefile.in (install-strip): New target. sim/testsuite/ChangeLog 2019-12-19 Tom Tromey <tromey@adacore.com> PR build/24572: * Makefile.in (install-strip): New target. Change-Id: I76613bc5c7e7812284f33826f8a5d914477fcdc5
2019-12-19Fix comment in field_kindTom Tromey2-3/+7
Christian pointed out that the new comment in field_kind is un-grammatical. This fixes it. gdb/ChangeLog 2019-12-19 Tom Tromey <tromey@adacore.com> * ui-out.h (enum class field_kind): Fix comment. Change-Id: I6608ff18e29f1af98a0ff77012afe28b3d4602f4
2019-12-19Handle CRLF when reading XML on WindowsTom Tromey4-5/+22
xml-support.c uses FOPEN_RT, but then reads the entire contents of the file and verifies that the number of bytes read matches the length. This can fail on Windows, where the read will translate line terminators. This patch fixes the bug by changing xml-support.c to use FOPEN_RB. This works because expat correctly handles \r\n line terminators. gdb/ChangeLog 2019-12-11 Tom Tromey <tromey@adacore.com> * xml-support.c (xml_fetch_content_from_file): Use FOPEN_RB. gdb/testsuite/ChangeLog 2019-12-11 Tom Tromey <tromey@adacore.com> * gdb.xml/tdesc-arch.exp (set_arch): Add "trans_mode" parameter. Add crlf test. Change-Id: I548438f33eed284dde1de8babf755eaa1a40319d
2019-12-19xcoff slurp_armap bounds checkingAlan Modra3-6/+40
"count * 8 >= size" might overflow, "count >= size / 8" doesn't. * coff-rs6000.c (_bfd_xcoff_slurp_armap): Don't overflow when checking symbol count against section size. Guard against strlen running off end of buffer by allocating one more byte and zeroing. * coff64-rs6000.c (xcoff64_slurp_armap): Likewise.
2019-12-19vax decoding of indexed addressing modeAlan Modra2-2/+16
This patch prevents print_insn_mode recursing into another index mode byte, which if repeated enough times will overflow private.the_buffer and scribble over other memory. * vax-dis.c (print_insn_mode): Stop index mode recursion.
2019-12-19PowerPC, use size_t rather than long for indicesAlan Modra3-3/+9
This is fussing about nothing really but since I was looking at signed vs. unsigned issues, I decided to use the correct types here. * elf32-ppc.c (ppc_elf_get_synthetic_symtab): Use size_t for vars. * elf64-ppc.c (sym_exists_at): Use size_t for lo, hi and mid.
2019-12-19Re: Enable --build-id for moxie-elf-ldAlan Modra2-1/+4
* testsuite/lib/ld-lib.exp (uses_genelf): Remove moxie.
2019-12-19PR25277, microblaze opcode enumeration vs ISO/IEC TS 18661-3:2015Dr N.W. Filardo3-4/+11
fadd, fmul, and fdiv are now, by ISO/IEC TS 18661-3:2015, defined to refer to functions from the runtime subsystem. PR 25277 * microblaze-opcm.h (enum microblaze_instr): Prefix fadd, fmul and fdiv with "mbi_". * microblaze-opc.h (opcodes): Adjust to suit.
2019-12-19Automatic date update in version.inGDB Administrator1-1/+1
2019-12-18Update gdb.base/default.exp for GDB 10Simon Marchi2-1/+5
Now that the version number in master has been bumped to 10, I get this failure: FAIL: gdb.base/default.exp: show convenience ($_gdb_major = 9 not found) Update the test accordingly. gdb/testsuite/ChangeLog: * gdb.base/default.exp: Update value of $_gdb_major.
2019-12-182019-12-18 Anthony Green <green@moxielogic.com>Anthony Green3-3/+7
* emulparams/elf32moxie.sh (TEMPLATE_NAME): Switch to elf template to enable --build-id. * configure.tgt: Don't define targ_extra_ofiles for moxie-*-*.
2019-12-18Fix pthread_setname_np build errorTom Tromey2-1/+9
My earlier patch to fix the pthread_setname_np build error on macOS was incorrect. While the macOS man page claims that pthread_setname_np returns void, in <pthread.h> it is actually declared returning "int". I knew this earlier, but must have made some mistake when preparing the patch for submission (perhaps when removing the templates?). This patch re-fixes the bug. I'm also applying it to the 9.1 branch. Tested by building on macOS High Sierra. gdb/ChangeLog 2019-12-18 Tom Tromey <tromey@adacore.com> PR build/25268: * gdbsupport/thread-pool.c (set_thread_name): Expect "int" return type on macOS. Add comment. Change-Id: Ib09da6ac33958a0d843f65df2a528112356e7de6
2019-12-18Fix indentation (and clang warning) in c-lang.cSimon Marchi2-5/+10
I see this warning when building with clang: CXX c-lang.o /home/smarchi/src/binutils-gdb/gdb/c-lang.c:314:7: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] *length = i * width; ^ /home/smarchi/src/binutils-gdb/gdb/c-lang.c:308:4: note: previous statement is here if (extract_unsigned_integer (contents + i * width, ^ It took me a while to notice that some lines in that area have a spurious space before the tabs, at the beginning of the ling. I'm not sure how clang translates that to misleading indentation, but making the indentation correct gets rid of the error. There are many more instances of this in the code base (`grep -P '^ \t' *.c`), if others think it's a good idea, it would be pretty easy to fix them all up in one shot. gdb/ChangeLog: * c-lang.c (c_get_string, asm_language_defn): Remove space before tab.
2019-12-18Fix build failure on macOSTom Tromey3-6/+18
PR build/25250 notes that the gdb 9 pre-release fails to build on macOS, due to a name clash between field_kind::STRING and the STRING token in ada-exp.y. I am not sure (I couldn't reproduce this myself), but presumably this is due to differences caused by the version of bison in use there. This patch works around the problem by renaming the field_kind enumerator. I chose to rename this one because it is used in relatively few places -- it's just an implementation detail of the style code. This version also renames field_kind::SIGNED for consistency. Let me know what you think. I intend to check this in on the gdb 9 branch as well. gdb/ChangeLog 2019-12-18 Tom Tromey <tromey@adacore.com> PR build/25250: * ui-out.c (ui_out::vmessage): Update. * ui-out.h (enum class field_kind) <FIELD_STRING, FIELD_SIGNED>: Rename. (string_field): Update. (signed_field): Update. Change-Id: Iae9f36f1b793e22c61fee0de2ab2d508668ee7e4
2019-12-18Fix -Wmisleading-indentation warning in top.cSimon Marchi2-3/+26
When building top.c with this clang (daily build from apt.llvm.org): $ clang++-10 --version clang version 10.0.0-+20191211091425+f99297176cd-1~exp1~20191211082036.1372 I get: /home/smarchi/src/binutils-gdb/gdb/top.c:1549:5: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] fprintf_filtered (stream, _("\n\ ^ /home/smarchi/src/binutils-gdb/gdb/top.c:1543:3: note: previous statement is here if (SYSTEM_GDBINIT_DIR[0]) ^ This looks like a legitimate warning, the fprintf_filtered is too much indented. Fix it, and at the same time add a bit of whitespace to make this function easier to read. gdb/ChangeLog: * top.c (print_gdb_configuration): Adjust indentation.
2019-12-18ld signed overflow fixAlan Modra2-2/+6
* pe-dll.c (pe_get32, pe_as32): Avoid signed overflow.
2019-12-18Yet more signed overflow fixesAlan Modra7-110/+122
* elf-bfd.h (ELF_LOCAL_SYMBOL_HASH): Avoid signed overflow. * elf32-hppa.c (final_link_relocate): Likewise. * elf32-ppc.c (_bfd_elf_ppc_at_tls_transform): Likewise. (_bfd_elf_ppc_at_tprel_transform, is_insn_ds_form): Likewise. (is_insn_dq_form, ppc_elf_relocate_section): Likewise. * elf64-ppc.c (ok_lo_toc_insn, ppc64_elf_edit_toc): Likewise. (ppc64_elf_relocate_section): Likewise. * elfxx-mips.c (mips_elf_perform_relocation): Likewise. * netbsd.h (N_SET_FLAGS): Likewise.
2019-12-18More signed overflow fixesAlan Modra12-59/+70
The arc fix in create_map avoiding signed overflow by casting an unsigned char to unsigned int before shifting, shows one of the dangers of blinding doing that. The problem in this case was that the variable storing the value, newAuxRegister->address, was a long. Using the unsigned cast meant that the 32-bit value was zero extended when long is 64 bits. Previously we had a sign extension. Net result was that comparisons in arcExtMap_auxRegName didn't match. Of course, I could have cast the 32-bit unsigned value back to signed before storing in a long, but it's neater to just use an unsigned int for the address. opcodes/ * alpha-opc.c (OP): Avoid signed overflow. * arm-dis.c (print_insn): Likewise. * mcore-dis.c (print_insn_mcore): Likewise. * pj-dis.c (get_int): Likewise. * ppc-opc.c (EBD15, EBD15BI): Likewise. * score7-dis.c (s7_print_insn): Likewise. * tic30-dis.c (print_insn_tic30): Likewise. * v850-opc.c (insert_SELID): Likewise. * vax-dis.c (print_insn_vax): Likewise. * arc-ext.c (create_map): Likewise. (struct ExtAuxRegister): Make "address" field unsigned int. (arcExtMap_auxRegName): Pass unsigned address. (dump_ARC_extmap): Adjust. * arc-ext.h (arcExtMap_auxRegName): Update prototype.
2019-12-18Automatic date update in version.inGDB Administrator1-1/+1
2019-12-17Add missing include to bsd-kvm.c for gdb_abspathChristian Biesinger2-0/+5
Commit ff8577f64987a898e1dc5eb6afb66a404fb7bb16 added a call to gdb_abspath in bsd-kvm.c, but doesn't include its header file. This commit fixes that. gdb/ChangeLog: 2019-12-17 Christian Biesinger <cbiesinger@google.com> * bsd-kvm.c: Include gdbsupport/pathstuff.h. Change-Id: I647c3620d8ae978ae27c38dbe0b3347a97c5bfc2
2019-12-17Add virtual destructor to tui_layout_baseSimon Marchi2-0/+7
I stumbled on some ASan failures when using the TUI, when tearing down a TUI layout. The simplest way to trigger it is to run: $ ./gdb --data-directory=data-directory -batch -ex "layout next" The ASan report is: ================================================================= ==2829136==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x608000009a20 in thread T0: object passed to delete has wrong type: size of the allocated type: 88 bytes; size of the deallocated type: 24 bytes. #0 0x7f470fe2507e in operator delete(void*, unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cc:177 #1 0x55f88c75700d in std::default_delete<tui_layout_base>::operator()(tui_layout_base*) const /usr/include/c++/9.2.0/bits/unique_ptr.h:81 #2 0x55f88c756328 in std::unique_ptr<tui_layout_base, std::default_delete<tui_layout_base> >::~unique_ptr() /usr/include/c++/9.2.0/bits/unique_ptr.h:284 #3 0x7f470ee536a6 in __run_exit_handlers (/usr/lib/libc.so.6+0x3e6a6) #4 0x7f470ee5385d in __GI_exit (/usr/lib/libc.so.6+0x3e85d) #5 0x55f88c69f2ac in quit_force(int*, int) /home/simark/src/binutils-gdb/gdb/top.c:1766 #6 0x55f88becc29a in captured_main_1 /home/simark/src/binutils-gdb/gdb/main.c:1183 #7 0x55f88becc814 in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1192 #8 0x55f88becc8a9 in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1217 #9 0x55f88b3159cd in main /home/simark/src/binutils-gdb/gdb/gdb.c:32 #10 0x7f470ee3c152 in __libc_start_main (/usr/lib/libc.so.6+0x27152) #11 0x55f88b31579d in _start (/home/simark/build/binutils-gdb/gdb/gdb+0x11fb79d) 0x608000009a20 is located 0 bytes inside of 88-byte region [0x608000009a20,0x608000009a78) allocated by thread T0 here: #0 0x7f470fe238f8 in operator new(unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cc:104 #1 0x55f88c750906 in tui_layout_split::clone() const /home/simark/src/binutils-gdb/gdb/tui/tui-layout.c:515 #2 0x55f88c74e60e in show_layout /home/simark/src/binutils-gdb/gdb/tui/tui-layout.c:90 #3 0x55f88c74e7db in tui_set_layout(tui_layout_type) /home/simark/src/binutils-gdb/gdb/tui/tui-layout.c:116 #4 0x55f88c782f4f in tui_enable() /home/simark/src/binutils-gdb/gdb/tui/tui.c:481 #5 0x55f88c74eeb2 in tui_layout_command /home/simark/src/binutils-gdb/gdb/tui/tui-layout.c:286 #6 0x55f88b6f969b in do_const_cfunc /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:107 #7 0x55f88b701859 in cmd_func(cmd_list_element*, char const*, int) /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:1952 #8 0x55f88c69b455 in execute_command(char const*, int) /home/simark/src/binutils-gdb/gdb/top.c:652 #9 0x55f88bec9026 in catch_command_errors /home/simark/src/binutils-gdb/gdb/main.c:400 #10 0x55f88becc1f2 in captured_main_1 /home/simark/src/binutils-gdb/gdb/main.c:1167 #11 0x55f88becc814 in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1192 #12 0x55f88becc8a9 in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1217 #13 0x55f88b3159cd in main /home/simark/src/binutils-gdb/gdb/gdb.c:32 #14 0x7f470ee3c152 in __libc_start_main (/usr/lib/libc.so.6+0x27152) The problem is that the tui_layout_base is missing a virtual destructor. We allocate a derived object (tui_layout_split), but delete it through a tui_layout_base pointer. Since the tui_layout_base destructor is not virtual, the derived (tui_layout_split) destructor is not called, only the base destructor. That code is not in gdb-9-branch, so I don't think this patch is relevant for the stable branch. Note that this is caught as a diagnostic with clang: In file included from /home/simark/src/binutils-gdb/gdb/tui/tui-layout.c:22: In file included from /home/simark/src/binutils-gdb/gdb/defs.h:28: In file included from /home/simark/src/binutils-gdb/gdb/gdbsupport/common-defs.h:133: In file included from /home/simark/src/binutils-gdb/gdb/gdbsupport/common-exceptions.h:25: In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0/memory:80: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0/bits/unique_ptr.h:81:2: error: delete called on 'tui_layout_base' that is abstract but has non-virtual destructor [-Werror,-Wdelete-abstract-non-virtual-dtor] delete __ptr; ^ /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0/bits/unique_ptr.h:284:4: note: in instantiation of member function 'std::default_delete<tui_layout_base>::operator()' requested here get_deleter()(std::move(__ptr)); ^ /home/simark/src/binutils-gdb/gdb/tui/tui-layout.c:54:41: note: in instantiation of member function 'std::unique_ptr<tui_layout_base, std::default_delete<tui_layout_base> >::~unique_ptr' requested here static std::unique_ptr<tui_layout_base> applied_layout; ^ 1 error generated. GCC has the similar -Wdelete-non-virtual-dtor, enabled by -Wall, but it doesn't show up because warnings are inhibited for system headers, where std::unique_ptr is defined. There is a bug about it here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58876 gdb/ChangeLog: * tui/tui-layout.h (class tui_layout_base): Add virtual destructor.
2019-12-17Fix skip.exp test failure observed with gcc-9.2.0Bernd Edlinger2-5/+15
We need to step a second time with this gcc version. The first step jumps back to main before entering foo. Previously the control flow was from bar directly to foo. Further ananlysis suggests, that this change in behavior started with gcc-8.1.0 when -gcolumn-info was enabled by default. The option -gcolumn-info was first implemented in gcc-7.1.0 but default-disabled, so you can get the altered behavior already with gcc-7 if you manually enable -gcolumn-info. Previously there was just one point where line 30 (of skip.c) started: [0x00000032] Advance Line by 27 to 28 [0x00000034] Copy [0x00000035] Special opcode 63: advance Address by 4 to 0x4004cb and Line by 2 to 30 [0x00000036] Advance PC by constant 17 to 0x4004dc [0x00000037] Special opcode 7: advance Address by 0 to 0x4004dc and Line by 2 to 32 But with -gcolumn-info enabled, we have line 30 three times with different column: [0x00000034] Advance Line by 27 to 28 [0x00000036] Copy [0x00000037] Set column to 9 [0x00000039] Special opcode 63: advance Address by 4 to 0x4004c6 and Line by 2 to 30 [0x0000003a] Set column to 17 [0x0000003c] Special opcode 75: advance Address by 5 to 0x4004cb and Line by 0 to 30 [0x0000003d] Set column to 3 [0x0000003f] Special opcode 75: advance Address by 5 to 0x4004d0 and Line by 0 to 30 [0x00000040] Special opcode 105: advance Address by 7 to 0x4004d7 and Line by 2 to 32 That could probably be filtered in dwarf2read.c to keep the old behavior, but the new behavior makes still sense, even if we cannot really make use of the column in the line number info for now.
2019-12-17Whitespace fix in gdb.base/skip.expBernd Edlinger2-2/+6
Just use tabs instead of spaces here.
2019-12-17ubsan: visium: left shift cannot be represented in type 'int'Alan Modra2-1/+5
* visium-dis.c (print_insn_visium): Avoid signed overflow.
2019-12-17ubsan: aarch64: left shift cannot be represented in type 'int64_t'Alan Modra3-13/+20
* aarch64-opc.c (value_fit_signed_field_p): Avoid signed overflow. (value_fit_unsigned_field_p): Likewise. (aarch64_wide_constant_p): Likewise. (operand_general_constraint_met_p): Likewise. * aarch64-opc.h (aarch64_wide_constant_p): Update prototype.
2019-12-17ubsan: nds32: left shift cannot be represented in type 'int'Alan Modra2-9/+15
Yet more. * nds32-dis.c (nds32_mask_opcode): Avoid signed overflow. (print_insn_nds32): Use uint64_t for "given" and "given1".
2019-12-17Prefer object over notype symbols when disassemblingAlan Modra43-41/+164
Changing objdump disassembly output like this always requires some testsuite changes, with the avr and x64_64 changes simply due to picking up better symbols, the whole point of the patch. The mips changes are due to mips-sgi-irix changing STT_NOTYPE symbols to STT_OBJECT, which objdump now chooses in preference to script symbols. The problem is that objdump looks at the first symbol in the section being disassembled, and if object type, just dumps out bytes rather than disassembling. This results in new failures: FAIL: JAL overflow 2 FAIL: undefined weak symbol overflow FAIL: undefined weak symbol overflow (n32) FAIL: undefined weak symbol overflow (n64) So for mips-sgi-irix function symbols really do need to be function type. I fixed a few more than just the required minimum to avoid the above test fails. binutils/ * objdump.c (compare_section): New static var. (compare_symbols): Sort by current section only. Don't access symbol name out of bounds when checking for file symbols. Sort section symbols and object symbols. (find_symbol_for_address): Remove bogus debugging and section symbol test. (disassemble_data): Move symbol sort from here.. (disassemble_section): ..to here. Set compare_section. ld/ * testsuite/ld-avr/lds-mega.d: Adjust symbols to suit objdump change. * testsuite/ld-avr/lds-tiny.d: Likewise. * testsuite/ld-x86-64/load2.d: Likewise. * testsuite/ld-mips-elf/compact-eh1.s: Give function symbols function type. * testsuite/ld-mips-elf/compact-eh1a.s: Likewise. * testsuite/ld-mips-elf/compact-eh1b.s: Likewise. * testsuite/ld-mips-elf/compact-eh2.s: Likewise. * testsuite/ld-mips-elf/compact-eh3.s: Likewise. * testsuite/ld-mips-elf/compact-eh3a.s: Likewise. * testsuite/ld-mips-elf/eh-frame5.s: Likewise. * testsuite/ld-mips-elf/ehdr_start-new.s: Likewise. * testsuite/ld-mips-elf/ehdr_start-o32.s: Likewise. * testsuite/ld-mips-elf/emit-relocs-1a.s: Likewise. * testsuite/ld-mips-elf/jaloverflow-2.s: Likewise. * testsuite/ld-mips-elf/jaloverflow.s: Likewise. * testsuite/ld-mips-elf/mips16-call-global-1.s: Likewise. * testsuite/ld-mips-elf/mips16-intermix-1.s: Likewise. * testsuite/ld-mips-elf/mips16-pic-1b.s: Likewise. * testsuite/ld-mips-elf/mips16-pic-4c.s: Likewise. * testsuite/ld-mips-elf/no-shared-1-n64.s: Likewise. * testsuite/ld-mips-elf/no-shared-1-o32.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-1b-micromips.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-1b.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-2a.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-3b.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-4b.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-5a.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-6-n32c.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-6-n64c.s: Likewise. * testsuite/ld-mips-elf/pic-and-nonpic-6-o32c.s: Likewise. * testsuite/ld-mips-elf/pie.s: Likewise. * testsuite/ld-mips-elf/relax-jalr.s: Likewise. * testsuite/ld-mips-elf/reloc-1a.s: Likewise. * testsuite/ld-mips-elf/reloc-2a.s: Likewise. * testsuite/ld-mips-elf/reloc-4.s: Likewise. * testsuite/ld-mips-elf/reloc-5.s: Likewise. * testsuite/ld-mips-elf/reloc-6b.s: Likewise. * testsuite/ld-mips-elf/textrel-1.s: Likewise. * testsuite/ld-mips-elf/undefweak-overflow.s: Likewise. * testsuite/ld-mips-elf/undefweak-overflow.d: Adjust.
2019-12-17Accept mips-sgi-irix output in a few ld testsAlan Modra6-13/+26
mips-sgi-irix gas emits STT_OBJECT symbols where other assemblers would use STT_NOTYPE. See mips_frob_symbol in gas/config/tc-mips.c. Also, the section of some dynamic symbols is set to SHN_MIPS_TEXT or SHN_MIPS_DATA. See _bfd_mips_elf_finish_dynamic_symbol in bfd/elfxx-mips.c. These differences are visible in readelf output and cause some tests to fail for no other good reason. The patch fixes the following fails and removes an xfail. FAIL: ld-elf/pr23591 FAIL: PROVIDE_HIDDEN test (auxiliary shared object) FAIL: PR ld/21233 dynamic symbols with section GC (auxiliary shared library) * testsuite/ld-elf/pr21233-l.sd: Accept OBJECT for type and PRC for section of symbols. * testsuite/ld-elf/pr23591.d: Likewise. * testsuite/ld-elf/provide-hidden-s.nd: Likewise. * testsuite/ld-mips-elf/start.s: Make symbols function type. * testsuite/ld-mips-elf/hash2.d: Adjust. Don't xfail irix.
2019-12-17Remove tic80 supportAlan Modra39-2902/+55
This is one way of fixing ubsan bug reports, just delete the code. The assembler support was removed back in 2005 along with other non-BFD assemblers, but somehow the remainder of the port stayed in. bfd/ * coff-tic80.c: Delete file. * cpu-tic80.c: Delete file. * archures.c: Remove tic80 support. * coffcode.h: Likewise. * coffswap.h: Likewise. * targets.c: Likewise. * config.bfd: Likewise. * configure.ac: Likewise. * Makefile.am: Likewise. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * configure: Regenerate. * po/SRC-POTFILES.in: Regenerate. binutils/ * testsuite/binutils-all/objcopy.exp: Remove tic80 support. * testsuite/binutils-all/objdump.exp: Likewise. gas/ * doc/as.texi: Remove mention of tic80. include/ * coff/tic80.h: Delete file. * opcode/tic80.h: Delete file. ld/ * emulparams/tic80coff.sh: Delete file. * scripttempl/tic80coff.sc: Delete file. * configure.tgt: Remove tic80 support. * Makefile.am: Likewise. * Makefile.in: Regenerate. * po/BLD-POTFILES.in: Regenerate. opcodes/ * tic80-dis.c: Delete file. * tic80-opc.c: Delete file. * disassemble.c: Remove tic80 support. * disassemble.h: Likewise. * Makefile.am: Likewise. * configure.ac: Likewise. * Makefile.in: Regenerate. * configure: Regenerate. * po/POTFILES.in: Regenerate.
2019-12-17ubsan: bpf: left shift cannot be represented in type 'DI' (aka 'long')Alan Modra4-3/+11
cpu/ * bpf.cpu (f-imm64): Avoid signed overflow. opcodes/ * bpf-ibld.c: Regenerate.
2019-12-16Add a test case for skip with inlined functionsBernd Edlinger3-0/+147
2019-12-16Check all inline frames if they are marked for skipBernd Edlinger3-5/+75
This makes the skip command work in optimized builds, where skipped functions may be inlined. Previously that was only working when stepping into a non-inlined function.
2019-12-17Automatic date update in version.inGDB Administrator1-1/+1
2019-12-16jit: make gdb_symtab::blocks an std::forward_listSimon Marchi2-94/+54
This patch changes the gdb_symtab::blocks manually maintained linked list to be an std::forward_list, simplifying memory management. Currently, the list is sorted as blocks are created. With an std::forward_list, it is easier (and probably a bit more efficient) to sort them once at the end, so this is what I did. A note about the comment on the "next" field: /* gdb_blocks are linked into a tree structure. Next points to the next node at the same depth as this block and parent to the parent gdb_block. */ I don't think it's true that "next" points to the next node at the same depth. All nodes are in a simple singly linked list, so necessarily some node will point to some other node that isn't at the same depth. gdb/ChangeLog: * jit.c (struct gdb_block) <next>: Remove field. (struct gdb_symtab) <~gdb_symtab>: Remove. <blocks>: Change type to std::forward_list<gdb_block>. (compare_block): Remove. (jit_block_open_impl): Adjust to std::forward_list. Place the new block at the beginning, don't mind about sorting. (finalize_symtab): Adjust to std::forward_list, sort the blocks list before using it.
2019-12-16jit: c++-ify gdb_blockSimon Marchi2-11/+23
Add a constructor to gdb_block, change the name field to be a gdb::unique_xmalloc_ptr. This is in preparation for using an std::forward_list<gdb_block> in the next patch. gdb/ChangeLog: * jit.c (struct gdb_block): Add constructor, initialize real_block and next fields. <name>: Change type to gdb::unique_xmalloc_ptr. (struct gdb_symtab) <~gdb_symtab>: Free blocks with delete. (jit_block_open_impl): Allocate gdb_block with new. (finalize_symtab): Adjust to gdb::unique_xmalloc_ptr.
2019-12-16jit: make gdb_object::symtabs an std::forward_listSimon Marchi2-18/+28
Replace the manual linked list with an std::forward_list, simplifying the memory management. This requires allocating gdb_object with new and free'ing it with delete. gdb/ChangeLog: * jit.c: Include forward_list. (struct gdb_symtab) <next>: Remove field. (struct gdb_object) <symtabs>: Change type to std::forward_list<gdb_symtab>. (jit_object_open_impl): Allocate gdb_object with new. (jit_symtab_open_impl): Adjust to std::forward_list. (finalize_symtab): Don't delete symtab. (jit_object_close_impl): Adjust to std::forward_list. Free gdb_object with delete.
2019-12-16jit: c++-ify gdb_symtabSimon Marchi2-29/+43
This patch makes the gdb_symtab bit more c++y, in preparation for the next patch that will use an std::forward_list<gdb_symtab>. It changes the fields to use automatic memory management, in the form of std::string and gdb::unique_xmalloc_ptr, and adds a constructor and a destructor. gdb/ChangeLog: * jit.c (struct gdb_symtab): Add constructor, destructor, initialize fields. <linetable>: Change type to unique_xmalloc_ptr. <file_name>: Change type to std::string. (jit_symtab_open_impl): Allocate gdb_symtab with new. (jit_symtab_line_mapping_add_impl): Adjust. (finalize_symtab): Adjust, call delete on stab.
2019-12-16Fix double-free when creating more than one block in JIT debug info readerSimon Marchi7-31/+104
A double-free happens when using a JIT debug info reader that creates more than one block. In the loop that frees blocks in finalize_symtab, at the very end, the gdb_block_iter_tmp variable is set initially, but not changed as the loop advances. If we have two blocks, the first iteration frees the first block, the second iteration frees the second block, but the third iteration tries to free the second block again, as gdb_block_iter_tmp keeps pointing on the second block. Fix it by assigning the gdb_block_iter_tmp variable in the loop. I have improved the jit-reader.exp test to cover this case, by adding a second "JIT-ed" function and creating a block for it. I have renamed the existing function to something I find a bit more descriptive. There are no significant changes to jit-reader.exp itself, only updates following the renaming. The important changes are in jithost.c (generate a new function) and in jitreader.c (create a gdb_block for that function). This was found because of an ASan report: $ ./gdb testsuite/outputs/gdb.base/jit-reader/jit-reader -ex "jit-reader-load /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/jit-reader/jitreader.so" -ex r Reading symbols from testsuite/outputs/gdb.base/jit-reader/jit-reader... Starting program: /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/jit-reader/jit-reader ================================================================= ==1751048==ERROR: AddressSanitizer: heap-use-after-free on address 0x604000042eb8 at pc 0x5650ef8eec88 bp 0x7ffe52767290 sp 0x7ffe52767280 READ of size 8 at 0x604000042eb8 thread T0 #0 0x5650ef8eec87 in finalize_symtab /home/simark/src/binutils-gdb/gdb/jit.c:768 #1 0x5650ef8eef88 in jit_object_close_impl /home/simark/src/binutils-gdb/gdb/jit.c:797 #2 0x7fbbda986278 in read_debug_info /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/jitreader.c:71 #3 0x5650ef8ef56b in jit_reader_try_read_symtab /home/simark/src/binutils-gdb/gdb/jit.c:850 #4 0x5650ef8effe3 in jit_register_code /home/simark/src/binutils-gdb/gdb/jit.c:948 #5 0x5650ef8f2c92 in jit_event_handler(gdbarch*) /home/simark/src/binutils-gdb/gdb/jit.c:1396 #6 0x5650ef0d137e in handle_jit_event /home/simark/src/binutils-gdb/gdb/breakpoint.c:5470 [snip] 0x604000042eb8 is located 40 bytes inside of 48-byte region [0x604000042e90,0x604000042ec0) freed by thread T0 here: #0 0x7fbbe57376b0 in __interceptor_free /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:122 #1 0x5650ef8f350b in xfree<gdb_block> /home/simark/src/binutils-gdb/gdb/gdbsupport/common-utils.h:62 #2 0x5650ef8eeca9 in finalize_symtab /home/simark/src/binutils-gdb/gdb/jit.c:769 #3 0x5650ef8eef88 in jit_object_close_impl /home/simark/src/binutils-gdb/gdb/jit.c:797 #4 0x7fbbda986278 in read_debug_info /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/jitreader.c:71 #5 0x5650ef8ef56b in jit_reader_try_read_symtab /home/simark/src/binutils-gdb/gdb/jit.c:850 #6 0x5650ef8effe3 in jit_register_code /home/simark/src/binutils-gdb/gdb/jit.c:948 #7 0x5650ef8f2c92 in jit_event_handler(gdbarch*) /home/simark/src/binutils-gdb/gdb/jit.c:1396 #8 0x5650ef0d137e in handle_jit_event /home/simark/src/binutils-gdb/gdb/breakpoint.c:5470 [snip] previously allocated by thread T0 here: #0 0x7fbbe5737cd8 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:153 #1 0x5650eef662f3 in xcalloc /home/simark/src/binutils-gdb/gdb/alloc.c:100 #2 0x5650ef8f34ea in xcnew<gdb_block> /home/simark/src/binutils-gdb/gdb/gdbsupport/poison.h:122 #3 0x5650ef8ed467 in jit_block_open_impl /home/simark/src/binutils-gdb/gdb/jit.c:557 #4 0x7fbbda98620a in read_debug_info /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/jitreader.c:60 #5 0x5650ef8ef56b in jit_reader_try_read_symtab /home/simark/src/binutils-gdb/gdb/jit.c:850 #6 0x5650ef8effe3 in jit_register_code /home/simark/src/binutils-gdb/gdb/jit.c:948 #7 0x5650ef8f2c92 in jit_event_handler(gdbarch*) /home/simark/src/binutils-gdb/gdb/jit.c:1396 #8 0x5650ef0d137e in handle_jit_event /home/simark/src/binutils-gdb/gdb/breakpoint.c:5470 [snip] gdb/ChangeLog: * jit.c (finalize_symtab): Set gdb_block_iter_tmp in loop. gdb/testsuite/ChangeLog: * gdb.base/jit-reader.exp (jit_reader_test): Rename jit_function_00 to jit_function_stack_mangle. * gdb.base/jithost.c (jit_function_t): Rename to... (jit_function_stack_mangle_t): ... this. (jit_function_add_t): New typedef. (jit_function_00_code): Rename to... (jit_function_stack_mangle_code): ... this, make static. (jit_function_add_code): New. (main): Generate "add" function and call it. Adjust to changes in jithost_abi. * gdb.base/jithost.h (struct jithost_abi_bounds): New. (struct jithost_abi) <begin, end>: Remove fields. <object, function_stack_mangle, function_add>: New fields. * gdb.base/jitreader.c (struct reader_state) <code_begin, code_end>: Remove fields. <func_stack_mangle>: New field. (read_debug_info): Adjust to renaming, create block for "add" function. (read_sp, unwind_frame, get_frame_id): Adjust to other changes.