aboutsummaryrefslogtreecommitdiff
path: root/gdb/value.c
AgeCommit message (Collapse)AuthorFilesLines
2023-02-24gdb: fix parenthesis position in commentSimon Marchi1-1/+1
Change-Id: I535b597ab4482378910570d8dd69c090419941eb
2023-02-24GDB: Fix out of bounds accesses with limited-length valuesMaciej W. Rozycki1-3/+14
Fix accesses to limited-length values in `contents_copy_raw' and `contents_copy_raw_bitwise' so that they observe the limit of the original allocation. Reported by Simon Marchi as a heap-buffer-overflow AddressSanitizer issue triggered with gdb.ada/limited-length.exp. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-20gdb: revert one erroneous bool-ification changeSimon Marchi1-1/+1
Commit 42c13555ff88 ("Change value::m_stack to bool") erroneously changed a `0` to `false` in this call to read_value_memory. This parameter is `LONGEST bit_offset`, it should stay `0`. Change-Id: I128df6834cf8055ec6a7051e237e379978d3d651
2023-02-15Return bool from more value methodsTom Tromey1-15/+15
There are several more value methods that currently return 'int' but that should return 'bool'. This patch updates these. Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-02-15Have value::bits_synthetic_pointer return boolTom Tromey1-2/+2
This changes value::bits_synthetic_pointer to return bool and fixes up some fallout from this. Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-02-15Change value::m_stack to boolTom Tromey1-1/+1
This changes value::m_stack to be a bool and updates the various uses. Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-02-15Change value::m_lazy to boolTom Tromey1-4/+4
This changes value::m_lazy to be a bool and updates the various uses. Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-02-15Change value::m_modifiable to boolTom Tromey1-3/+3
This changes value::m_modifiable to be a bool and updates the various uses. Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-02-15gdb: store internalvars in an std::mapSimon Marchi1-27/+28
In a test downstream in ROCgdb, we had a test case failing when GDB_REVERSE_INIT_FUNCTIONS was set. The test was assuming a particular order in the output of "show convenience". And the order changes when running with GDB_REVERSE_INIT_FUNCTIONS. I think that a nice way to fix it is to make the output of "show convenience" sorted, and therefore stable. Ideally, I think that the the user-visible behavior of GDB should not change when using GDB_REVERSE_INIT_FUNCTIONS. Plus, it makes the output of "show convenience" look nice, not that it's really important. Implement this by storing the internal vars in an std::map, which is a sorted container. Change-Id: I1fca7e7877cc984a3a3432c7639d45e68d437241 Approved-By: Tom Tromey <tom@tromey.com>
2023-02-15gdb: add constructor to internalvarSimon Marchi1-5/+7
Add a constructor that takes the name as a parameter. Initialize the next and kind fields inline. Change-Id: Ic4db0aba85f1da9f12f3eee0ac62c0e5ef0cfe88 Approved-By: Tom Tromey <tom@tromey.com>
2023-02-15gdb: use std::string for internalvar::nameSimon Marchi1-10/+10
Change internalvar::name to std::string, automating memory management. It becomes necessary to allocate internalvar with new instead of XNEW. I didn't find how to trigger the code in complete_internalvar. It is called from condition_completer, so it should be by using the "condition" command, but I never managed to get in the right code path. Change-Id: I814d61361663e7becb8f3fb5f58c0180cdc414bc Approved-By: Tom Tromey <tom@tromey.com>
2023-02-14gdb: cast return value of std::unique_ptr::release to voidSimon Marchi1-2/+5
My editor shows warnings like: value.c:2784: warning: The value returned by this function should be used value.c:2784: note: cast the expression to void to silence this warning [bugprone-unused-return-value] These warnings come from clangd, so ultimately from one of the clang static analyzers (probably clang-tidy). Silence these warnings by casting to void. Add a comment to explain why this unusual thing is done. Change-Id: I58323959c0baf9f1b20a8d596e4c58dc77c6809a Approved-By: Tom Tromey <tom@tromey.com>
2023-02-13Rely on value_ref_ptr::operator->Tom Tromey1-7/+7
Simon pointed out some spots were doing val.get()->mumble, where val is a value_ref_ptr. These were introduced by the function-to-method script, replacing older code that passed the result of .get() to a function. Now that value.h is using methods, we can instead rely on operator->. This patch replaces all the newly-introduced instances of this. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Remove deprecated_lval_hackTom Tromey1-22/+22
This removes deprecated_lval_hack and the VALUE_LVAL macro, replacing all uses with a call to value::lval. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Introduce set_lval method on valueTom Tromey1-10/+10
This introduces the set_lval method on value, one step toward removing deprecated_lval_hack. Ultimately I think the goal should be for some of these set_* methods to be replaced with constructors; but I haven't done this, as the series is already too long. Other 'deprecated' methods can probably be handled the same way. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn record_latest_value into a methodTom Tromey1-17/+13
record_latest_value now access some internals of struct value, so turn it into a method. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Add value::set_modifiableTom Tromey1-2/+2
This introduces a value::set_modifiable and changes a couple of spots to use it. I'm not completely sure the comments by deprecated_modifiable are correct any more. Perhaps they should be removed and the method renamed. Like so many before me, though, I've deferred investigation of the issue. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn various value copying-related functions into methodsTom Tromey1-126/+87
This patch turns a grab bag of value functions to methods of value. These are done together because their implementations are interrelated. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn preserve_one_value into methodTom Tromey1-13/+8
This changes preserve_one_value 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 some xmethod functions into methodsTom Tromey1-11/+11
This turns value_from_xmethod, result_type_of_xmethod, and call_xmethod to be methods of value. value_from_xmethod is a static "constructor" now. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Change some code to use value methodsTom Tromey1-14/+14
A few functions in value.c were accessing the internal fields of struct value. However, in these cases it seemed simpler to change them to use the public API rather than convert them to be methods. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn set_value_component_location into methodTom Tromey1-15/+14
This turns set_value_component_location into a method of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_non_lval and value_force_lval into methodsTom Tromey1-15/+15
This changes value_non_lval and value_force_lval to be methods of value. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn many optimized-out value functions into methodsTom Tromey1-81/+55
This turns many functions that are related to optimized-out or availability-checking to be methods of value. The static function value_entirely_covered_by_range_vector is also converted to be a private method. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn value_copy into a methodTom Tromey1-29/+28
This turns value_copy into a method of value. Much of this was written by script. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Fully qualify calls to copy in value.cTom Tromey1-3/+3
A coming patch will add value::copy, so this namespace-qualifies existing calls to 'copy' in value.c, to ensure it will still compile after that change is done. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-02-13Turn remaining value_contents functions into methodsTom Tromey1-34/+34
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 Tromey1-17/+6
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-13Turn value_bits_synthetic_pointer into a methodTom Tromey1-7/+5
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 Tromey1-18/+19
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 Tromey1-28/+24
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 Tromey1-65/+59
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 Tromey1-33/+32
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 Tromey1-3/+2
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 Tromey1-5/+5
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 Tromey1-3/+3
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 Tromey1-21/+21
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 Tromey1-16/+14
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 Tromey1-12/+6
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 Tromey1-28/+27
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 Tromey1-16/+0
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 Tromey1-13/+1
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 Tromey1-9/+9
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 Tromey1-13/+1
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 Tromey1-32/+20
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 Tromey1-41/+17
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 Tromey1-34/+26
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 Tromey1-5/+0
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 Tromey1-17/+6
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 Tromey1-16/+2
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>