aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2020-05-11[gdb/symtab] Fix incomplete CU list assert in .debug_namesTom de Vries8-108/+260
Consider the following two-file test-case: ... $ cat main.c extern int foo (void); int main (void) { int sum, a, b; sum = a + b + foo (); return sum; } $ cat foo.c int foo (void) { return 3; } ... Compiled like this: ... $ clang-10 -gdwarf-5 -gpubnames -c main.c $ clang-10 -gdwarf-5 -c foo.c $ clang-10 -gdwarf-5 -gpubnames main.o foo.o ... When loading this exec into gdb, we run into this assert: ... $ gdb a.out Reading symbols from a.out... warning: Section .debug_aranges in a.out entry at offset 0 \ debug_info_offset 0 does not exists, ignoring .debug_aranges. src/gdb/dwarf2/read.c:6949: \ internal-error: cutu_reader::cutu_reader(dwarf2_per_cu_data*, \ abbrev_table*, int, bool): \ Assertion `this_cu->length == cu->header.get_length ()' failed. ... The problem is that the determined length of the CU: ... (gdb) p /x this_cu->length $4 = 0x26a ... does not match the actual length: ... (gdb) p /x cu->header.get_length () $5 = 0x59 ... The length of the CU is determined in create_cus_from_debug_names_list, and set based on this list in the .debug_names section: ... Compilation Unit offsets [ CU[0]: 0x000000c7 ] ... and it is assumed that this is a complete list, so the size of the CU is calculated using the end of the .debug_section at 0x331, making it 0x331 - 0xc7 == 0x26a. However, the CU list is not complete: ... $ llvm-dwarfdump -debug-info a.out \ | grep "Compile Unit" \ | sed 's/Compile Unit.*//' 0x00000000: 0x0000002e: 0x000000a5: 0x000000c7: 0x00000120: 0x00000157: 0x0000030f: ... In particular, because the CU for foo.c is there at 0x120 (the rest of the CUs is due to openSUSE having debug info for various linked in objects). Fix the assert by not assuming to know the length of CUs in create_cus_from_debug_names_list (if the .debug_names is not produced by GDB), and setting it to 0, and setting it later to the actual length. Note that this does not fix the .debug_aranges warning, that's PR25969. Build and tested on x86_64-linux, with native and debug-names. gdb/ChangeLog: 2020-05-11 Tom de Vries <tdevries@suse.de> PR symtab/25941 * dwarf2/read.c (create_cus_from_debug_names_list): Initialize CUs with length 0, if not gdb-produced. (cutu_reader::cutu_reader): Set CU length to actual length if 0. gdb/testsuite/ChangeLog: 2020-05-11 Tom de Vries <tdevries@suse.de> PR symtab/25941 * gdb.dwarf2/clang-debug-names.exp.in: New include exp file, factored out of ... * gdb.dwarf2/clang-debug-names.exp: ... here. * gdb.dwarf2/clang-debug-names-2.exp: New file. Include clang-debug-names.exp.in. * gdb.dwarf2/clang-debug-names-2-foo.c: New test. * gdb.dwarf2/clang-debug-names-2.c: New test.
2020-05-11gdb/fortran: Allow Flang MAIN_ in Fortran testingAlok Kumar Sharma40-64/+145
Name of fortran main function for Flang compiler is MAIN_ while for gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for the purpose of inserting breakpoint. New proc is added to detect main function name depending on the compiler used. Fortran specific version of runto_main named fortran_runto_main is added. This commit adds support for Flang main function, there should be no change for gfortran. gdb/testsuite/ChangeLog * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_, (fortran_runto_main): New Proc, fortran version of runto_main. * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_. * gdb.fortran/array-bounds.exp: Likewise. * gdb.fortran/array-slices.exp: Likewise. * gdb.fortran/block-data.exp: Likewise. * gdb.fortran/charset.exp: Likewise. * gdb.fortran/common-block.exp: Likewise. * gdb.fortran/complex.exp: Likewise. * gdb.fortran/derived-type-function.exp: Likewise. * gdb.fortran/derived-type.exp: Likewise. * gdb.fortran/info-modules.exp: Likewise. * gdb.fortran/info-types.exp: Likewise. * gdb.fortran/intrinsics.exp: Likewise. * gdb.fortran/library-module.exp: Likewise. * gdb.fortran/logical.exp: Likewise. * gdb.fortran/max-depth.exp: Likewise. * gdb.fortran/module.exp: Likewise. * gdb.fortran/multi-dim.exp: Likewise. * gdb.fortran/nested-funcs.exp: Likewise. * gdb.fortran/print-formatted.exp: Likewise. * gdb.fortran/print_type.exp: Likewise. * gdb.fortran/printing-types.exp: Likewise. * gdb.fortran/ptr-indentation.exp: Likewise. * gdb.fortran/ptype-on-functions.exp: Likewise. * gdb.fortran/subarray.exp: Likewise. * gdb.fortran/vla-alloc-assoc.exp: Likewise. * gdb.fortran/vla-datatypes.exp: Likewise. * gdb.fortran/vla-history.exp: Likewise. * gdb.fortran/vla-ptr-info.exp: Likewise. * gdb.fortran/vla-ptype-sub.exp: Likewise. * gdb.fortran/vla-ptype.exp: Likewise. * gdb.fortran/vla-sizeof.exp: Likewise. * gdb.fortran/vla-type.exp: Likewise. * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise. * gdb.fortran/vla-value-sub-finish.exp: Likewise. * gdb.fortran/vla-value-sub.exp: Likewise. * gdb.fortran/vla-value.exp: Likewise. * gdb.fortran/whatis_type.exp: Likewise. * gdb.mi/mi-var-child-f.exp: Likewise.
2020-05-09[gdb] Fix catch throw regexp matchingTom de Vries2-1/+7
When running test-case gdb.mi/mi-catch-cpp-exceptions.exp, we have: ... FAIL: gdb.mi/mi-catch-cpp-exceptions.exp: all with invalid regexp: run until \ breakpoint in main (unknown output after running) ... This is a regression since commit 596dc4adff "Speed up psymbol reading by removing a copy". Before that commit, we have: ... $ gdb \ -batch \ ./outputs/gdb.mi/mi-catch-cpp-exceptions/mi-catch-cpp-exceptions \ -ex "break 67" \ -ex "catch throw -r blahblah" \ -ex r Breakpoint 1 at 0x4008e5: file mi-catch-cpp-exceptions.cc, line 67. Catchpoint 2 (throw) Breakpoint 1, main () at mi-catch-cpp-exceptions.cc:67 67 return 1; /* Stop here. */ ... In other words: - we set a breakpoint somewhere in main, - we set a catchpoint with a regexp that is intended to not match any exception, and - run to the breakpoint, without the catchpoint triggering. After the commit, we have: ... $ gdb \ -batch \ ./outputs/gdb.mi/mi-catch-cpp-exceptions/mi-catch-cpp-exceptions \ -ex "break 67" \ -ex "catch throw -r blahblah" \ -ex r Breakpoint 1 at 0x4008e5: file mi-catch-cpp-exceptions.cc, line 67. Catchpoint 2 (throw) Catchpoint 2 (exception thrown), 0x00007ffff7ab037e in __cxa_throw () from \ /usr/lib64/libstdc++.so.6 ... In other words, the catchpoint triggers. This is caused by this bit of the commit: ... type_name = cplus_typename_from_type_info (typeinfo_arg); canon = cp_canonicalize_string (type_name.c_str ()); - if (!canon.empty ()) - std::swap (type_name, canon); + name = (canon == nullptr + ? canon.get () + : type_name.c_str ()); } catch (const gdb_exception_error &e) { exception_print (gdb_stderr, e); } - if (!type_name.empty ()) + if (name != nullptr) { - if (self->pattern->exec (type_name.c_str (), 0, NULL, 0) != 0) + if (self->pattern->exec (name, 0, NULL, 0) != 0) ... Before the commit, we have: - type_name == "my_exception" - canon = "" and the !type_name.empty () test succeeds, and gdb executes the self->pattern->exec call. After the commit, we have: - type_name == "my_exception" - canon == NULL - name == NULL and the name != nullptr test fails, and gdb doesn't execute the self->pattern->exec call. Fix this by inverting the condition for the calculation of name: ... - name = (canon == nullptr + name = (canon != nullptr ... Build and tested on x86_64-linux. gdb/ChangeLog: 2020-05-09 Tom de Vries <tdevries@suse.de> PR gdb/25955 * break-catch-throw.c (check_status_exception_catchpoint): Fix name calculation.
2020-05-09Change server_command to boolTom Tromey3-2/+7
I noticed that "server_command" is an int, but really it should be a bool. gdb/ChangeLog 2020-05-09 Tom Tromey <tom@tromey.com> * top.c (server_command): Now bool. * top.h (server_command): Now bool.
2020-05-09Fix for the complaint observed when symbol reading due to unsupported ↵nitachra3-12/+23
.debug_names form Following complaint is observed with the executable compiled with -gdwarf-5 and -gpubnames flags - "During symbol reading: Unsupported .debug_names form DW_FORM_ref4". This is the form corresponding to DW_IDX_die_offset attribute. This patch fixes this complaint. Tested with clang 10.0.0. Test case used - int main() { int sum,a,b; sum = a + b; return sum; } clang -gdwarf-5 -gpubnames test.c -o test.out gdb -q test.out -ex "set complaints 1" -ex "start" Reading symbols from test.out... During symbol reading: Unsupported .debug_names form DW_FORM_ref4 \ [in module test.out] Temporary breakpoint 1 at 0x400484 Starting program: test.out During symbol reading: Unsupported .debug_names form DW_FORM_ref4 \ [in module test.out] During symbol reading: Unsupported .debug_names form DW_FORM_ref4 \ [in module test.out] During symbol reading: Unsupported .debug_names form DW_FORM_ref4 \ [in module test.out] gdb/dwarf2/ChangeLog: 2020-05-09 Nitika Achra <Nitika.Achra@amd.com> PR symtab/25952 * read.c (dw2_debug_names_iterator::next): Handle DW_FORM_ref* and DW_IDX_die_offset. If there is no compilation unit attribute in the index entry, then there is a single CU. Return the CU at O index of compilation unit vector. gdb/testsuite/ChangeLog: 2020-05-09 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/clang-debug-names.exp: Remove PR25952 kfail.
2020-05-08Don't re-process a DIE in read_lexical_block_scopeTom Tromey2-1/+15
A customer reported a crash in the DWARF reader. Investigation showed that the crash occurred in an unusual scenario: a function was lexically scoped within some other function -- but the inner function inlined the outer function and referred to its DIE via DW_AT_abstract_origin. With the executable in question, inherit_abstract_dies could eventually call read_lexical_block_scope, which in turn could recurse into process_die, to process a DIE that was already being read, triggering an assert. This came up once before; see: https://www.sourceware.org/ml/gdb-patches/2014-02/msg00652.html However, in this case, I don't have an easy way to reproduce. So, there is no test case. I did experiment with the failing executable. This patch fixes the bug and doesn't seem to cause other issues. For example, I can still set breakpoints on the relevant functions. gdb/ChangeLog 2020-05-08 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (read_lexical_block_scope): Don't process a DIE already being processed.
2020-05-08More C++-ification for struct displayTom Tromey2-126/+93
This changes displays to have a constructor, use bool and std::string, and to be stored using std::vector. The ALL_DISPLAYS and ALL_DISPLAYS_SAFE macros are removed. While internal iteration is still done via map_display_numbers, this is updated to use a function_view. These changes simplify the code somewhat; for example, free_display can now be removed in favor of ordinary destruction. gdb/ChangeLog 2020-05-08 Tom Tromey <tom@tromey.com> * printcmd.c (struct display) <next>: Remove. <display>: New constructor. <exp_string>: Now a std::string. <enabled_p>: Now a bool. (display_number): Move definition earlier. (displays): Rename from display_chain. Now a std::vector. (ALL_DISPLAYS, ALL_DISPLAYS_SAFE): Remove. (display_command): Update. (do_one_display, disable_display) (enable_disable_display_command, do_enable_disable_display): Update. (free_display): Remove. (clear_displays): Rewrite. (delete_display): Update. (map_display_numbers): Use function_view. Remove "data" parameter. Update. (do_delete_display): Remove. (undisplay_command): Update. (do_one_display, do_displays, disable_display) (info_display_command): Update. (do_enable_disable_display): Remove. (enable_disable_display_command) (clear_dangling_display_expressions): Update.
2020-05-08Remove ALL_PSPACESTom Tromey15-369/+309
This removes the ALL_PSPACES macro. In this case it seemed cleanest to change how program spaces are stored -- instead of using a linked list, they are now stored in a std::vector. gdb/ChangeLog 2020-05-08 Tom Tromey <tom@tromey.com> * symtab.c (set_symbol_cache_size) (maintenance_print_symbol_cache, maintenance_flush_symbol_cache) (maintenance_print_symbol_cache_statistics): Update. * symmisc.c (print_symbol_bcache_statistics) (print_objfile_statistics, maintenance_print_objfiles) (maintenance_info_symtabs, maintenance_check_symtabs) (maintenance_expand_symtabs, maintenance_info_line_tables): Update. * symfile-debug.c (set_debug_symfile): Update. * source.c (forget_cached_source_info): Update. * python/python.c (gdbpy_progspaces): Update. * psymtab.c (maintenance_info_psymtabs): Update. * probe.c (parse_probes): Update. * linespec.c (iterate_over_all_matching_symtabs) (collect_symtabs_from_filename, search_minsyms_for_name): Update. * guile/scm-progspace.c (gdbscm_progspaces): Update. * exec.c (exec_target::close): Update. * ada-tasks.c (ada_tasks_new_objfile_observer): Update. * breakpoint.c (print_one_breakpoint_location) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint): Update. * progspace.c (program_spaces): Now a std::vector. (maybe_new_address_space): Update. (add_program_space): Remove. (program_space::program_space): Update. (remove_program_space): Update. (number_of_program_spaces): Remove. (print_program_space, update_address_spaces): Update. * progspace.h (program_spaces): Change type. (ALL_PSPACES): Remove. (number_of_program_spaces): Don't declare. (struct program_space) <next>: Remove.
2020-05-08Remove ALL_SO_LIBS and so_list_headTom Tromey9-72/+63
This patch started as an attempt to replace ALL_SO_LIBS with an ordinary C++ iterator. However, then I tripped over the so_list_head define again, and decided to remove it as well. gdb/ChangeLog 2020-05-08 Tom Tromey <tom@tromey.com> * mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Update. * solib-svr4.c (svr4_fetch_objfile_link_map): Update. (enable_break): Update. * solib-frv.c (frv_fdpic_find_global_pointer): Update. (frv_fdpic_find_canonical_descriptor): Update. (frv_fetch_objfile_link_map): Update. * progspace.c (program_space::free_all_objfiles): Update. (program_space::solibs): New method. * progspace.h (struct program_space) <solibs>: New method. * solist.h (master_so_list): Don't declare. (ALL_SO_LIBS): Remove. * solib.h (so_list_head): Remove. (update_solib_list): Update comment. * solib.c (master_so_list): Remove. (solib_used, update_solib_list, solib_add) (info_sharedlibrary_command, clear_solib) (reload_shared_libraries_1, remove_user_added_objfile): Update.
2020-05-08Remove ALL_EXTENSION_LANGUAGES and ALL_ENABLED_EXTENSION_LANGUAGESTom Tromey2-102/+69
This removes the ALL_EXTENSION_LANGUAGES and ALL_ENABLED_EXTENSION_LANGUAGES macros, in favor of ordinary iterators. For ALL_ENABLED_EXTENSION_LANGUAGES, I chose to simply inline the check, as that seemed simpler than trying to make filtered_iterator work for std::array. (As an aside, this sort of thing will be easier once we can use the ranges library...) gdb/ChangeLog 2020-05-08 Tom Tromey <tom@tromey.com> * extension.c (extension_languages): Now a std::array. (ALL_EXTENSION_LANGUAGES): Remove. (get_ext_lang_defn, get_ext_lang_of_file) (eval_ext_lang_from_control_command): Update. (finish_ext_lang_initialization) (auto_load_ext_lang_scripts_for_objfile) (ext_lang_type_printers::ext_lang_type_printers) (apply_ext_lang_type_printers) (ext_lang_type_printers::~ext_lang_type_printers) (apply_ext_lang_val_pretty_printer, apply_ext_lang_frame_filter) (preserve_ext_lang_values, get_breakpoint_cond_ext_lang) (breakpoint_ext_lang_cond_says_stop, check_quit_flag) (get_matching_xmethod_workers, ext_lang_colorize) (ext_lang_before_prompt): Update. (ALL_ENABLED_EXTENSION_LANGUAGES): Remove.
2020-05-08Speed up psymbol reading by removing a copyTom Tromey13-79/+104
I noticed that cp_canonicalize_string and friends copy a unique_xmalloc_ptr to a std::string. However, this copy isn't genuinely needed anywhere, and it serves to slow down DWARF psymbol reading. This patch removes the copy and updates the callers to adapt. This speeds up the reader from 1.906 seconds (mean of 10 runs, of gdb on a copy of itself) to 1.888 seconds (mean of 10 runs, on the same copy as the first trial). gdb/ChangeLog 2020-05-08 Tom Tromey <tom@tromey.com> * symtab.h (class demangle_result_storage) <set_malloc_ptr>: New overload. <swap_string, m_string>: Remove. * symtab.c (demangle_for_lookup, completion_list_add_symbol): Update. * stabsread.c (define_symbol, read_type): Update. * linespec.c (find_linespec_symbols): Update. * gnu-v3-abi.c (gnuv3_get_typeid): Update. * dwarf2/read.c (dwarf2_canonicalize_name): Update. * dbxread.c (read_dbx_symtab): Update. * cp-support.h (cp_canonicalize_string_full) (cp_canonicalize_string, cp_canonicalize_string_no_typedefs): Return unique_xmalloc_ptr. * cp-support.c (inspect_type): Update. (cp_canonicalize_string_full): Return unique_xmalloc_ptr. (cp_canonicalize_string_no_typedefs, cp_canonicalize_string): Likewise. * c-typeprint.c (print_name_maybe_canonical): Update. * break-catch-throw.c (check_status_exception_catchpoint): Update.
2020-05-08[gdb] Fix stepping over fork with follow-fork-mode child and gcc-8Tom de Vries2-0/+11
When running test-case gdb.threads/fork-child-threads.exp with gcc-8 instead of gcc-7, we have: ... (gdb) next^M [Attaching after Thread 0x7ffff7fae740 (LWP 27574) fork to child process \ 27578]^M [New inferior 2 (process 27578)]^M [Detaching after fork from parent process 27574]^M [Inferior 1 (process 27574) detached]^M [Thread debugging using libthread_db enabled]^M Using host libthread_db library "/lib64/libthread_db.so.1".^M [Switching to Thread 0x7ffff7fae740 (LWP 27578)]^M -main () at src/gdb/testsuite/gdb.threads/fork-child-threads.c:41^M +main () at src/gdb/testsuite/gdb.threads/fork-child-threads.c:34^M -41 i = pthread_create (&thread, NULL, start, NULL);^M +34 switch (fork ())^M -(gdb) PASS: gdb.threads/fork-child-threads.exp: next over fork +(gdb) FAIL: gdb.threads/fork-child-threads.exp: next over fork ... This is due to the fact that gcc-8 generates more precise line info, making the instruction after the call to fork a "recommended breakpoint location". However, it is a bug because next is supposed to move to the next source line. The problem is that in process_event_stop_test we hit this code: ... if ((ecs->event_thread->suspend.stop_pc == stop_pc_sal.pc) && (ecs->event_thread->current_line != stop_pc_sal.line || ecs->event_thread->current_symtab != stop_pc_sal.symtab)) { if (stop_pc_sal.is_stmt) { /* We are at the start of a different line. So stop. Note that we don't stop if we step into the middle of a different line. That is said to make things like for (;;) statements work better. */ if (debug_infrun) fprintf_unfiltered (gdb_stdlog, "infrun: stepped to a different line\n"); end_stepping_range (ecs); return; } ... because current_line and current_symtab have initial values: ... (gdb) p ecs->event_thread->current_line $8 = 0 (gdb) p ecs->event_thread->current_symtab $9 = (symtab *) 0x0 ... Fix this in follow_fork by copying current_line and current_symtab from parent thread to child thread. Tested on x86_64-linux, with gcc 7.5.0 and gcc 10.0.1. gdb/ChangeLog: 2020-05-08 Tom de Vries <tdevries@suse.de> * infrun.c (follow_fork): Copy current_line and current_symtab to child thread.
2020-05-08[gdb/testsuite] Add gdb.dwarf2/clang-debug-names.cTom de Vries3-0/+186
Add test-case with .debug_names section using DW_FORM_ref4. There's currently no support for .debug_names in the dwarf assembler, so we use plain _emit rather than something more structured. Consequently, we cannot use regular declare_labels-generated labels to refer from .debug_names to .debug_info. Instead, we use labels with a predefined name, which we generate using _compute_label, and then define using define_label. This is the test-case for PR25952, so kfail the corresponding test. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-08 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/clang-debug-names.c: New test. * gdb.dwarf2/clang-debug-names.exp: New file.
2020-05-07gdb: small cleanup of async-event.c structsSimon Marchi2-35/+44
This is a small cleanup to normalize the structures in async-event.c with the rest of the code base: - Remove the unnecessary typedefs - Fix indentation of struct bodies - Put comments above fields No functional changes expected. gdb/ChangeLog: * async-event.c (struct async_signal_handler, struct async_event_handler): Reformat, remove typedef.
2020-05-07gdb: remove TYPE_DYN_PROP_LIST macroSimon Marchi3-13/+16
Remove this macro, which abstracts how to obtain the dyn_prop_list of a given type. We could replace it with a method on `struct type`, but I don't think it's needed, as the only code that accesses the dynamic prop list directly is internal gdbtypes.c code (that can be seen as code internal to `struct type`). So it can just refer to the field directly. gdb/ChangeLog: * gdbtypes.h (TYPE_DYN_PROP_LIST): Remove. Update all users access thistype->main_type->dyn_prop_list directly.
2020-05-07gdb: make remove_dyn_prop a method of struct typeSimon Marchi4-12/+19
Move remove_dyn_prop, currently a free function, to be a method of struct type. gdb/ChangeLog: * gdbtypes.h (struct type) <remove_dyn_prop>: New method. (remove_dyn_prop): Remove. Update all users to use type::remove_dyn_prop. * gdbtypes.c (remove_dyn_prop): Rename to... (type::remove_dyn_prop): ... this.
2020-05-07gdb: make add_dyn_prop a method of struct typeSimon Marchi4-21/+26
Move add_dyn_prop, currently a free function, to be a method of struct type. gdb/ChangeLog: * gdbtypes.h (struct type) <add_dyn_prop>: New method. (add_dyn_prop): Remove. Update all users to use type::add_dyn_prop. * gdbtypes.c (add_dyn_prop): Rename to... (type::add_dyn_prop): ... this.
2020-05-07gdb: make get_dyn_prop a method of struct typeSimon Marchi6-27/+32
Move get_dyn_prop, currently a free function, to be a method on struct type. gdb/ChangeLog: * gdbtypes.h (struct type) <get_dyn_prop>: New method. (get_dyn_prop): Remove. Update all users to use type::dyn_prop. * gdbtypes.c (get_dyn_prop): Rename to... (type::dyn_prop): ... this.
2020-05-06gdb: remove main_type::flag_staticSimon Marchi2-1/+4
It is not used. gdb/ChangeLog: * gdbtypes.h (struct main_type) <flag_static>: Remove.
2020-05-06gdb: handle endbr64 instruction in amd64_analyze_prologueSimon Marchi6-0/+126
v2: - test: build full executable instead of object - test: add and use supports_fcf_protection - test: use gdb_test_multiple's -wrap option - test: don't execute gdb_assert if failed to get breakpoint address Some GCCs now enable -fcf-protection by default. This is the case, for example, with GCC 9.3.0 on Ubuntu 20.04. Enabling it causes the `endbr64` instruction to be inserted at the beginning of all functions and that breaks GDB's prologue analysis. I noticed this because it gives many failures in gdb.base/break.exp. But let's take this dummy program and put a breakpoint on main: int main(void) { return 0; } Without -fcf-protection, the breakpoint is correctly put after the prologue: $ gcc test.c -g3 -O0 -fcf-protection=none $ ./gdb -q -nx --data-directory=data-directory a.out Reading symbols from a.out... (gdb) disassemble main Dump of assembler code for function main: 0x0000000000001129 <+0>: push %rbp 0x000000000000112a <+1>: mov %rsp,%rbp 0x000000000000112d <+4>: mov $0x0,%eax 0x0000000000001132 <+9>: pop %rbp 0x0000000000001133 <+10>: retq End of assembler dump. (gdb) b main Breakpoint 1 at 0x112d: file test.c, line 3. With -fcf-protection, the breakpoint is incorrectly put on the first byte of the function: $ gcc test.c -g3 -O0 -fcf-protection=full $ ./gdb -q -nx --data-directory=data-directory a.out Reading symbols from a.out... (gdb) disassemble main Dump of assembler code for function main: 0x0000000000001129 <+0>: endbr64 0x000000000000112d <+4>: push %rbp 0x000000000000112e <+5>: mov %rsp,%rbp 0x0000000000001131 <+8>: mov $0x0,%eax 0x0000000000001136 <+13>: pop %rbp 0x0000000000001137 <+14>: retq End of assembler dump. (gdb) b main Breakpoint 1 at 0x1129: file test.c, line 2. Stepping in amd64_skip_prologue, we can see that the prologue analysis, for GCC-compiled programs, is done in amd64_analyze_prologue by decoding the instructions and looking for typical patterns. This patch changes the analysis to check for a prologue starting with the `endbr64` instruction, and skip it if it's there. gdb/ChangeLog: * amd64-tdep.c (amd64_analyze_prologue): Check for `endbr64` instruction, skip it if it's there. gdb/testsuite/ChangeLog: * gdb.arch/amd64-prologue-skip-cf-protection.exp: New file. * gdb.arch/amd64-prologue-skip-cf-protection.c: New file.
2020-05-06[gdb/testsuite] Fix gdb.reverse/consecutive-{precsave,reverse}.exp with gcc-8Tom de Vries3-2/+34
When running test-cases gdb.reverse/consecutive-precsave.exp and gdb.reverse/consecutive-reverse.exp with gcc-8, we get: ... FAIL: gdb.reverse/consecutive-precsave.exp: stopped at bp, 2nd instr FAIL: gdb.reverse/consecutive-reverse.exp: stopped at bp, 2nd instr ... These FAILs are duplicates of the FAILs fixed in commit 7c99e7e2b08 "[gdb/testsuite] Fix gdb.base/consecutive.exp with gcc-8". Fix these in the same manner. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * gdb.reverse/consecutive-precsave.exp: Handle if instruction after breakpoint is at a "recommended breakpoint location". * gdb.reverse/consecutive-reverse.exp: Same.
2020-05-06[gdb/testsuite] Fix gdb.base/watchpoint-reuse-slot.exp with gcc-8Tom de Vries2-2/+7
When running test-case gdb.base/watchpoint-reuse-slot.exp with gcc-8 instead of gcc-7, we have: ... (gdb) PASS: $conf: watch *(buf.byte + 0 + 0)@1 stepi^M -0x00000000004004b9 34 for (i = 0; i < 100000; i++);^M +34 for (i = 0; i < 100000; i++);^M -(gdb) PASS: $conf: stepi advanced +(gdb) FAIL: $conf: stepi advanced ... where $conf is "gdb.base/watchpoint-reuse-slot.exp: hw-watch: always-inserted off: watch x watch: : width 1, iter 0: base + 0". This is due to the fact that gcc-8 generates more precise line info, making the instruction at 0x4004b9 a "recommended breakpoint location", such that gdb no longer prints the instruction address. Fix this by getting the instruction address by printing $pc. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * gdb.base/watchpoint-reuse-slot.exp (stepi): Print $pc to get current address.
2020-05-06[gdb/testsuite] Fix cur_addr update in gdb.base/watchpoint-reuse-slot.expTom de Vries2-1/+5
I noticed this code in gdb.base/watchpoint-reuse-slot.exp, proc stepi: ... gdb_test_multiple "stepi" $test { -re "($hex).*[string_to_regexp $srcline]\r\n$gdb_prompt $" { set addr $expect_out(1,string) if {$addr != $cur_addr} { pass $test } else { fail $test } set cur_addr addr } } ... The variable cur_addr is documented as: ... # The address the program is stopped at currently. set cur_addr "" ... but in the gdb_test_multiple clause we assign the string "addr" to cur_addr, while $addr contains the current address. Fix this by assigning $addr instead "addr". Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * gdb.base/watchpoint-reuse-slot.exp: Fix incorrect assignment.
2020-05-06[gdb/testsuite] Fix gdb.base/store.exp with gcc-10Tom de Vries2-16/+41
When running gdb.base/store.exp with gcc-10 instead of gcc-9, we have: ... (gdb) PASS: gdb.base/store.exp: continue to wack_double print l^M -$22 = <optimized out>^M +$22 = -1^M -(gdb) UNSUPPORTED: gdb.base/store.exp: var double l; print old l, expecting -1 -(gdb) PASS: gdb.base/store.exp: var double l; print old l, expecting -1 +print r^M +$23 = <optimized out>^M +(gdb) FAIL: gdb.base/store.exp: var double l; print old r, expecting -2 ... With gcc-9, there's no location info for both l and r, but with gcc-10, there's location info for l, but not r. The test-case only checks for location info availability of l, and then assumes location info for r is also available. Fix this by allowing missing location info for r. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * gdb.base/store.exp (check_set, up_set): Allowing missing location info for r.
2020-05-06[gdb/testsuite] Fix gdb.base/shlib-call.exp with gcc-8Tom de Vries2-3/+13
When running test-case gdb.base/shlib-call.exp with gcc-8 instead of gcc-7, we have: ... (gdb) step^M -main () at /data/gdb_versions/devel/src/gdb/testsuite/gdb.base/shmain.c:42^M -42 g = mainshr1(g);^M -(gdb) PASS: gdb.base/shlib-call.exp: step out of shr2 epilogue to main +main () at /data/gdb_versions/devel/src/gdb/testsuite/gdb.base/shmain.c:41^M +41 g = shr2(g);^M +(gdb) FAIL: gdb.base/shlib-call.exp: step out of shr2 epilogue to main ... This is due to the fact that gcc-8 generates more precise line info, making the instruction after the call to shr2 at 0x4008f1: ... 4008e4: 8b 05 aa 07 20 00 mov 0x2007aa(%rip),%eax # 601094 <g> 4008ea: 89 c7 mov %eax,%edi 4008ec: e8 1f fe ff ff callq 400710 <shr2@plt> 4008f1: 89 05 9d 07 20 00 mov %eax,0x20079d(%rip) # 601094 <g> ... a "recommended breakpoint location": ... [0x00000287] Special opcode 187: advance Address by 13 to 0x4008f1 and \ Line by 0 to 41 ... so when stepping out of shr2, gdb steps back onto line 41, the line containing the call to shr2. Fix this by detecting this situation and adding an extra step to reach line 42. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * gdb.base/shlib-call.exp: Add extra step to reach shmain.c:42, if necessary.
2020-05-06[gdb/testsuite] Fix gdb_unbuffer_output return-typeTom de Vries2-1/+6
When running test-case gdb.base/shlib-call.exp with clang, we get: ... gdb compile failed, In file included from shmain.c:6: unbuffer_output.c:39:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ 1 warning generated. ... Fix this by changing the return-type to void. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * lib/unbuffer_output.c (gdb_unbuffer_output): Change return type to void.
2020-05-06[gdb/testsuite] Fix gdb.base/consecutive.exp with gcc-8Tom de Vries4-13/+56
When running test-case gdb.base/consecutive.exp with gcc-8 instead of gcc-7, we get: ... (gdb) step^M ^M -Breakpoint 3, 0x00000000004004b1 in foo () at consecutive.c:10^M +Breakpoint 3, foo () at consecutive.c:10^M 10 return a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6];^M -(gdb) PASS: gdb.base/consecutive.exp: stopped at bp, 2nd instr +(gdb) FAIL: gdb.base/consecutive.exp: stopped at bp, 2nd instr ... This is due to the fact that gcc-8 generates more precise line info, making the breakpoint address a "recommended breakpoint location", and consequently gdb doesn't print the address prefix anymore. Fix the FAIL by checking in the test-case whether the breakpoint address is at "recommended breakpoint location" or not. gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (is_stmt_addresses, hex_in_list): New proc, factored out of ... * gdb.base/async.exp: ... here. * gdb.base/consecutive.exp: Handle if 2nd breakpoint is at a "recommended breakpoint location".
2020-05-06[gdb/testsuite] Compile compile-ifunc.c with -Wno-attribute-aliasTom de Vries2-2/+14
Consider the following test-case: ... $ cat 1.c typedef int (*final_t) (int arg); int final (int arg) { return arg + 1; } final_t gnu_ifunc (void) { return final; } int gnu_ifunc_alias (int) __attribute__ ((ifunc ("gnu_ifunc"))); int main (void) { return gnu_ifunc_alias (10); } ... with result: ... $ gcc 1.c $ ./a.out; echo $? 11 ... The test-case uses the ifunc attribute, but there's another solution using %gnu_indirect_function. Consider 2.c and 3.c: ... $ cat 2.c typedef int (*final_t) (int arg); int final (int arg) { return arg + 1; } asm (".type gnu_ifunc, %gnu_indirect_function"); final_t gnu_ifunc (void) { return final; } $ cat 3.c extern int gnu_ifunc (int); int main (void) { return gnu_ifunc (10); } ... However, it can be inconvenient to have seperate files for the incompatible decls of gnu_ifunc, so we can use this in a single file like this: ... $ cat 4.c typedef int (*final_t) (int arg); int final (int arg) { return arg + 1; } asm (".type gnu_ifunc, %gnu_indirect_function"); final_t gnu_ifunc (void) { return final; } extern int gnu_ifunc_alias (int arg) __attribute__ ((alias ("gnu_ifunc"))); int main (void) { return gnu_ifunc_alias (10); } ... This alias trick works ok at -O0, but not at -O2: ... $ gcc 4.c $ ./a.out; echo $? 11 $ gcc 4.c $ ./a.out; echo $? 176 ... and produces a warning with gcc-8 and later: ... $ gcc-8 4.c 4.c:7:12: warning: 'gnu_ifunc_alias' alias between functions of incompatible \ types 'int(int)' and 'int (*(void))(int)' [-Wattribute-alias] extern int gnu_ifunc_alias (int arg) __attribute__ ((alias ("gnu_ifunc"))); ^~~~~~~~~~~~~~~ 4.c:5:9: note: aliased declaration here final_t gnu_ifunc (void) ^~~~~~~~~ ... The warning is correct, but the mismatch is intentional. The last variant (%gnu_indirect_function + alias) is used in gdb.compile/compile-ifunc.c, so we run into the warning with recent gcc. Fix the warning by compiling with -Wno-attribute-alias. Tested the test-case on x86_64-linux with gcc-10, and observed I no longer see the warning: ... Running src/gdb/testsuite/gdb.compile/compile-ifunc.exp ... === gdb Summary === nr of untested testcases 1 ... gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * gdb.compile/compile-ifunc.exp: Use -Wno-attribute-alias.
2020-05-05gdb: remove main_type::flag_incompleteSimon Marchi2-1/+4
It is unused. The corresponding macro was removed in c3236f84c17 ("gdb: remove TYPE_INCOMPLETE"). gdb/ChangeLog: * gdbtypes.h (struct main_type) <flag_incomplete>: Remove.
2020-05-05Mention the NetBSD support in "info proc" documentationKamil Rytarowski2-11/+17
gdb/doc/ChangeLog: * gdb.texinfo (info proc, info proc cmdline, info proc cwd) (info proc exe, info proc mappings, info proc stat): Mention NetBSD support.
2020-05-04gdb: remove TYPE_INCOMPLETESimon Marchi3-14/+6
The "HP platforms" comment prompted me to check if this was still used somewhere. Apparently it's not, so remove it. gdb/ChangeLog: * gdbtypes.h (TYPE_INCOMPLETE): Remove. * gdbtypes.c (recursive_dump_type): Remove use of TYPE_INCOMPLETE.
2020-05-04[gdb/testsuite] Fix gdb.base/async.exp with gcc-8Tom de Vries2-6/+53
When running test-case gdb.base/async.exp with gcc-8, we run into: ... FAIL: gdb.base/async.exp: stepi& ... The problem is that with gcc-8, the instruction address is no longer printed: ... stepi& -(gdb) 0x00000000004004b2 9 x = 5; x = 5; x = 5; +(gdb) 9 x = 5; x = 5; x = 5; completed. -PASS: gdb.base/async.exp: stepi& +FAIL: gdb.base/async.exp: stepi& ... This is due to the fact that gcc-8 contains more precise line info, making the address being stepped to a "recommended breakpoint location", and consequently gdb doesn't print the address prefix anymore. Given that: - we step through statements on the same line, and - there's no addres prefix anymore, this gives the impression of lack of progress, which could be improved upon, filed as enhancement PR25911 - "Show column when stepping through line". Fix the FAIL by checking in the test-case whether addresses are at "recommended breakpoint location" or not. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-04 Tom de Vries <tdevries@suse.de> * gdb.base/async.exp: Check whether instruction addresses are a "recommended breakpoint location".
2020-05-03Update more calls to add_prefix_cmdTom Tromey13-173/+86
I looked at all the calls to add_prefix_cmd, and replaced them with calls to add_basic_prefix_cmd or add_show_prefix_cmd when appropriate. This makes gdb's command language a bit more regular. I don't think there's a significant downside. Note that this patch removes a couple of tests. The removed ones are completely redundant. gdb/ChangeLog 2020-05-03 Tom Tromey <tom@tromey.com> * breakpoint.c (catch_command, tcatch_command): Remove. (_initialize_breakpoint): Use add_basic_prefix_cmd, add_show_prefix_cmd. (set_breakpoint_cmd, show_breakpoint_cmd): Remove * utils.c (set_internal_problem_cmd, show_internal_problem_cmd): Remove. (add_internal_problem_command): Use add_basic_prefix_cmd, add_show_prefix_cmd. * mips-tdep.c (set_mipsfpu_command): Remove. (_initialize_mips_tdep): Use add_basic_prefix_cmd. * dwarf2/index-cache.c (set_index_cache_command): Remove. (_initialize_index_cache): Use add_basic_prefix_cmd. * memattr.c (dummy_cmd): Remove. (_initialize_mem): Use add_basic_prefix_cmd, add_show_prefix_cmd. * tui/tui-win.c (set_tui_cmd, show_tui_cmd): Remove. (_initialize_tui_win): Use add_basic_prefix_cmd, add_show_prefix_cmd. * cli/cli-logging.c (set_logging_command): Remove. (_initialize_cli_logging): Use add_basic_prefix_cmd, add_show_prefix_cmd. (show_logging_command): Remove. * target.c (target_command): Remove. (add_target): Use add_basic_prefix_cmd. gdb/testsuite/ChangeLog 2020-05-03 Tom Tromey <tom@tromey.com> * gdb.base/sepdebug.exp: Remove "catch" test. * gdb.base/break.exp: Remove "catch" test. * gdb.base/default.exp: Update expected output.
2020-05-02Fix typo in comment of DYN_PROP_ASSOCIATEDHannes Domani2-1/+5
gdb/ChangeLog: 2020-05-02 Hannes Domani <ssbssa@yahoo.de> * gdbtypes.h (enum dynamic_prop_node_kind): Fix typo.
2020-05-02gdb: Fix formatting error in ChangeLogAndrew Burgess1-0/+2
2020-05-02[gdb/testsuite] Fix i386-mpx.exp compilation warningsTom de Vries7-0/+41
When running test-case gdb.arch/i386-mpx.exp with gcc-10, we get: ... Running src/gdb/testsuite/gdb.arch/i386-mpx.exp ... gdb compile failed, xgcc: warning: switch '-mmpx' is no longer supported xgcc: warning: switch '-fcheck-pointer-bounds' is no longer supported ... The test-case uses a combination of options, -mmpx and -fcheck-pointer-bounds. The -fcheck-pointer-bounds option requires the -mmpx option: ... $ gcc -fcheck-pointer-bounds ~/hello.c hello.c:1:0: warning: Pointer Checker requires MPX support on this target. \ Use -mmpx options to enable MPX. #include <stdio.h> cc1: error: ‘-fcheck-pointer-bounds’ is not supported for this target ... Both options is no longer supported in gcc-9. Fix the warnings by testing if the option combination is supported. Tested on x86_64-linux, with gcc-7.5.0 and gcc-10.0.1. gdb/testsuite/ChangeLog: 2020-05-02 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (supports_mpx_check_pointer_bounds): New proc. * gdb.arch/i386-mpx-call.exp: Use supports_mpx_check_pointer_bounds. * gdb.arch/i386-mpx-map.exp: Same. * gdb.arch/i386-mpx-sigsegv.exp: Same. * gdb.arch/i386-mpx-simple_segv.exp: Same. * gdb.arch/i386-mpx.exp: Same.
2020-05-02[gdb/testsuite] Update psym-external-decl.exp for gcc-10/clangTom de Vries3-1/+10
When running test-case gdb.base/psym-external-decl.exp with gcc-10, we have: ... (gdb) print aaa^M 'aaa' has unknown type; cast it to its declared type^M (gdb) FAIL: gdb.base/psym-external-decl.exp: print aaa ... With an an earlier version, gcc still emits the debug info for the declaration of aaa: ... <0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit) <d8> DW_AT_name : psym-external-decl.c <1><f4>: Abbrev Number: 2 (DW_TAG_variable) <f5> DW_AT_name : aaa <ff> DW_AT_external : 1 <ff> DW_AT_declaration : 1 ... but with gcc-10 that's no longer the case. Fix the test-case by adding a use of aaa in psym-external-decl.c. That still doesn't work for clang, so skip test in that case. Tested with x86_64-linux, with gcc 7.5.0, gcc 10.0.0 and clang 5.0.2. Also tested by reverting corresponding fix and ensuring test-case still fails. gdb/testsuite/ChangeLog: 2020-05-02 Tom de Vries <tdevries@suse.de> * gdb.base/psym-external-decl.c (main): Add use of variable aaa.
2020-05-01[gdb/testsuite] Fix gdb.ada/operator_bp.exp breakpoint location FAILsTom de Vries2-4/+15
When running test-case gdb.ada/operator_bp.exp with gcc-10, I run into: ... FAIL: gdb.ada/operator_bp.exp: break "+" FAIL: gdb.ada/operator_bp.exp: break "-" FAIL: gdb.ada/operator_bp.exp: break "<" FAIL: gdb.ada/operator_bp.exp: break "<=" FAIL: gdb.ada/operator_bp.exp: break ">" FAIL: gdb.ada/operator_bp.exp: break ">=" FAIL: gdb.ada/operator_bp.exp: break "=" FAIL: gdb.ada/operator_bp.exp: break "and" FAIL: gdb.ada/operator_bp.exp: break "or" FAIL: gdb.ada/operator_bp.exp: break "xor" FAIL: gdb.ada/operator_bp.exp: break "not" ... The first FAIL is because two breakpoint locations are expected, but there are more than 2: ... (gdb) break "+" Breakpoint 2 at 0x402c3c: "+". (6 locations) (gdb) info break Num Type Disp Enb Address What 2 breakpoint keep y <MULTIPLE> 2.1 y 0x0000000000402c3c in ops."+" at operator_bp/ops.adb:25 2.2 y 0x0000000000402e5b in ops."+" at operator_bp/ops.adb:119 2.3 y 0x0000000000414207 in system.storage_elements."+" at s-stoele.adb:82 2.4 y 0x0000000000414404 in system.storage_elements."+" at s-stoele.adb:87 2.5 y 0x0000000000414413 in system.storage_elements."+" at s-stoele.adb:87 2.6 y 0x0000000000414430 in system.storage_elements."+" at s-stoele.adb:81 ... This can be traced back to a extra debug info in the executable: ... $ readelf -w ops_test | grep system__storage_elements__Oadd <28104> DW_AT_name : system__storage_elements__Oadd__2 <2812e> DW_AT_name : system__storage_elements__Oadd ... Fix the FAILs by allowing more than the required amount of breakpoint locations. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-01 Tom de Vries <tdevries@suse.de> * gdb.ada/operator_bp.exp: Allow more than required amount of breakpoint.
2020-05-01Remove gdb-gdb.gdb breakpoint on disappeared function info_command.Philippe Waroquiers2-6/+4
The function info_command has disappeared, so this breakpoint does not work anymore. "info_command" was a function for the prefix command "info", giving the list of "info" subcommands. It is not very clear what the removed breakpoint and its associated command list was supposed to do. Removed and pushed as obvious, after discussion with Tom.
2020-05-01Fix size recalculation of fortran arraysHannes Domani1-62/+70
My recent change regarding size calculation of arrays of stubbed types didn't take array strides and associated/allocated type properties into account, which basically broke fortran arrays. Fixed by refactoring the array size calculation of create_array_type_with_stride into a new function, and also use it for the stubbed array size recalculation. gdb/ChangeLog: 2020-05-01 Hannes Domani <ssbssa@yahoo.de> * gdbtypes.c (update_static_array_size): New function. (create_array_type_with_stride): Use update_static_array_size. (check_typedef): Likewise.
2020-05-01[gdb/testsuite] Fix Wunused-result warning in until-reverse.cTom de Vries2-1/+6
When running test-case gdb.reverse/until-reverse.exp or gdb.reverse/until-precsave.exp with gcc-10, we run into a Wunused-result warning: ... gdb compile failed, gdb.reverse/until-reverse.c: In function 'main': gdb.reverse/until-reverse.c:40:14: warning: ignoring return value of \ 'malloc' declared with attribute 'warn_unused_result' [-Wunused-result] 40 | (void) malloc (1); | ^~~~~~~~~~ ... Fix this by using the result of malloc as argument to a free call. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-01 Tom de Vries <tdevries@suse.de> * gdb.reverse/until-reverse.c (main): Fix Wunused-result warning.
2020-04-30Add support for NetBSD thread events (create, exit)Kamil Rytarowski3-3/+90
Report LWP CREATE and LWP EXIT events and setup this on post_attach() and post_startup_inferior(). Stop reinitializing the list of recognized threads in update_thread_list(). Handle LWP CREATE and EXIT events in nbsd_nat_target::wait(). gdb/ChangeLog: * nbsd-nat.c (nbsd_enable_proc_events) (nbsd_nat_target::post_startup_inferior): Add. (nbsd_nat_target::post_attach): Call `nbsd_enable_proc_events'. (nbsd_nat_target::update_thread_list): Rewrite. (nbsd_nat_target::wait): Handle "PTRACE_LWP_EXIT" and "PTRACE_LWP_CREATE". * nbsd-nat.h (nbsd_nat_target::post_startup_inferior): Add.
2020-04-30Revert "2020-04-29 Sterling Augustine <saugustine@google.com>"Tom de Vries2-5/+0
This reverts commit 84ed7a472551bce1ac58e0eced619433fabc956c. The problem that the commit attempts to address has already been fixed in commit 770479f223e "gdb: Fix toplevel types with -fdebug-types-section". The commit itself is superfluous because it sets list_in_scope at a point that it's already set (by start_symtab).
2020-04-30Remove duplicated creation of "frame" command and "f" alias.Philippe Waroquiers2-9/+4
"frame" and "f" are created twice by stack.c _initialize_stack. Remove the second creation. Regression tested on amd64/Debian. 2020-04-30 Philippe Waroquiers <philippe.waroquiers@skynet.be> * stack.c (_initialize_stack): Remove duplicated creation of "frame" command and "f" alias.
2020-04-30Calculate size of array of stubbed typeHannes Domani7-0/+126
Sizes of stubbed types are calculated on demand in check_typedef, so the same must also be done for arrays of stubbed types. A stubbed type is usually a structure that has only been forward declared, but can also happen if the structure has a virtual function that's not inline in the class definition. For these stubbed types, the size must be recalculated once the full definition is available. gdb/ChangeLog: 2020-04-30 Hannes Domani <ssbssa@yahoo.de> PR gdb/18706 * gdbtypes.c (check_typedef): Calculate size of array of stubbed type. gdb/testsuite/ChangeLog: 2020-04-30 Hannes Domani <ssbssa@yahoo.de> PR gdb/18706 * gdb.cp/stub-array-size.cc: New test. * gdb.cp/stub-array-size.exp: New file. * gdb.cp/stub-array-size.h: New test. * gdb.cp/stub-array-size2.cc: New test.
2020-04-30Adjust array pretty printer tests to the new formatHannes Domani2-3/+8
gdb/testsuite/ChangeLog: 2020-04-30 Hannes Domani <ssbssa@yahoo.de> * gdb.python/py-format-string.exp: Adjust pretty_arrays expected output to the new format.
2020-04-30Use thiscall calling convention for class membersHannes Domani4-7/+83
Non-static member functions for Windows 32bit programs need the thiscall calling convention, so the 'this' pointer needs to be passed in ECX. gdb/ChangeLog: 2020-04-30 Hannes Domani <ssbssa@yahoo.de> PR gdb/15559 * i386-tdep.c (i386_push_dummy_call): Call i386_thiscall_push_dummy_call. (i386_thiscall_push_dummy_call): New function. * i386-tdep.h (i386_thiscall_push_dummy_call): Declare. * i386-windows-tdep.c (i386_windows_push_dummy_call): New function. (i386_windows_init_abi): Call set_gdbarch_push_dummy_call.
2020-04-29gdb: silence shellcheck warning SC2162 (use read -r) in gdbarch.shSimon Marchi2-0/+6
shellcheck reports: In gdbarch.sh line 53: while IFS='' read line ^--^ SC2162: read without -r will mangle backslashes. See the rationale at [1]. In our case, we actually want the backslashes to be interpreted and removed. Silence the warning using a directive. [1] https://github.com/koalaman/shellcheck/wiki/SC2162 gdb/ChangeLog: * gdbarch.sh (do_read): Add shellcheck disable directive for warning SC2162.
2020-04-29gdb: fix shellcheck warnings SC2154 (referenced but not assigned) in gdbarch.shSimon Marchi2-7/+12
Fix all instances of this kind of warning: In gdbarch.sh line 96: m ) staticdefault="${predefault}" ;; ^-----------^ SC2154: predefault is referenced but not assigned. These warnings appear because we are doing something a bit funky when reading the gdbarch fields. These variables are not assigned explicitly, but using some `eval` commands. I don't think there is so much we can fix about those warnings. To silence them, I've changed `${foo}` to `${foo:-}`. This tells the shell to substitute with an empty string if `foo` is not defined. This retains the current behavior, but the warnings go away. gdb/ChangeLog: * gdbarch.sh: Use ${foo:-} where shellcheck would report a "referenced but not assigned" warning.
2020-04-29gdb: fix shellcheck warnings SC2034 (unused variable) in gdbarch.shSimon Marchi2-19/+6
shellcheck reports: In gdbarch.sh line 139: fallbackdefault="0" ^-------------^ SC2034: fallbackdefault appears unused. Verify use (or export if used externally). Indeed, the `fallbackdefault` variable appears to be unused, remove the code that sets it. gdb/ChangeLog: * gdbarch.sh: Remove code that sets fallbackdefault.