aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-02-13Turn remaining value_contents functions into methodsTom Tromey84-329/+330
This turns the remaining value_contents functions -- value_contents, value_contents_all, value_contents_for_printing, and value_contents_for_printing_const -- into methods of value. It also converts the static functions require_not_optimized_out and require_available to be private methods. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_incref and value_decref into methodsTom Tromey7-39/+27
This changes value_incref and value_decref to be methods of value. Much of this patch was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Move value_ref_policy methods out-of-lineTom Tromey1-9/+14
This moves the value_ref_policy methods to be defined out-of-line. This is a necessary step to change value_incref and value_decref to be methods of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_bits_synthetic_pointer into a methodTom Tromey8-31/+26
This changes value_bits_synthetic_pointer to be a method of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_contents_eq into a methodTom Tromey7-93/+102
This changes value_contents_eq to be a method of value. It also converts the static function value_contents_bits_eq into a private method. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn allocate_value_contents into a methodTom Tromey2-28/+37
This turns the static function allocate_value_contents into a method on value. It is temporarily public, until some users are converted. set_limited_array_length is converted as well. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_fetch_lazy into a methodTom Tromey16-88/+98
This changes value_fetch_lazy to be a method of value. A few helper functions are converted as well, to avoid problems in later patches when the data members are all made private. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn some value_contents functions into methodsTom Tromey32-145/+142
This turns value_contents_raw, value_contents_writeable, and value_contents_all_raw into methods on value. The remaining functions will be changed later in the series; they were a bit trickier and so I didn't include them in this patch. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_zero into static "constructor"Tom Tromey15-77/+77
This turns value_zero into a static "constructor" of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn allocate_optimized_out_value into static "constructor"Tom Tromey11-20/+21
This turns allocate_optimized_out_value into a static "constructor" of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn allocate_computed_value into static "constructor"Tom Tromey7-15/+14
This turns allocate_computed_value into a static "constructor" of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn allocate_value into a static "constructor"Tom Tromey37-128/+135
This changes allocate_value to be a static "constructor" of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn allocate_value_lazy into a static "constructor"Tom Tromey6-21/+29
This changes allocate_value_lazy to be a static "constructor" of struct value. I considered trying to change value to use ordinary new/delete, but it seems to me that due to reference counting, we may someday want to change these static constructors to return value_ref_ptr instead. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn more deprecated_* functions into methodsTom Tromey2-18/+16
This changes deprecated_value_internalvar_hack, deprecated_value_internalvar_hack, and deprecated_value_regnum_hack into methods on value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_address and set_value_address functions into methodsTom Tromey45-167/+166
This changes the value_address and set_value_address functions to be methods of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_initialized and set_value_initialized functions into methodsTom Tromey4-24/+11
This changes the value_initialized and set_value_initialized functions to be methods of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Convert value_lval_const and deprecated_lval_hack to methodsTom Tromey5-24/+14
This converts the value_lval_const and deprecated_lval_hack functions to be methods on value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_computed_closure and value_computed_funcs functions into methodsTom Tromey6-34/+34
This changes the value_computed_funcs and value_computed_closure functions to be methods of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_stack and set_value_stack functions into methodsTom Tromey5-19/+10
This changes the value_stack and set_value_stack functions to be methods of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_lazy and set_value_lazy functions into methodsTom Tromey22-96/+87
This changes the value_lazy and set_value_lazy functions to be methods of value. Much of this patch was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn some value offset functions into methodTom Tromey13-88/+72
This changes various offset-related functions to be methods of value. Much of this patch was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_enclosing_type into methodTom Tromey15-119/+111
This changes value_enclosing_type to be a method of value. Much of this patch was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn deprecated_value_modifiable into methodTom Tromey7-17/+12
This changes deprecated_value_modifiable to be a method of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_offset into methodTom Tromey12-53/+44
This changes value_offset to be a method of value. Much of this patch was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_parent into methodTom Tromey5-30/+18
This changes value_parent to be a method of value. Much of this patch was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_bitpos into methodTom Tromey6-39/+30
This changes value_bitpos to be a method of value. Much of this patch was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_bitsize into methodTom Tromey6-46/+37
This changes value_bitsize to be a method of value. Much of this patch was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_arch into methodTom Tromey3-11/+10
This changes value_arch to be a method of value. Much of this patch was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn deprecated_set_value_type into a methodTom Tromey9-35/+25
This changes deprecated_set_value_type to be a method of value. Much of this patch was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_type into methodTom Tromey107-884/+880
This changes value_type to be a method of value. Much of this patch was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Move struct value to value.hTom Tromey2-230/+223
This moves struct value to value.h. For now, all members remain public, but this is a temporary state -- by the end of the series we'll add 'private'. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Move ~value body out-of-lineTom Tromey1-12/+14
struct value is going to move to value.h, but to avoid having excessive code there, first move the destructor body out-of-line. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Rename all fields of struct valueTom Tromey2-202/+202
This renames all the fields of struct value, in preparation for the coming changes. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13PR30120: fix x87 fucomp misassembledMichael Matz4-5/+22
this fixes the entry for 'fucomp' to use the correct Reg value (otherwise it's assembled as 'fucom').
2023-02-13Remove unused imports from gdb's Python codeTom Tromey4-5/+0
The "sys" import is unused in several Python files. This removes this line from all the places where it is unnecessary.
2023-02-13gdb/tui: don't leak the known_window_types mapAndrew Burgess1-24/+17
This commit finishes the task that was started in the previous commit. Now that all Python TUI window factories are correctly deleted when the Python interpreter is shut down, we no longer need to dynamically allocate the known_window_types map in tui-layout.c This commit changes known_window_types to a statically allocated data structure, removes the dynamic allocation from initialize_known_windows, and then replaces lots of '->' with '.' throughout this file. There should be no user visible changes after this commit. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-02-13gdb/python: deallocate tui window factories at Python shut downAndrew Burgess4-2/+84
The previous commit relied on spotting when a Python defined TUI window factory was deleted. I spotted that the window factories are not deleted when GDB shuts down its Python environment, they are only deleted when one window factory replaces another. Consider this example Python script: class TestWindowFactory: def __init__(self, msg): self.msg = msg print("Entering TestWindowFactory.__init__: %s" % self.msg) def __call__(self, tui_win): print("Entering TestWindowFactory.__call__: %s" % self.msg) return TestWindow(tui_win, self.msg) def __del__(self): print("Entering TestWindowFactory.__del__: %s" % self.msg) gdb.register_window_type("test_window", TestWindowFactory("A")) gdb.register_window_type("test_window", TestWindowFactory("B")) And this GDB session: (gdb) source tui.py Entering TestWindowFactory.__init__: A Entering TestWindowFactory.__init__: B Entering TestWindowFactory.__del__: B (gdb) quit Notice that when the 'B' window replaces the 'A' window we see the 'A' object being deleted. But, when Python is shut down (after the 'quit') the 'B' object is never deleted. Instead, GDB retains a reference to the window factory object, which forces the Python object to remain live even after the Python interpreter itself has been shut down. The references themselves are held in a dynamically allocated std::unordered_map (in tui/tui-layout.c) which is never deallocated, thus the underlying Python references are never decremented to zero, and so GDB never tries to delete these Python objects. This commit is the first half of the work to clean up this edge case. All gdbpy_tui_window_maker objects (the objects that implement the TUI window factory callback for Python defined TUI windows), are now linked together into a global list using the intrusive list mechanism. When GDB shuts down the Python interpreter we can now walk this global list and release the reference that is held to the underlying Python object. By releasing this reference the Python object will now be deleted. I've added a new assert in gdbpy_tui_window_maker::operator(), this will catch the case where we somehow end up in here after having reset the reference to the underlying Python object. I don't think this should ever happen though as we only clear the references when shutting down the Python interpreter, and the ::operator() function is only called when trying to apply a new TUI layout - something that shouldn't happen while GDB itself is shutting down. This commit does not update the std::unordered_map in tui-layout.c, that will be done in the next commit. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-02-13gdb/python: allow Python TUI windows to be replacedAndrew Burgess3-0/+129
The documentation for gdb.register_window_type says: "... It's an error to try to replace one of the built-in windows, but other window types can be replaced. ..." I take this to mean that if I imported a Python script like this: gdb.register_window_type('my_window', FactoryFunction) Then GDB would have a new TUI window 'my_window', which could be created by calling FactoryFunction(). If I then, in the same GDB session imported a script which included: gdb.register_window_type('my_window', UpdatedFactoryFunction) Then GDB would replace the old 'my_window' factory with my new one, GDB would now call UpdatedFactoryFunction(). This is pretty useful in practice, as it allows users to iterate on their window implementation within a single GDB session. However, right now, this is not how GDB operates. The second call to register_window_type is basically ignored and the old window factory is retained. This is because in tui_register_window (tui/tui-layout.c) we use std::unordered_map::emplace to insert the new factory function, and emplace doesn't replace an existing element in an unordered_map. In this commit, before the emplace call, I now search for an already existing element, and delete any matching element from the map, the emplace call will then add the new factory function. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-02-13Fix doc build dependencies for --with-system-readlineKeith Seitz3-4/+15
PR build/30108 concerns building gdb documentation with --with-sytem-readline. If the in-tree readline directory is missing, though, the docs will fail to build: make[4]: Entering directory '/home/keiths/work/readline-doc-issue/linux/gdb/doc' make[4]: *** No rule to make target '../../../src/gdb/doc/../../readline/readline/doc/rluser.texi', needed by 'gdb.info'. Stop. The listed file (and hsuser.texi) are conditionally included by gdb.texinfo. When system readline is used, gdb/configure.ac will leave READLINE_TEXI_INCFLAGS empty, causing doc/Makefile.in to output a line to $BUILD/doc/GDBvn.texi with "@set SYSTEM_READLINE". This surpresses the inclusion of the missing files. They are not needed or used in this scenario. However, GDB_DOC_SOURCE_INCLUDES always lists these two files as dependencies, thus provoking the build error whenever readline/ is missing. This patch fixes this by creating (essentially) a conditional setting of the dependencies to be included from readline.
2023-02-13Fix PR30079: abort on mingwMichael Matz1-1/+2
the early-out in wild_sort is not enough, it might still be that filenames are equal _and_ the wildcard list doesn't specify a sort order either. Don't call compare_section then. Tested on all targets.
2023-02-13_bfd_ecoff_slurp_symbol_table buffer overflowAlan Modra1-12/+20
Add missing bounds check, and tidy the existing bounds checking. * ecoff.c (_bfd_ecoff_slurp_symbol_table): Break overlong lines. Set bfd_error. Bounds check internal_sym.iss.
2023-02-13opcodes/mips: disassemble unknown micromips instructions as two shortsAndrew Burgess6-5/+41
Before commit: commit 2438b771ee07be19d5b01ea55e077dd8b7cef445 Date: Wed Nov 2 15:53:43 2022 +0000 opcodes/mips: use .word/.short for undefined instructions unknown 32-bit microMIPS instructions were disassembled as a raw 32-bit number with no '.word' directive. The above commit changed this and added a '.word' directive before the 32-bit number. It was pointed out on the mailing list, that for microMIPS it would be better to display such 32-bit instructions using a '.short' directive followed by two 16-bit values. This commit updates the mips disassembler to do this, and adds a new test that validates this output.
2023-02-13gdb/testsuite: handle differences in guile error string outputAndrew Burgess1-2/+4
A new guile test added in commit: commit 0a9ccb9dd79384f3ba3f8cd75940e8868f3b526f Date: Mon Feb 6 13:04:16 2023 +0000 gdb: only allow one of thread or task on breakpoints or watchpoints fails for some versions of guile. It turns out that some versions of guile emit an error like this: (gdb) guile (set-breakpoint-thread! bp 1) ERROR: In procedure set-breakpoint-thread!: In procedure gdbscm_set_breakpoint_thread_x: cannot set both task and thread attributes Error while executing Scheme code. while other versions of guile emit the error like this: (gdb) guile (set-breakpoint-thread! bp 1) ERROR: In procedure set-breakpoint-thread!: ERROR: In procedure gdbscm_set_breakpoint_thread_x: cannot set both task and thread attributes Error while executing Scheme code. notice the extra 'ERROR: ' on the second line of output. This commit updates the test regexp to handle this optional 'ERROR: ' string.
2023-02-13stabs.c static stateAlan Modra3-46/+71
Move all the function local static state variables to file scope, in order to tidy memory on exit and to reinit everything for that annoying oss-fuzz. Also fix a couple memory leaks. * read.h (read_begin, read_end): Declare. * read.c (read_begin): Call stabs_begin. (read_end): Call stabs_end. * stabs.c (stabs_begin, stabs_end): New functions. (in_dot_func_p): Delete, use current_function_label instead. (cached_sec): Move from s_stab_generic. (last_asm_file, file_label_count): Move from generate_asm_file. (line_label_count, prev_lineno, prev_line_file): Move from stabs_generate_asm_lineno. (void_emitted_p): Move from stabs_generate_asm_func. (endfunc_label_count): Move from stabs_generate_asm_endfunc. (stabs_generate_asm_lineno): Simplify setting of prev_line_file. (stabs_generate_asm_func): Don't leak current_function_label. (stabs_generate_asm_endfunc): Likewise.
2023-02-13Split off gas init to functionsAlan Modra1-72/+87
With some slight reordering. * as.c (gas_early_init, gas_late_init): New functions, split.. (main): ..from here.
2023-02-13gdb/testsuite: look for hipcc in env(ROCM_PATH)Lancelot SIX1-2/+5
If the hipcc compiler cannot be found in dejagnu's tool_root_dir, look for it in $::env(ROCM_PATH) (if set). If hipcc is still not found, fallback to "hipcc" so the compiler will be searched in the PATH. This removes the fallback to the hard-coded "/opt/rocm/bin" prefix. This change is done so ROCM tools are searched in a uniform manner. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13gdb/testsuite: allow_hipcc_tests tests the hipcc compilerLancelot SIX2-1/+72
Update allow_hipcc_tests so all gdb.rocm tests are skipped if we do not have a working hipcc compiler available. To achieve this, adjust gdb_simple_compile to ensure that the hip program is saved in a ".cpp" file before calling hipcc otherwise compilation will fail. One thing to note is that it is possible to have a hipcc installed with a CUDA backend. Compiling with this back-end will successfully result in an application, but GDB cannot debug it (at least for the offload part). In the context of the gdb.rocm tests, we want to detect such situation where gdb_simple_compile would give a false positive. To achieve this, this patch checks that there is at least one AMDGPU device available and that hipcc can compile for this or those targets. Detecting the device is done using the rocm_agent_enumerator tool which is installed with the all ROCm installations (it is used by hipcc to detect identify targets if this is not specified on the comand line). This patch also makes the allow_hipcc_tests proc a cached proc. Co-Authored-By: Pedro Alves <pedro@palves.net> Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13gdb/testsuite: require amd-dbgapi support to run rocm testsLancelot SIX1-0/+7
Update allow_hipcc_tests to check that GDB has the amd-dbgapi support built-in. Without this support, all tests using hipcc and the rocm stack will fail. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13gdb/testsuite: Rename skip_hipcc_tests to allow_hipcc_testsLancelot SIX2-7/+4
Rename skip_hipcc_tests to allow_hipcc_tests so it can be used as a "require" predicate in tests. Use require in gdb.rocm/simple.exp. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13gdb: 'show config' shows --with[out]-amd-dbgapiLancelot SIX4-0/+17
Ensure that the "show configuration" command and the "--configuration" command line switch shows if GDB was built with the AMDGPU support or not. This will be used in a later patch in this series. Approved-By: Simon Marchi <simon.marchi@efficios.com>