aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-06-29gdb: make frame_debug a booleanSimon Marchi3-6/+13
gdb/ChangeLog: * frame.h (frame_debug): Change type to bool. * frame.c (frame_debug): Change type to bool. (_initialize_frame): Adjust. Change-Id: I27b5359a25ad53ac42618b5708a025c348a1eeda
2021-06-29Add the netbsdpe configuration to the list of obsolete targets.Nick Clifton2-1/+5
* config.bfd (obsolete configurations): Add netbsdpe.
2021-06-29gdb: remove duplicate declaration of 'find_thread_ptid'Tankut Baris Aktemur2-4/+4
There are two declarations of 'find_thread_ptid' in gdbthread.h with the same signature: /* Find (non-exited) thread PTID of inferior INF. */ extern thread_info *find_thread_ptid (inferior *inf, ptid_t ptid); and /* Search function to lookup a (non-exited) thread by 'ptid'. Only searches in threads of INF. */ extern struct thread_info *find_thread_ptid (inferior *inf, ptid_t ptid); Retain the former, remove the latter. Tested by rebuilding. gdb/ChangeLog: 2021-06-29 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdbthread.h (find_thread_ptid): Remove the duplicate declaration.
2021-06-29sim: io: add printf attributes to vprintf funcs tooMike Frysinger2-2/+9
The compiler can still do basic format checks with vprintf style funcs, so add the printf attribute to these.
2021-06-29sim: callback: add printf attributesMike Frysinger4-5/+20
This helps these funcs get printf format checking coverage. The sim-io.c hack as a result is a bit unfortunate, but the compiler throws warnings when printing with empty strings. In this one case, we actually want that due to the side-effect of the callback halting execution for us.
2021-06-29sim: callback: drop unused printf helpersMike Frysinger3-66/+8
These cover functions aren't used anywhere, so drop them. There was one caller, but it's old DOS code that most likely hasn't been tested in years, so just delete that too.
2021-06-29sim: cgen: require long long supportMike Frysinger3-29/+6
We require C11 now, so we can assume & require long long exists. Drop this old code that hasn't been used for a long long time.
2021-06-29Automatic date update in version.inGDB Administrator1-1/+1
2021-06-28gdb: use gdb_bfd_count_sections in macho_symfile_offsetsSimon Marchi2-1/+7
When loading a mach-o (macOS) executable and trying to set a breakpoint, a GDB built with ASan or -D_GLIBCXX_DEBUG will crash with an out-of-bound vector access. This can be reproduced on Linux using the repro files in bug 28017 [1]: $ ./gdb -nx --data-directory=data-directory -q repro/test -ex "b main" -batch /usr/include/c++/11.1.0/debug/vector:445: In function: std::__debug::vector<_Tp, _Allocator>::const_reference std::__debug::vector<_Tp, _Allocator>::operator[](std::__debug::vector<_Tp, _Allocator>::size_type) const [with _Tp = long unsigned int; _Allocator = std::allocator<long unsigned int>; std::__debug::vector<_Tp, _Allocator>::const_reference = const long unsigned int&; std::__debug::vector<_Tp, _Allocator>::size_type = long unsigned int] Error: attempt to subscript container with out-of-bounds index 13, but container only holds 13 elements. Objects involved in the operation: sequence "this" @ 0x0x61300000a590 { type = std::__debug::vector<unsigned long, std::allocator<unsigned long> >; } The out-of-bound access happens here: #0 0x00007ffff6405d22 in raise () from /usr/lib/libc.so.6 #1 0x00007ffff63ef862 in abort () from /usr/lib/libc.so.6 #2 0x00007ffff664e21e in __gnu_debug::_Error_formatter::_M_error() const [clone .cold] from /usr/lib/libstdc++.so.6 #3 0x000055555699e5ff in std::__debug::vector<unsigned long, std::allocator<unsigned long> >::operator[] (this=0x61300000a590, __n=13) at /usr/include/c++/11.1.0/debug/vector:445 #4 0x0000555556a58c17 in objfile::section_offset (this=0x61300000a4c0, section=0x55555bbe4ac0 <_bfd_std_section>) at /home/simark/src/binutils-gdb/gdb/objfiles.h:644 #5 0x0000555556a58cac in obj_section::offset (this=0x62100016d2a8) at /home/simark/src/binutils-gdb/gdb/objfiles.h:838 #6 0x0000555556a58cfa in obj_section::addr (this=0x62100016d2a8) at /home/simark/src/binutils-gdb/gdb/objfiles.h:850 #7 0x000055555779f5f7 in sort_cmp (sect1=0x62100016d2a8, sect2=0x62100016d170) at /home/simark/src/binutils-gdb/gdb/objfiles.c:902 #8 0x00005555577aae35 in __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(obj_section const*, obj_section const*)>::operator()<obj_section**, obj_section**> (this=0x7fffffffa9e0, __it1=0x60c000015970, __it2=0x60c000015940) at /usr/include/c++/11.1.0/bits/predefined_ops.h:158 #9 0x00005555577aa2b8 in std::__insertion_sort<obj_section**, __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(obj_section const*, obj_section const*)> > (__first=0x60c000015940, __last=0x60c0000159c0, __comp=...) at /usr/include/c++/11.1.0/bits/stl_algo.h:1826 #10 0x00005555577a8e26 in std::__final_insertion_sort<obj_section**, __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(obj_section const*, obj_section const*)> > (__first=0x60c000015940, __last=0x60c0000159c0, __comp=...) at /usr/include/c++/11.1.0/bits/stl_algo.h:1871 #11 0x00005555577a723c in std::__sort<obj_section**, __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(obj_section const*, obj_section const*)> > (__first=0x60c000015940, __last=0x60c0000159c0, __comp=...) at /usr/include/c++/11.1.0/bits/stl_algo.h:1957 #12 0x00005555577a50f4 in std::sort<obj_section**, bool (*)(obj_section const*, obj_section const*)> (__first=0x60c000015940, __last=0x60c0000159c0, __comp=0x55555779f4e7 <sort_cmp(obj_section const*, obj_section const*)>) at /usr/include/c++/11.1.0/bits/stl_algo.h:4875 #13 0x00005555577a147e in update_section_map (pspace=0x61200001d2c0, pmap=0x6030000d40b0, pmap_size=0x6030000d40b8) at /home/simark/src/binutils-gdb/gdb/objfiles.c:1165 #14 0x00005555577a19a0 in find_pc_section (pc=0x100003fa0) at /home/simark/src/binutils-gdb/gdb/objfiles.c:1212 #15 0x00005555576dd39e in lookup_minimal_symbol_by_pc_section (pc_in=0x100003fa0, section=0x0, prefer=lookup_msym_prefer::TEXT, previous=0x0) at /home/simark/src/binutils-gdb/gdb/minsyms.c:750 #16 0x00005555576de552 in lookup_minimal_symbol_by_pc (pc=0x100003fa0) at /home/simark/src/binutils-gdb/gdb/minsyms.c:986 #17 0x0000555557d44b54 in find_pc_sect_line (pc=0x100003fa0, section=0x62100016d170, notcurrent=0) at /home/simark/src/binutils-gdb/gdb/symtab.c:3163 #18 0x0000555557d489fa in find_function_start_sal_1 (func_addr=0x100003fa0, section=0x62100016d170, funfirstline=true) at /home/simark/src/binutils-gdb/gdb/symtab.c:3650 #19 0x0000555557d49015 in find_function_start_sal (sym=0x621000191670, funfirstline=true) at /home/simark/src/binutils-gdb/gdb/symtab.c:3706 #20 0x0000555557485283 in symbol_to_sal (result=0x7fffffffbb30, funfirstline=1, sym=0x621000191670) at /home/simark/src/binutils-gdb/gdb/linespec.c:4460 #21 0x00005555574728c2 in convert_linespec_to_sals (state=0x7fffffffc390, ls=0x7fffffffc3e0) at /home/simark/src/binutils-gdb/gdb/linespec.c:2335 #22 0x0000555557475a8e in parse_linespec (parser=0x7fffffffc360, arg=0x60200007a550 "main", match_type=symbol_name_match_type::WILD) at /home/simark/src/binutils-gdb/gdb/linespec.c:2716 #23 0x0000555557479027 in event_location_to_sals (parser=0x7fffffffc360, location=0x606000097be0) at /home/simark/src/binutils-gdb/gdb/linespec.c:3173 #24 0x00005555574798f7 in decode_line_full (location=0x606000097be0, flags=1, search_pspace=0x0, default_symtab=0x0, default_line=0, canonical=0x7fffffffcca0, select_mode=0x0, filter=0x0) at /home/simark/src/binutils-gdb/gdb/linespec.c:3253 #25 0x0000555556b4949f in parse_breakpoint_sals (location=0x606000097be0, canonical=0x7fffffffcca0) at /home/simark/src/binutils-gdb/gdb/breakpoint.c:9134 #26 0x0000555556b6ce95 in create_sals_from_location_default (location=0x606000097be0, canonical=0x7fffffffcca0, type_wanted=bp_breakpoint) at /home/simark/src/binutils-gdb/gdb/breakpoint.c:13819 #27 0x0000555556b645a6 in bkpt_create_sals_from_location (location=0x606000097be0, canonical=0x7fffffffcca0, type_wanted=bp_breakpoint) at /home/simark/src/binutils-gdb/gdb/breakpoint.c:12631 #28 0x0000555556b4badf in create_breakpoint (gdbarch=0x621000152d10, location=0x606000097be0, cond_string=0x0, thread=0, extra_string=0x0, force_condition=false, parse_extra=1, tempflag=0, type_wanted=bp_breakpoint, ignore_count=0, pending_break_support=AUTO_BOOLEAN_AUTO, ops=0x55555bd728a0 <bkpt_breakpoint_ops>, from_tty=0, enabled=1, internal=0, flags=0) at /home/simark/src/binutils-gdb/gdb/breakpoint.c:9410 #29 0x0000555556b4d3b1 in break_command_1 (arg=0x7fffffffe291 "", flag=0, from_tty=0) at /home/simark/src/binutils-gdb/gdb/breakpoint.c:9590 #30 0x0000555556b4dc1b in break_command (arg=0x7fffffffe28d "main", from_tty=0) at /home/simark/src/binutils-gdb/gdb/breakpoint.c:9660 #31 0x0000555556d24ca9 in do_const_cfunc (c=0x61100003a240, args=0x7fffffffe28d "main", from_tty=0) at /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:102 #32 0x0000555556d2fcd3 in cmd_func (cmd=0x61100003a240, args=0x7fffffffe28d "main", from_tty=0) at /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:2160 #33 0x0000555557e84e93 in execute_command (p=0x7fffffffe290 "n", from_tty=0) at /home/simark/src/binutils-gdb/gdb/top.c:674 #34 0x00005555575a9933 in catch_command_errors (command=0x555557e84043 <execute_command(char const*, int)>, arg=0x7fffffffe28b "b main", from_tty=0, do_bp_actions=true) at /home/simark/src/binutils-gdb/gdb/main.c:523 #35 0x00005555575a9fdb in execute_cmdargs (cmdarg_vec=0x7fffffffd910, file_type=CMDARG_FILE, cmd_type=CMDARG_COMMAND, ret=0x7fffffffd5b0) at /home/simark/src/binutils-gdb/gdb/main.c:618 #36 0x00005555575ad48a in captured_main_1 (context=0x7fffffffdd00) at /home/simark/src/binutils-gdb/gdb/main.c:1322 #37 0x00005555575ada9c in captured_main (data=0x7fffffffdd00) at /home/simark/src/binutils-gdb/gdb/main.c:1343 #38 0x00005555575adb31 in gdb_main (args=0x7fffffffdd00) at /home/simark/src/binutils-gdb/gdb/main.c:1368 #39 0x000055555681e179 in main (argc=8, argv=0x7fffffffde78) at /home/simark/src/binutils-gdb/gdb/gdb.c:32 The section being dealt with at that moment is the special *COM* section: (top-gdb) p section.name $1 = 0x55555a1bbe60 "*COM*" (top-gdb) p section $2 = (bfd_section *) 0x55555bbe4ac0 <_bfd_std_section> I'm not too sure what this section is for, but this is one of four special BFD sections that GDB puts after the regular sections in the objfile::sections and objfile::section_offsets lists. You can check gdb_bfd_section_index to see how they are handled. gdb_bfd_count_sections returns "+ 4" to account for those sections. The problem is that macho_symfile_offsets uses bfd_count_sections instead of gdb_bfd_count_sections when allocating the objfile::section_offsets vector. The vector will therefore contain, say, 13 elements instead of 17. When trying to access the section offset of the *COM* section, the first after the regular sections, we access section_offsets[13], which is out of bounds. Fix that by using gdb_bfd_count_sections instead of bfd_count_sections. I'm fairly confident that this is correct, as this is what default_symfile_offsets does. With this patch, the command shown above terminates normally: $ ./gdb -nx --data-directory=data-directory -q repro/test -ex "b main" -batch Breakpoint 1 at 0x100003fad: file test.c, line 2. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=28017 gdb/ChangeLog: PR gdb/28017 * machoread.c (macho_symfile_offsets): Use gdb_bfd_count_sections to allocate objfile::section_offsets. Change-Id: Ic3a56f46f7232e9f24581f8255fc1ab981935450
2021-06-28gdb: convert obj_section macros to methodsSimon Marchi22-102/+134
Convert these three macros to methods of obj_section. The problem fixed by the following patch is caused by an out of bound access of the objfile::section_offsets vector. Since this is deep in macros, we don't get a clear backtrace and it's difficult to debug. Changing that to methods means we can step in them and break on them. Because their implementation requires knowing about struct objfile, move struct obj_section below struct objfile in objfiles.h. The obj_section_offset was used in one place as an lvalue to set offsets, in machoread.c. Replace that with a set_offset method. Add the objfile::section_offset and objfile::set_section_offset methods to improve encapsulation (reduce other objects poking into struct objfile's internals). gdb/ChangeLog: * objfiles.h (struct obj_section): Move down. <offset, set_offset, addr, endaddr>: New. (obj_section_offset, obj_section_addr, obj_section_endaddr), replace all users to use obj_section methods. (struct objfile) <section_offset, set_section_offset>: New. Change-Id: I97e8fcae93ab2353fbdadcb4a5ec10d7949a7334
2021-06-28gdb: add .flake8 fileSimon Marchi2-0/+6
Add a .flake8 file, which is used to set default options to the flake8 Python linter. Use it to disable these two kinds of diagnostics, which we don't care about since formatting is handled by black. This reduces the amount of noise when running flake8 on Python files. ./python/lib/gdb/function/caller_is.py:30:80: E501 line too long (81 > 79 characters) ./python/lib/gdb/command/frame_filters.py:468:17: W503 line break before binary operator gdb/ChangeLog: * .flake8: New. Change-Id: I2b41379fdd1f6e8bf2a784d55a10b406e4d1c828
2021-06-28Sanitize the address before working with allocation tagsLuis Machado2-2/+17
Remove the logical tag/top byte from the address whenever we have to work with allocation tags. gdb/ChangeLog: 2021-06-28 Luis Machado <luis.machado@linaro.org> * aarch64-linux-tdep.c (aarch64_linux_memtag_matches_p): Remove the top byte. (aarch64_linux_set_memtags): Likewise. (aarch64_linux_get_memtag): Likewise. (aarch64_linux_report_signal_info): Likewise.
2021-06-28Fix FFR register size for core files.Luis Machado2-1/+6
The FFR register has a size of VL bits, not 32 bits. This causes issues when writing core files with the gcore command and when reading them. The FFR register sometimes shows up with garbage data. gdb/ChangeLog: 2021-06-28 Luis Machado <luis.machado@linaro.org> * aarch64-linux-tdep.c (aarch64_linux_iterate_over_regset_sections): Fix FFR register size.
2021-06-28Fix tag_ctl register size in the core file.Luis Machado3-3/+11
This register should be 64 bits in size, but the current code only saves 32 bits. This is due to an early assumption that tag_ctl would be 32 bits in size. gdb/ChangeLog: 2021-06-28 Luis Machado <luis.machado@linaro.org> * aarch64-linux-tdep.c (aarch64_linux_iterate_over_regset_sections): Update tag_ctl register size. * aarch64-linux-tdep.h (AARCH64_LINUX_SIZEOF_MTE_REGSET): Set to 8 and update comments.
2021-06-28gdb: remove gdbarch_info_initSimon Marchi18-92/+43
While reviewing another patch, I realized that gdbarch_info_init could easily be removed in favor of initializing gdbarch_info fields directly in the struct declaration. The only odd part is the union. I don't know if it's actually important for it to be zero-initialized, but I presume it is. I added a constructor to gdbarch_info to take care of that. A proper solution would be to use std::variant. Or, these could also be separate fields, the little extra space required wouldn't matter. gdb/ChangeLog: * gdbarch.sh (struct gdbarch_info): Initialize fields, add constructor. * gdbarch.h: Re-generate. * arch-utils.h (gdbarch_info_init): Remove, delete all usages. * arch-utils.c (gdbarch_info_init): Remove. Change-Id: I7502e08fe0f278d84eef1667a072e8a97bda5ab5
2021-06-28gdb: remove gdbarch_info::tdep_infoSimon Marchi4-14/+6
This field is not actually used, remove it. gdb/ChangeLog: * gdbarch.sh (struct gdbarch_info) <tdep_info>: Remove. (gdbarch_find_by_info): Remove print. * gdbarch.c, gdbarch.h: Re-generate. Change-Id: I00af4681b8e1a27727441cbadc3827f5914bd8eb
2021-06-28gdb/remote: Use true/false instead of 1/0Andrew Burgess2-4/+9
The remote_state::starting_up member variable is already of type bool, but in some places we still write to it using 1 and 0. This commit just updates things to use true and false. There should be no user visible change after this commit. gdb/ChangeLog: * remote.c (remote_target::start_remote): Set 'starting_up' using boolean values instead of integers.
2021-06-28sim: bpf: enable -Werror usageMike Frysinger2-3/+4
Now that all bpf warnings have been cleaned up, turn on -Werror.
2021-06-28sim: bpf: fix printf warnings on 32-bit systemsMike Frysinger2-1/+5
Use PRI macros to display 64-bit types instead of assuming long is a 64-bit type itself.
2021-06-28sim: cgen: delete unused record_trace_results functionsMike Frysinger17-80/+31
Since there are no callers of this anywhere, nor is the function implemented by anyone, drop it across the board to cleanup warnings.
2021-06-28gdb/fortran: Add type info of formal parameter for clang.Bhuvanendra Kumar N1-7/+29
Additional compiler generated formal parameter exist with clang and type information for the same is added accordingly. Also few kind parameter printing are removed which is not default for clang. Note: More details about this kind parameter omission while printing can be found with similar patch commit 0a709cba00d36d490482d0e8673e323ac1e897a6 Author Alok Kumar Sharma (alokkumar.sharma@amd.com) gdb/testsuite/ChangeLog: * gdb.fortran/ptype-on-functions.exp: Add type info of formal parameter for clang. Also removed the kind parameter for clang.
2021-06-27sim: frv: add missing const typeMike Frysinger2-1/+5
2021-06-27sim: frv: fix engine hookMike Frysinger2-1/+5
This hook doesn't return a value, so don't define it to 0 to avoid the compiler warning about it not being used.
2021-06-27sim: frv: fix up various missing prototype warningsMike Frysinger6-1/+22
Some of these were missing includes, some were unused funcs we can cleanup, and some were missing prototypes for use in other files.
2021-06-27sim: frv: fix some printf type mismatch warningsMike Frysinger3-2/+7
The %p usage was a real bug that would probably cause a crash.
2021-06-27sim: frv: fix uninitialized variable warningMike Frysinger2-2/+6
This variable isn't set anywhere, so pass down NULL_CIA to indicate we don't have a pc to pass.
2021-06-27sim: frv: fix return type for post_wait_for funcsMike Frysinger3-19/+31
These functions never return anything, so change the int return type to void to fix a bunch of compiler warnings about missing return.
2021-06-27sim: frv: fix ambiguous else compiler warningsMike Frysinger4-25/+43
Add explicit braces to if bodies when the body is another if/else to fix a bunch of compiler warnings.
2021-06-28Automatic date update in version.inGDB Administrator1-1/+1
2021-06-27sim: bpf/cris: include cgen-mem in decodersMike Frysinger6-0/+16
These arches use cgen memory functions, so make sure to include the header in the modules.
2021-06-27sim: bpf: include more local headers & fix broken funcsMike Frysinger5-10/+25
Various files were not including the relevant headers, or some funcs were missing prototypes entirely, leading to mismatch between the actual definition of the functions. Add includes to a few places and fix the broken functions that are uncovered as a result. Fixing some compile warnings (e.g. missing prototypes) often find real bugs.
2021-06-27sim: cgen: suppress trace non-literal printf warningMike Frysinger2-0/+10
The cgen trace macros are a bit ugly in that they specify a series of format strings & arguments in a single call. This means we pass a non-literal string to printf and the compiler warns about it. Use the diagnostic macros to suppress that in this one place.
2021-06-27sim: cgen: add asserts to fix unused engine warningsMike Frysinger2-1/+8
If the user passed in values outside the range of [0, MAX_NR_PROCESSORS), it would cause the code to access out-of-bind engine function pointers. Add some asserts to catch that and to fix the related compiler warnings.
2021-06-27sim: cgen: add printf attributes in a few more callsMike Frysinger2-2/+7
This helps the compiler process calls to these functions and emit warnings about mismatched format arguments.
2021-06-27sim: cgen: constify trace stringsMike Frysinger3-8/+17
Shouldn't be any functional changes here.
2021-06-27sim: cgen: always leverage the mem prototypesMike Frysinger2-14/+55
This fixes missing prototype warnings, and guarantees the prototypes stay in sync with the function definitions. One of the macros had fallen out by declaring the wrong return type.
2021-06-27sim: cgen: always leverage the ops prototypesMike Frysinger2-50/+50
This fixes missing prototype warnings, and guarantees the prototypes stay in sync with the function definitions.
2021-06-27sim: cgen: sync prototypes with implementationMike Frysinger2-17/+27
These prototype blocks are not normally used, so they've fallen out of sync with the actual function definitions. Resync them all.
2021-06-27sim: bpf: add explicit casts when using explicit formatsMike Frysinger2-12/+16
Since the value variable usually has an incompatible type for the wide variety of types it is printed as, add explicit casts to them all.
2021-06-27sim: bpf: fix mixed decls & code warnings (and style)Mike Frysinger3-3/+12
2021-06-27sim: erc32: merge with common configure scriptMike Frysinger11-4305/+213
Move the unique library tests to the common code so we can delete the erc32 configure logic entirely.
2021-06-27sim: bfin: move pkg-config & SDL checks to common codeMike Frysinger12-1196/+319
This reduces the unique logic in bfin/configure to make it easier to (eventually) unify it entirely.
2021-06-27Automatic date update in version.inGDB Administrator1-1/+1
2021-06-25gdb/guile: use return values of add_setshow functions in add_setshow_genericSimon Marchi2-88/+76
Use the set_show_commands objects returned by the add_setshow functions in add_setshow_generic. This lets us avoid looking up the commands after creating them, instead using the return objects directly. Make add_setshow_generic return a set_show_commands object, which is a bit nicer than returning both commands by parameter. Finally, store using that object in param_smob. Equivalent of 7bd22f56a3cf ("gdb/python: use return values of add_setshow functions in add_setshow_generic"), but for guile. gdb/ChangeLog: * guile/scm-param.c (struct param_smob) <set_command, show_command>: Remove. <commands>: New. (pascm_is_valid): Adjust. (add_setshow_generic): Use return values of add_setshow functions, return a set_show_commands. (gdbscm_register_parameter_x): Adjust. Change-Id: I18ed9e7dd5646529491c86749a5cb20763acd1f0
2021-06-25gdb: remove context parameter from add_setshow_enum_cmdSimon Marchi4-31/+48
I propose removing the context parameter from add_setshow_enum_cmd. It was useful before add_setshow_enum_cmd returned both created commands, as the caller couldn't easily set the context itself. But now, I think it's fine to just let the caller do it. gdb/ChangeLog: * command.h (add_setshow_enum_cmd): Remove context parameter. * cli/cli-decode.c (add_setshow_enum_cmd): Likewise, and don't set context. * cli/cli-style.c (cli_style_option::add_setshow_commands): Set context here. Change-Id: I377c4e6820ec9d5069492ed28f4cba342ce1336e
2021-06-25gdb: add assert in cmd_list_element::set_contextSimon Marchi2-1/+9
If something tries to set a context pointer on a cmd_list_element and m_context is not nullptr, it's likely that two parts of the code are trying to set different contexts, and one will overwrite the other. This is almost guaranteed to lead to bad behavior or a crash, as one of the spots will not be using the data it expects. This happened to me during development, so I think having this assert would be useful to catch this problem earlier. gdb/ChangeLog: * cli/cli-decode.h (struct cmd_list_element) <set_context>: Add assert. Change-Id: I1f2e9fda1bf2bec1b732c9b90e7d7910a97f2ac6
2021-06-25gdb: add context getter/setter to cmd_list_elementSimon Marchi17-62/+69
Straightforward replacement of get_cmd_context / set_cmd_context with cmd_list_element methods. gdb/ChangeLog: * cli/cli-decode.h (struct cmd_list_element) <set_context, context>: New. <context>: Rename to... <m_context>: ... this. * cli/cli-decode.c (set_cmd_context, get_cmd_context): Remove. * command.h (set_cmd_context, get_cmd_context): Remove, use cmd_list_element::set_context and cmd_list_element::context everywhere instead. Change-Id: I5016b0079014e3f17d1aa449ada7954473bf2b5d
2021-06-26Automatic date update in version.inGDB Administrator1-1/+1
2021-06-25gdb: change info sources to group results by objfileAndrew Burgess11-81/+342
Currently the 'info sources' command lists all of the known source files together, regardless of their source, e.g. here is a session debugging a test application that makes use of a shared library: (gdb) info sources Source files for which symbols have been read in: /tmp/info-sources/test.c, /usr/include/stdc-predef.h, /tmp/info-sources/header.h, /tmp/info-sources/helper.c Source files for which symbols will be read in on demand: (gdb) In this commit I change the format of the 'info sources' results so that the results are grouped by the object file that uses that source file. Here's the same session with the new output format: (gdb) info sources /tmp/info-sources/test.x: /tmp/info-sources/test.c, /usr/include/stdc-predef.h, /tmp/info-sources/header.h /lib64/ld-linux-x86-64.so.2: (Objfile has no debug information.) system-supplied DSO at 0x7ffff7fcf000: (Objfile has no debug information.) /tmp/info-sources/libhelper.so: /tmp/info-sources/helper.c, /usr/include/stdc-predef.h, /tmp/info-sources/header.h /lib64/libc.so.6: (Objfile has no debug information.) (gdb) Notice that in the new output some source files are repeated, e.g. /tmp/info-sources/header.h, as multiple objfiles use this source file. Further, some object files are tagged with the message '(Objfile has no debug information.)', it is also possible to see the message '(Full debug information has not yet been read for this file.)', which is printed when some symtabs within an objfile have not yet been expanded. All of the existing regular expression based filtering still works. An original version of this patch added the new format as an option to 'info sources', however, it was felt that the new layout was so much better than the old style that GDB should just switch to the new result format completely. gdb/ChangeLog: * NEWS: Mention changes to 'info sources'. * symtab.c (info_sources_filter::print): Delete. (struct output_source_filename_data) <print_header>: Delete declaration. <printed_filename_p>: New member function. (output_source_filename_data::print_header): Delete. (info_sources_worker): Update group-by-objfile style output to make it CLI suitable, simplify non-group-by-objfile now this is only used from the MI. (info_sources_command): Make group-by-objfile be the default for CLI info sources command. * symtab.h (struct info_sources_filter) <print>: Delete. gdb/doc/ChangeLog: * gdb.texinfo (Symbols): Document new output format for 'info sources'. gdb/testsuite/ChangeLog: * gdb.base/info_sources_2-header.h: New file. * gdb.base/info_sources_2-lib.c: New file. * gdb.base/info_sources_2-test.c: New file. * gdb.base/info_sources_2.exp: New file.
2021-06-25gdb/mi: add new --group-by-objfile flag for -file-list-exec-source-filesAndrew Burgess9-13/+192
This commit adds a new option '--group-by-objfile' to the MI command -file-list-exec-source-files. With this option the output format is changed; instead of a single list of source files the results are now a list of objfiles. For each objfile all of the source files associated with that objfile are listed. Here is an example of the new output format taken from the documentation (the newlines are added just for readability): -file-list-exec-source-files --group-by-objfile ^done,files=[{filename="/tmp/info-sources/test.x", debug-info="fully-read", sources=[{file="test.c", fullname="/tmp/info-sources/test.c", debug-fully-read="true"}, {file="/usr/include/stdc-predef.h", fullname="/usr/include/stdc-predef.h", debug-fully-read="true"}, {file="header.h", fullname="/tmp/info-sources/header.h", debug-fully-read="true"}]}, {filename="/lib64/ld-linux-x86-64.so.2", debug-info="none", sources=[]}, {filename="system-supplied DSO at 0x7ffff7fcf000", debug-info="none", sources=[]}, {filename="/tmp/info-sources/libhelper.so", debug-info="fully-read", sources=[{file="helper.c", fullname="/tmp/info-sources/helper.c", debug-fully-read="true"}, {file="/usr/include/stdc-predef.h", fullname="/usr/include/stdc-predef.h", debug-fully-read="true"}, {file="header.h", fullname="/tmp/info-sources/header.h", debug-fully-read="true"}]}, {filename="/lib64/libc.so.6", debug-info="none", sources=[]}] In the above output the 'debug-info' field associated with each objfile will have one of the values 'none', 'partially-read', or 'fully-read'. For example, /lib64/libc.so.6 has the value 'none', this indicates that this object file has no debug information associated with it, unsurprisingly then, the sources list of this object file is empty. An object file that was compiled with debug, for example /tmp/info-sources/libhelper.so, has the value 'fully-read' above indicating that this object file does have debug information, and the information is fully read into GDB. At different times this field might have the value 'partially-read' indicating that that the object file has debug information, but it has not been fully read into GDB yet. Source files can appear at most once for any single objfile, but can appear multiple times in total, if the same source file is part of multiple objfiles, for example /tmp/info-sources/header.h in the above output. The new output format is hidden behind a command option to ensure that the default output is unchanged, this ensures backward compatibility. The behaviour of the CLI "info sources" command is unchanged after this commit. gdb/ChangeLog: * NEWS: Mention additions to -file-list-exec-source-files. * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Add --group-by-objfile option. * symtab.c (isrc_flag_option_def): Rename to... (isrc_match_flag_option_def): ...this. (info_sources_option_defs): Rename to... (info_sources_match_option_defs): ...this, and update to rename of isrc_flag_option_def. (struct filename_grouping_opts): New struct. (isrc_grouping_flag_option_def): New type. (info_sources_grouping_option_defs): New static global. (make_info_sources_options_def_group): Update to return two option groups. (info_sources_command_completer): Update for changes to make_info_sources_options_def_group. (info_sources_worker): Add extra parameter, use this to display alternative output format. (info_sources_command): Pass extra parameter to info_sources_worker. (_initialize_symtab): Update for changes to make_info_sources_options_def_group. * symtab.h (info_sources_worker): Add extra parameter. gdb/doc/ChangeLog: * gdb.texinfo (GDB/MI File Commands): Document --group-by-objfile extension for -file-list-exec-source-files. gdb/testsuite/ChangeLog: * gdb.mi/mi-info-sources.exp: Add additional tests.