1999-04-16 01:35:26 +00:00
|
|
|
|
/* Definitions for values of C expressions, for GDB.
|
2003-05-10 23:10:08 +00:00
|
|
|
|
|
2023-01-01 16:49:04 +04:00
|
|
|
|
Copyright (C) 1986-2023 Free Software Foundation, Inc.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
This file is part of GDB.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-23 18:08:50 +00:00
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
1999-07-07 20:19:36 +00:00
|
|
|
|
(at your option) any later version.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 18:08:50 +00:00
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
#if !defined (VALUE_H)
|
|
|
|
|
#define VALUE_H 1
|
|
|
|
|
|
2023-09-19 20:34:23 -06:00
|
|
|
|
#include "frame.h"
|
C++ify xmethod_worker, get rid of VEC(xmethod_worker_ptr)
The initial goal of this patch was to remove the usage of
VEC(xmethod_worker_ptr) and corresponding cleanups. I ended up having
to C++ify the xmethod_worker code, to be able to have xmethod_workers
free their data in destructors, and therefore be able to use vectors of
xmethod_worker unique_ptr.
The operations in extension_language_ops that act on one instance of
xmethod_worker (get result type, get args type, invoke) are transformed
to methods of xmethod_worker. xmethod_worker becomes an abstract base
class with virtual pure methods which python_xmethod_worker implements.
The only xmethod-related operation left in extension_language_ops is
get_matching_xmethod_workers, which returns a list of xmethod_workers.
The changes are relatively straightforward, but here are some notes on
things that may raise eyebrows:
- I was not really comfortable with the value_of_xmethod function. At
first it looks like a simple getter, so I considered making it a
method of xmethod_worker. But actually it creates a value and
transfers the ownership of the xmethod_worker to it. It would be a
bit weird and error-prone if calling a method on an object silently
removed the ownership of the object from the caller. To reflect the
behavior more accurately, I renamed it to value_from_xmethod and made
it accept an rvalue-reference (so the caller knows it gives away the
ownership). I noticed the backlink from xmethod_worker to its owning
value was not used, so I removed it.
- Some code, like get_matching_xmethod_workers, made each callee fill
a new vector, which was then merged in the result vector. I think
it's safe if we always pass the same vector around, and each
implementation just appends to it.
- The clone operation does not seem particularly useful, it is removed
in the following patch.
gdb/ChangeLog:
* extension-priv.h (enum ext_lang_rc): Remove, move to extension.h.
(struct extension_language_ops) <clone_xmethod_worker_data>: Remove.
<free_xmethod_worker_data>: Remove.
<get_matching_xmethod_workers>: Chance VEC to std::vector.
<get_xmethod_arg_types>: Remove.
<get_xmethod_result_type>: Remove.
<invoke_xmethod>: Remove.
* extension.c (new_xmethod_worker): Remove.
(clone_xmethod_worker): Remove.
(get_matching_xmethod_workers): Return void, pass std::vector by
pointer.
(get_xmethod_arg_types): Rename to...
(xmethod_worker::get_arg_types): ... this, and adjust.
(get_xmethod_result_type): Rename to...
(xmethod_worker::get_result_type): ... this, and adjust.
(invoke_xmethod): Remove.
(free_xmethod_worker): Remove.
(free_xmethod_worker_vec): Remove.
* extension.h (enum ext_lang_rc): Move here from
extension-priv.h.
(struct xmethod_worker): Add constructor and destructor.
<data>: Remove.
<value>: Remove.
<invoke, clone, do_get_result_type, do_get_arg_types>: New
virtual pure methods.
<get_arg_types, get_result_type>: New methods.
(xmethod_worker_ptr): Remove typedef.
(DEF_VEC_P (xmethod_worker_ptr)): Remove.
(xmethod_worker_vec): Remove typedef.
(xmethod_worker_up): New typedef.
(invoke_xmethod): Remove.
(clone_xmethod_worker): Remove.
(free_xmethod_worker): Remove.
(free_xmethod_worker_vec): Remove.
(get_xmethod_arg_types): Remove.
(get_xmethod_result_type): Remove.
* valops.c (find_method_list): Use std::vector, don't use
intermediate vector.
(value_find_oload_method_list): Use std::vector.
(find_overload_match): Use std::vector.
(find_oload_champ): Use std::vector.
* value.c (value_free): Use operator delete.
(value_of_xmethod): Rename to...
(value_from_xmethod): ... this. Don't assign
xmethod_worker::value, take rvalue-reference.
(result_type_of_xmethod): Adjust.
(call_xmethod): Adjust.
* value.h: Include extension.h.
(struct xmethod_worker): Don't forward-declare.
(value_of_xmethod): Rename to...
(value_from_xmethod): ... this, take rvalue-reference.
* python/py-xmethods.c (struct gdbpy_worker_data): Rename to...
(struct python_xmethod_worker): ... this, add constructor and
destructor.
<invoke, clone, do_get_arg_types, do_get_result_type>: Implement.
(gdbpy_free_xmethod_worker_data): Rename to...
(python_xmethod_worker::~python_xmethod_worker): ... this and
adjust.
(gdbpy_clone_xmethod_worker_data): Rename to...
(python_xmethod_worker::clone): ... this and adjust.
(gdbpy_get_matching_xmethod_workers): Use std::vector, don't use
temporary vector.
(gdbpy_get_xmethod_arg_types): Rename to...
(python_xmethod_worker::do_get_arg_types): ... this and adjust.
(gdbpy_get_xmethod_result_type): Rename to...
(python_xmethod_worker::do_get_result_type): ... this and
adjust.
(gdbpy_invoke_xmethod): Rename to...
(python_xmethod_worker::invoke): ... this and adjust.
(new_python_xmethod_worker): Rename to...
(python_xmethod_worker::python_xmethod_worker): ... this and
adjust.
* python/python-internal.h (gdbpy_clone_xmethod_worker_data):
Remove.
(gdbpy_free_xmethod_worker_data): Remove.
(gdbpy_get_matching_xmethod_workers): Use std::vector.
(gdbpy_get_xmethod_arg_types): Remove.
(gdbpy_get_xmethod_result_type): Remove.
(gdbpy_invoke_xmethod): Remove.
* python/python.c (python_extension_ops): Remove obsolete
callbacks.
2018-01-07 09:25:32 -05:00
|
|
|
|
#include "extension.h"
|
Rename common to gdbsupport
This is the next patch in the ongoing series to move gdbsever to the
top level.
This patch just renames the "common" directory. The idea is to do
this move in two parts: first rename the directory (this patch), then
move the directory to the top. This approach makes the patches a bit
more tractable.
I chose the name "gdbsupport" for the directory. However, as this
patch was largely written by sed, we could pick a new name without too
much difficulty.
Tested by the buildbot.
gdb/ChangeLog
2019-07-09 Tom Tromey <tom@tromey.com>
* contrib/ari/gdb_ari.sh: Change common to gdbsupport.
* configure: Rebuild.
* configure.ac: Change common to gdbsupport.
* gdbsupport: Rename from common.
* acinclude.m4: Change common to gdbsupport.
* Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES)
(HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to
gdbsupport.
* aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c,
amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c,
amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c,
amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c,
amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c,
arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c,
arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c,
arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c,
arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c,
auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h,
btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c,
charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c,
cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c,
coff-pe-read.c, command.h, compile/compile-c-support.c,
compile/compile-c.h, compile/compile-cplus-symbols.c,
compile/compile-cplus-types.c, compile/compile-cplus.h,
compile/compile-loc2c.c, compile/compile.c, completer.c,
completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c,
cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c,
darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c,
disasm.h, dtrace-probe.c, dwarf-index-cache.c,
dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c,
dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c,
event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c,
features/aarch64-core.c, features/aarch64-fpu.c,
features/aarch64-pauth.c, features/aarch64-sve.c,
features/i386/32bit-avx.c, features/i386/32bit-avx512.c,
features/i386/32bit-core.c, features/i386/32bit-linux.c,
features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c,
features/i386/32bit-segments.c, features/i386/32bit-sse.c,
features/i386/64bit-avx.c, features/i386/64bit-avx512.c,
features/i386/64bit-core.c, features/i386/64bit-linux.c,
features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c,
features/i386/64bit-segments.c, features/i386/64bit-sse.c,
features/i386/x32-core.c, features/riscv/32bit-cpu.c,
features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c,
features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c,
features/riscv/64bit-fpu.c, features/tic6x-c6xp.c,
features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h,
findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h,
gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c,
gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c,
go32-nat.c, guile/guile.c, guile/scm-ports.c,
guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c,
i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c,
i386-linux-tdep.c, i386-tdep.c, i387-tdep.c,
ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c,
inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h,
inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h,
inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c,
linux-tdep.c, linux-thread-db.c, location.c, machoread.c,
macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h,
mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c,
mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h,
minsyms.c, mips-linux-tdep.c, namespace.h,
nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h,
nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c,
nat/amd64-linux-siginfo.c, nat/fork-inferior.c,
nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c,
nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c,
nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h,
nat/linux-waitpid.c, nat/mips-linux-watch.c,
nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c,
nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c,
nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h,
obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c,
parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c,
procfs.c, producer.c, progspace.h, psymtab.h,
python/py-framefilter.c, python/py-inferior.c, python/py-ref.h,
python/py-type.c, python/python.c, record-btrace.c, record-full.c,
record.c, record.h, regcache-dump.c, regcache.c, regcache.h,
remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c,
riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c,
selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c,
ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c,
source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c,
stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h,
symtab.c, symtab.h, target-descriptions.c, target-descriptions.h,
target-memory.c, target.c, target.h, target/waitstatus.c,
target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c,
top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c,
tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h,
unittests/array-view-selftests.c,
unittests/child-path-selftests.c, unittests/cli-utils-selftests.c,
unittests/common-utils-selftests.c,
unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c,
unittests/format_pieces-selftests.c,
unittests/function-view-selftests.c,
unittests/lookup_name_info-selftests.c,
unittests/memory-map-selftests.c, unittests/memrange-selftests.c,
unittests/mkdir-recursive-selftests.c,
unittests/observable-selftests.c,
unittests/offset-type-selftests.c, unittests/optional-selftests.c,
unittests/parse-connection-spec-selftests.c,
unittests/ptid-selftests.c, unittests/rsp-low-selftests.c,
unittests/scoped_fd-selftests.c,
unittests/scoped_mmap-selftests.c,
unittests/scoped_restore-selftests.c,
unittests/string_view-selftests.c, unittests/style-selftests.c,
unittests/tracepoint-selftests.c, unittests/unpack-selftests.c,
unittests/utils-selftests.c, unittests/xml-utils-selftests.c,
utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c,
value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c,
xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c,
xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport.
gdb/gdbserver/ChangeLog
2019-07-09 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
* configure.ac: Change common to gdbsupport.
* acinclude.m4: Change common to gdbsupport.
* Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS)
(version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change
common to gdbsupport.
* ax.c, event-loop.c, fork-child.c, gdb_proc_service.h,
gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c,
inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c,
linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c,
linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c,
linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h,
nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c,
server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h,
thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change
common to gdbsupport.
2019-05-05 20:29:24 -06:00
|
|
|
|
#include "gdbsupport/gdb_ref_ptr.h"
|
Fix fixed-point binary operation type handling
Testing showed that gdb was not correctly handling some fixed-point
binary operations correctly.
Addition and subtraction worked by casting the result to the type of
left hand operand. So, "fixed+int" had a different type -- and
different value -- from "int+fixed".
Furthermore, for multiplication and division, it does not make sense
to first cast both sides to the fixed-point type. For example, this
can prevent "f * 1" from yielding "f", if 1 is not in the domain of
"f". Instead, this patch changes gdb to use the value. (This is
somewhat different from Ada semantics, as those can yield a "universal
fixed point".)
This includes a new test case. It is only run in "minimal" mode, as
the old-style fixed point works differently, and is obsolete, so I
have no plans to change it.
gdb/ChangeLog
2021-01-06 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_evaluate_subexp) <BINOP_ADD, BINOP_SUB>:
Do not cast result.
* valarith.c (fixed_point_binop): Handle multiplication
and division specially.
* valops.c (value_to_gdb_mpq): New function.
(value_cast_to_fixed_point): Use it.
gdb/testsuite/ChangeLog
2021-01-06 Tom Tromey <tromey@adacore.com>
* gdb.ada/fixed_points/pck.ads (Delta4): New constant.
(FP4_Type): New type.
(FP4_Var): New variable.
* gdb.ada/fixed_points/fixed_points.adb: Update.
* gdb.ada/fixed_points.exp: Add tests for binary operators.
2021-01-06 13:47:48 -07:00
|
|
|
|
#include "gmp-utils.h"
|
2003-05-10 23:10:08 +00:00
|
|
|
|
|
|
|
|
|
struct block;
|
2003-04-12 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh: Add missing opaque declarations.
* gdbarch.h: Regnerate.
* symtab.h: Add missing opaque declarations.
* value.h, target.h, symfile.h, stabsread.h: Ditto.
* x86-64-tdep.h, xmodem.h, monitor.h, typeprint.h: Ditto.
* srec.h, solib-svr4.h, source.h, inferior.h: Ditto.
* ser-unix.h, serial.h, remote-utils.h, gdbcore.h: Ditto.
* ppc-tdep.h, ocd.h, mips-tdep.h, gdbtypes.h: Ditto.
* buildsym.h, builtin-regs.h, linespec.h, language.h: Ditto.
* i387-tdep.h, gdbthread.h, event-top.h, gdb.h: Ditto.
* dwarf2cfi.h, doublest.h, disasm.h, cp-abi.h: Ditto.
* cli-out.h, c-lang.h, ax-gdb.h, arch-utils.h: Ditto.
* ada-lang.h, config/nm-lynx.h, config/nm-linux.h: Ditto.
* config/sparc/tm-sp64.h, config/rs6000/tm-rs6000.h: Ditto.
* config/pa/tm-hppah.h, config/m68k/tm-delta68.h: Ditto.
* cli/cli-setshow.h, cli/cli-script.h: Ditto.
2003-04-12 17:41:26 +00:00
|
|
|
|
struct expression;
|
2003-05-10 23:10:08 +00:00
|
|
|
|
struct regcache;
|
2003-04-12 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh: Add missing opaque declarations.
* gdbarch.h: Regnerate.
* symtab.h: Add missing opaque declarations.
* value.h, target.h, symfile.h, stabsread.h: Ditto.
* x86-64-tdep.h, xmodem.h, monitor.h, typeprint.h: Ditto.
* srec.h, solib-svr4.h, source.h, inferior.h: Ditto.
* ser-unix.h, serial.h, remote-utils.h, gdbcore.h: Ditto.
* ppc-tdep.h, ocd.h, mips-tdep.h, gdbtypes.h: Ditto.
* buildsym.h, builtin-regs.h, linespec.h, language.h: Ditto.
* i387-tdep.h, gdbthread.h, event-top.h, gdb.h: Ditto.
* dwarf2cfi.h, doublest.h, disasm.h, cp-abi.h: Ditto.
* cli-out.h, c-lang.h, ax-gdb.h, arch-utils.h: Ditto.
* ada-lang.h, config/nm-lynx.h, config/nm-linux.h: Ditto.
* config/sparc/tm-sp64.h, config/rs6000/tm-rs6000.h: Ditto.
* config/pa/tm-hppah.h, config/m68k/tm-delta68.h: Ditto.
* cli/cli-setshow.h, cli/cli-script.h: Ditto.
2003-04-12 17:41:26 +00:00
|
|
|
|
struct symbol;
|
|
|
|
|
struct type;
|
2003-05-10 23:10:08 +00:00
|
|
|
|
struct ui_file;
|
* valprint.c (val_print): Add new language parameter and use it
instead of using the current_language. Update calls to val_print
throughout.
(common_val_print): Add new langauge parameter and pass it to
val_print.
* value.h (struct language_defn): Add opaque declaration.
(val_print, common_val_print): Update declarations.
* stack.c (print_frame_args): Update call to common_val_print
using the appropriate language.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* c-valprint, f-valprint.c, m2-valprint.c, mt-tdep.c, infcmd.c,
mi/mi-main.c, jv-valprint.c, ada-valprint.c, varobj.c, p-valprint.c,
scm-valprint.c, cp-valprint.c, sh64-tdep.c, printcmd.c:
#include "language.h" if necessary.
Update calls to val_print and common_val_print.
* Makefile.in (mt-tdep.o, sh64-tdep.o, mi-cmds.o, mi-main.o):
Update dependencies.
2008-05-06 21:35:01 +00:00
|
|
|
|
struct language_defn;
|
gdb
* varobj.c (value_get_print_value): Include valprint.h.
(value_get_print_value): Use get_formatted_print_options.
* value.h (struct value_print_options): Declare.
(value_print, val_print, common_val_print, val_print_string):
Update.
* value.c: Include valprint.h.
(show_values): Use get_user_print_options.
(show_convenience): Likewise.
* valprint.h (prettyprint_arrays, prettyprint_structs): Don't
declare.
(struct value_print_options): New type.
(vtblprint, unionprint, addressprint, objectprint, print_max,
inspect_it, repeat_count_threshold, output_format,
stop_print_at_null): Don't declare.
(user_print_options, get_user_print_options,
get_raw_print_options, get_formatted_print_options): Declare.
(print_array_indexes_p): Don't declare.
(maybe_print_array_index, val_print_array_elements): Update.
* valprint.c (print_max): Remove.
(user_print_options): New global.
(get_user_print_options, get_raw_print_options,
get_formatted_print_options): New functions.
(print_array_indexes, repeat_count_threshold, stop_print_at_null,
prettyprint_structs, prettyprint_arrays, unionprint,
addressprint): Remove.
(val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
(common_val_print): Likewise.
(print_array_indexes_p): Remove.
(maybe_print_array_index): Remove format, pretty arguments; add
options. Update.
(val_print_array_elements): Remove format, deref_ref, pretty
arguments; add options. Update.
(val_print_string): Add options argument. Update.
(_initialize_valprint): Use user_print_options.
(output_format): Remove.
(set_output_radix_1): Use user_print_options.
* typeprint.c: Include valprint.h.
(objectprint): Don't declare.
(whatis_exp): Use get_user_print_options.
* tui/tui-regs.c: Include valprint.h.
(tui_register_format): Use get_formatted_print_options.
* tracepoint.c: Include valprint.h.
(addressprint): Don't declare.
(trace_mention): Use get_user_print_options.
(tracepoints_info): Likewise.
* stack.c (print_frame_args): Use get_raw_print_options.
(print_frame_info): Use get_user_print_options.
(print_frame): Likewise.
* sh64-tdep.c: Include valprint.h
(sh64_do_register): Use get_formatted_print_options.
* scm-valprint.c (scm_inferior_print): Remove format, deref_ref,
pretty arguments; add options.
(scm_scmlist_print): Likewise. Update.
(scm_scmval_print): Likewise.
(scm_val_print): Likewise.
(scm_value_print): Remove format, pretty arguments; add options.
Update.
* scm-lang.h (scm_value_print, scm_val_print, scm_scmval_print):
Update.
* scm-lang.c (scm_printstr): Add options argument.
* python/python-value.c: Include valprint.h.
(valpy_str): Use get_user_print_options.
* printcmd.c: Include valprint.h.
(addressprint): Don't declare.
(inspect_it): Remove.
(print_formatted): Remove format option; add options. Update.
(print_scalar_formatted): Likewise.
(print_address_demangle): Use get_user_print_options.
(do_examine): Use get_formatted_print_options.
(print_command_1): Likewise.
(output_command): Use get_formatted_print_options.
(do_one_display): Likewise.
(print_variable_value): Use get_user_print_options.
* p-valprint.c (pascal_val_print): Remove format, deref_ref,
pretty arguments; add options. Update.
(pascal_value_print): Remove format, pretty arguments; add
options. Update.
(vtblprint, objectprint): Don't declare.
(pascal_static_field_print): Remove.
(pascal_object_print_value_fields): Remove format, pretty
arguments; add options. Update.
(pascal_object_print_static_field): Likewise.
(_initialize_pascal_valprint): Use user_print_options. Update.
* p-lang.h (pascal_val_print, pascal_value_print,
pascal_printstr, pascal_object_print_value_fields): Update.
(vtblprint, static_field_print): Don't declare.
* p-lang.c (pascal_printstr): Add options argument. Update.
* objc-lang.c (objc_printstr): Add options argument. Update.
* mt-tdep.c: Include valprint.h.
(mt_registers_info): Use get_raw_print_options.
* mips-tdep.c: Include valprint.h.
(mips_print_fp_register): Use get_formatted_print_options.
(mips_print_register): Likewise.
* mi/mi-main.c: Include valprint.h.
(get_register): Use get_user_print_options.
(mi_cmd_data_evaluate_expression): Likewise.
(mi_cmd_data_read_memory): Use get_formatted_print_options.
* mi/mi-cmd-stack.c: Include valprint.h.
(list_args_or_locals): Use get_raw_print_options.
* m2-valprint.c (print_function_pointer_address): Add addressprint
argument.
(m2_print_long_set): Remove format, pretty arguments.
(m2_print_unbounded_array): Remove format, deref_ref, pretty
arguments; add options. Update.
(print_unpacked_pointer): Remove format argument; add options.
Now static. Update.
(print_variable_at_address): Remove format, deref_ref, pretty
arguments; add options. Update.
(m2_print_array_contents): Likewise.
(m2_val_print): Likewise.
* m2-lang.h (m2_val_print): Update.
* m2-lang.c (m2_printstr): Add options argument. Update.
* language.h (struct value_print_options): Declare.
(struct language_defn) <la_printstr>: Add options argument.
<la_val_print>: Remove format, deref_ref, pretty argument; add
options.
<la_value_print>: Remove format, pretty arguments; add options.
<la_print_array_index>: Likewise.
(LA_VAL_PRINT, LA_VALUE_PRINT, LA_PRINT_STRING,
LA_PRINT_ARRAY_INDEX): Update.
(default_print_array_index): Update.
* language.c (default_print_array_index): Remove format, pretty
arguments; add options. Update.
(unk_lang_printstr): Add options argument.
(unk_lang_val_print): Remove format, deref_ref, pretty arguments;
add options.
(unk_lang_value_print): Remove format, pretty arguments; add
options.
* jv-valprint.c (java_value_print): Remove format, pretty
arguments; add options. Update.
(java_print_value_fields): Likewise.
(java_val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
* jv-lang.h (java_val_print, java_value_print): Declare.
* infcmd.c: Include valprint.h.
(print_return_value): Use get_raw_print_options.
(default_print_registers_info): Use get_user_print_options,
get_formatted_print_options.
(registers_info): Use get_formatted_print_options.
* gdbtypes.h (struct value_print_options): Declare.
(print_scalar_formatted): Update.
* f-valprint.c (f77_print_array_1): Remove format, deref_ref,
pretty arguments; add options. Update.
(f77_print_array): Likewise.
(f_val_print): Likewise.
* f-lang.h (f_val_print): Update.
* f-lang.c (f_printstr): Add options argument. Update.
(c_value_print): Update declaration.
* expprint.c: Include valprint.h.
(print_subexp_standard): Use get_raw_print_options,
get_user_print_options.
* eval.c: Include valprint.h.
(objectprint): Don't declare.
(evaluate_subexp_standard): Use get_user_print_options.
* cp-valprint.c (vtblprint, objectprint, static_field_print):
Remove.
(cp_print_value_fields): Remove format, pretty arguments; add
options. Update.
(cp_print_value): Likewise.
(cp_print_static_field): Likewise.
(_initialize_cp_valprint): Use user_print_options. Update.
* c-valprint.c (print_function_pointer_address): Add addressprint
argument.
(c_val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
(c_value_print): Add options argument. Update.
* c-lang.h (c_val_print, c_value_print, c_printstr): Update.
(vtblprint, static_field_print): Don't declare.
(cp_print_value_fields): Update.
* c-lang.c (c_printstr): Add options argument. Update.
* breakpoint.c: Include valprint.h.
(addressprint): Don't declare.
(watchpoint_value_print): Use get_user_print_options.
(print_one_breakpoint_location): Likewise.
(breakpoint_1, print_it_catch_fork, print_it_catch_vfork, mention,
print_exception_catchpoint): Likewise.
* auxv.c (fprint_target_auxv): Don't declare addressprint. Use
get_user_print_options.
* ada-valprint.c (struct ada_val_print_args): Remove format,
deref_ref, and pretty; add options.
(print_optional_low_bound): Add options argument.
(val_print_packed_array_elements): Remove format and pretty
arguments; add options. Update.
(printstr): Add options argument. Update.
(ada_printstr): Likewise.
(ada_val_print): Remove format, deref_ref, pretty arguments; add
options argument. Update.
(ada_val_print_stub): Update.
(ada_val_print_array): Remove format, deref_ref, pretty arguments;
add options. Update.
(ada_val_print_1): Likewise.
(print_variant_part): Likewise.
(ada_value_print): Remove format, pretty arguments; add options.
Update.
(print_record): Likewise.
(print_field_values): Likewise.
* ada-lang.h (ada_val_print, ada_value_print, ada_printstr):
Update.
* ada-lang.c (ada_print_array_index): Add options argument; remove
format and pretty arguments.
(print_one_exception): Use get_user_print_options.
gdb/testsuite
* gdb.base/exprs.exp (test_expr): Add enum formatting tests.
2008-10-28 17:19:58 +00:00
|
|
|
|
struct value_print_options;
|
* defs.h (HOST_FLOAT_FORMAT, HOST_DOUBLE_FORMAT)
(HOST_FLOAT_FORMAT, HOST_DOUBLE_FORMAT)
(HOST_LONG_DOUBLE_FORMAT, DOUBLEST)
(floatformat_to_doublest, floatformat_from_doublest)
(floatformat_is_negative, floatformat_is_nan)
(floatformat_mantissa, store_floating)
(extract_floating): Move declaration from here.
* doublest.h: To here. New file.
* utils.c (get_field, floatformat_to_doublest, put_field)
(ldfrexp, floatformat_from_doublest, floatformat_is_negative)
(floatformat_is_nan, floatformat_mantissa)
(FLOATFORMAT_CHAR_BIT): Move from here.
* doublest.c: To here. New file.
* findvar.c (store_floating, extract_floating): Move from here.
* doublest.c: To here.
* Makefile.in (SFILES): Add doublest.c.
(COMMON_OBS): Add doublest.o.
(doublest.o): Specify dependencies.
(doublest_h): Define.
* config/m88k/tm-m88k.h: Include "doublest.h".
* config/i960/tm-i960.h: Ditto.
* config/i386/tm-symmetry.h: Ditto.
* rs6000-tdep.c, valarith.c: Ditto.
* valprint.c, stabsread.c, sh-tdep.c: Ditto.
* ia64-tdep.c, i387-tdep.c, i386-tdep.c: Ditto.
* values.c, arm-tdep.c, arm-linux-tdep.c: Ditto.
* alpha-tdep.c, ax.h, expression.h: Ditto.
* sh-tdep.c, parse.c, top.c, value.h: Ditto.
* Makefile.in (arm-tdep.o): Add $(doublest_h).
(i386-tdep.o, i387-tdep.o, ia64-tdep.o): Ditto.
(rs6000-tdep.o, stabsread.o, valarith.o): Ditto.
(values.o, valprint.o, arm-linux-tdep.o): Ditto.
(alpha-tdep.o, ax_h, parse.o, top.o, value_h): Ditto.
(parser_defs_h): Ditto.
(expression_h): Add $(doublest_h) and $(symtab_h).
2001-08-01 18:39:27 +00:00
|
|
|
|
|
Handle partially optimized out values similarly to unavailable values
This fixes PR symtab/14604, PR symtab/14605, and Jan's test at
https://sourceware.org/ml/gdb-patches/2014-07/msg00158.html, in a tree
with bddbbed reverted:
2014-07-22 Pedro Alves <palves@redhat.com>
* value.c (allocate_optimized_out_value): Don't mark value as
non-lazy.
The PRs are about variables described by the DWARF as being split over
multiple registers using DWARF piece information, but some of those
registers being marked as optimised out (not saved) by a later frame.
GDB currently incorrectly mishandles these partially-optimized-out
values.
Even though we can usually tell from the debug info whether a local or
global is optimized out, handling the case of a local living in a
register that was not saved in a frame requires fetching the variable.
GDB also needs to fetch a value to tell whether parts of it are
"<unavailable>". Given this, it's not worth it to try to avoid
fetching lazy optimized-out values based on debug info alone.
So this patch makes GDB track which chunks of a value's contents are
optimized out like it tracks <unavailable> contents. That is, it
makes value->optimized_out be a bit range vector instead of a boolean,
and removes the struct lval_funcs check_validity and check_any_valid
hooks.
Unlike Andrew's series which this is based on (at
https://sourceware.org/ml/gdb-patches/2013-08/msg00300.html, note some
pieces have gone in since), this doesn't merge optimized out and
unavailable contents validity/availability behind a single interface,
nor does it merge the bit range vectors themselves (at least yet).
While it may be desirable to have a single entry point that returns
existence of contents irrespective of what may make them
invalid/unavailable, several places want to treat optimized out /
unavailable / etc. differently, so each spot that potentially could
use it will need to be careful considered on case-by-case basis, and
best done as a separate change.
This fixes Jan's test, because value_available_contents_eq wasn't
considering optimized out value contents. It does now, and because of
that it's been renamed to value_contents_eq.
A new intro comment is added to value.h describing "<optimized out>",
"<not saved>" and "<unavailable>" values.
gdb/
PR symtab/14604
PR symtab/14605
* ada-lang.c (coerce_unspec_val_to_type): Use
value_contents_copy_raw.
* ada-valprint.c (val_print_packed_array_elements): Adjust.
* c-valprint.c (c_val_print): Use value_bits_any_optimized_out.
* cp-valprint.c (cp_print_value_fields): Let the common printing
code handle optimized out values.
(cp_print_value_fields_rtti): Use value_bits_any_optimized_out.
* d-valprint.c (dynamic_array_type): Use
value_bits_any_optimized_out.
* dwarf2loc.c (entry_data_value_funcs): Remove check_validity and
check_any_valid fields.
(check_pieced_value_bits): Delete and inline ...
(check_pieced_synthetic_pointer): ... here.
(check_pieced_value_validity): Delete.
(check_pieced_value_invalid): Delete.
(pieced_value_funcs): Remove check_validity and check_any_valid
fields.
(read_pieced_value): Use mark_value_bits_optimized_out.
(write_pieced_value): Switch to use
mark_value_bytes_optimized_out.
(dwarf2_evaluate_loc_desc_full): Copy the value contents instead
of assuming the whole value is optimized out.
* findvar.c (read_frame_register_value): Remove special handling
of optimized out registers.
(value_from_register): Use mark_value_bytes_optimized_out.
* frame-unwind.c (frame_unwind_got_optimized): Use
mark_value_bytes_optimized_out.
* jv-valprint.c (java_value_print): Adjust.
(java_print_value_fields): Let the common printing code handle
optimized out values.
* mips-tdep.c (mips_print_register): Remove special handling of
optimized out registers.
* opencl-lang.c (lval_func_check_validity): Delete.
(lval_func_check_any_valid): Delete.
(opencl_value_funcs): Remove check_validity and check_any_valid
fields.
* p-valprint.c (pascal_object_print_value_fields): Let the common
printing code handle optimized out values.
* stack.c (read_frame_arg): Remove special handling of optimized
out values. Fetch both VAL and ENTRYVAL before comparing
contents. Adjust to value_available_contents_eq rename.
* valprint.c (valprint_check_validity)
(val_print_scalar_formatted): Use value_bits_any_optimized_out.
(val_print_array_elements): Adjust.
* value.c (struct value) <optimized_out>: Now a VEC(range_s).
(value_bits_any_optimized_out): New function.
(value_entirely_covered_by_range_vector): New function, factored
out from value_entirely_unavailable.
(value_entirely_unavailable): Reimplement.
(value_entirely_optimized_out): New function.
(insert_into_bit_range_vector): New function, factored out from
mark_value_bits_unavailable.
(mark_value_bits_unavailable): Reimplement.
(struct ranges_and_idx): New struct.
(find_first_range_overlap_and_match): New function, factored out
from value_available_contents_bits_eq.
(value_available_contents_bits_eq): Rename to ...
(value_contents_bits_eq): ... this. Check both unavailable
contents and optimized out contents.
(value_available_contents_eq): Rename to ...
(value_contents_eq): ... this.
(allocate_value_lazy): Remove reference to the old optimized_out
boolean.
(allocate_optimized_out_value): Use
mark_value_bytes_optimized_out.
(require_not_optimized_out): Adjust to check whether the
optimized_out vec is empty.
(ranges_copy_adjusted): New function, factored out from
value_contents_copy_raw.
(value_contents_copy_raw): Also copy the optimized out ranges.
Assert the destination ranges aren't optimized out.
(value_contents_copy): Update comment, remove call to
require_not_optimized_out.
(value_contents_equal): Adjust to check whether the optimized_out
vec is empty.
(set_value_optimized_out, value_optimized_out_const): Delete.
(mark_value_bytes_optimized_out, mark_value_bits_optimized_out):
New functions.
(value_entirely_optimized_out, value_bits_valid): Delete.
(value_copy): Take a VEC copy of the 'optimized_out' field.
(value_primitive_field): Remove special handling of optimized out.
(value_fetch_lazy): Assert that lazy values have no unavailable
regions. Use value_bits_any_optimized_out. Remove some special
handling for optimized out values.
* value.h: Add intro comment about <optimized out> and
<unavailable>.
(struct lval_funcs): Remove check_validity and check_any_valid
fields.
(set_value_optimized_out, value_optimized_out_const): Remove.
(mark_value_bytes_optimized_out, mark_value_bits_optimized_out):
New declarations.
(value_bits_any_optimized_out): New declaration.
(value_bits_valid): Delete declaration.
(value_available_contents_eq): Rename to ...
(value_contents_eq): ... this, and extend comments.
gdb/testsuite/
PR symtab/14604
PR symtab/14605
* gdb.dwarf2/dw2-op-out-param.exp: Remove kfail branches and use
gdb_test.
2014-08-20 00:07:40 +01:00
|
|
|
|
/* Values can be partially 'optimized out' and/or 'unavailable'.
|
|
|
|
|
These are distinct states and have different string representations
|
|
|
|
|
and related error strings.
|
|
|
|
|
|
|
|
|
|
'unavailable' has a specific meaning in this context. It means the
|
|
|
|
|
value exists in the program (at the machine level), but GDB has no
|
|
|
|
|
means to get to it. Such a value is normally printed as
|
|
|
|
|
<unavailable>. Examples of how to end up with an unavailable value
|
|
|
|
|
would be:
|
|
|
|
|
|
|
|
|
|
- We're inspecting a traceframe, and the memory or registers the
|
|
|
|
|
debug information says the value lives on haven't been collected.
|
|
|
|
|
|
|
|
|
|
- We're inspecting a core dump, the memory or registers the debug
|
|
|
|
|
information says the value lives aren't present in the dump
|
|
|
|
|
(that is, we have a partial/trimmed core dump, or we don't fully
|
|
|
|
|
understand/handle the core dump's format).
|
|
|
|
|
|
|
|
|
|
- We're doing live debugging, but the debug API has no means to
|
|
|
|
|
get at where the value lives in the machine, like e.g., ptrace
|
|
|
|
|
not having access to some register or register set.
|
|
|
|
|
|
|
|
|
|
- Any other similar scenario.
|
|
|
|
|
|
|
|
|
|
OTOH, "optimized out" is about what the compiler decided to generate
|
|
|
|
|
(or not generate). A chunk of a value that was optimized out does
|
|
|
|
|
not actually exist in the program. There's no way to get at it
|
|
|
|
|
short of compiling the program differently.
|
|
|
|
|
|
|
|
|
|
A register that has not been saved in a frame is likewise considered
|
|
|
|
|
optimized out, except not-saved registers have a different string
|
|
|
|
|
representation and related error strings. E.g., we'll print them as
|
|
|
|
|
<not-saved> instead of <optimized out>, as in:
|
|
|
|
|
|
|
|
|
|
(gdb) p/x $rax
|
|
|
|
|
$1 = <not saved>
|
|
|
|
|
(gdb) info registers rax
|
|
|
|
|
rax <not saved>
|
|
|
|
|
|
|
|
|
|
If the debug info describes a variable as being in such a register,
|
|
|
|
|
we'll still print the variable as <optimized out>. IOW, <not saved>
|
|
|
|
|
is reserved for inspecting registers at the machine level.
|
|
|
|
|
|
|
|
|
|
When comparing value contents, optimized out chunks, unavailable
|
|
|
|
|
chunks, and valid contents data are all considered different. See
|
|
|
|
|
value_contents_eq for more info.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-09-19 13:40:15 +09:00
|
|
|
|
extern bool overload_resolution;
|
|
|
|
|
|
2023-01-31 07:46:56 -07:00
|
|
|
|
/* Defines an [OFFSET, OFFSET + LENGTH) range. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2023-01-31 07:46:56 -07:00
|
|
|
|
struct range
|
|
|
|
|
{
|
|
|
|
|
/* Lowest offset in the range. */
|
|
|
|
|
LONGEST offset;
|
|
|
|
|
|
|
|
|
|
/* Length of the range. */
|
|
|
|
|
ULONGEST length;
|
|
|
|
|
|
|
|
|
|
/* Returns true if THIS is strictly less than OTHER, useful for
|
|
|
|
|
searching. We keep ranges sorted by offset and coalesce
|
|
|
|
|
overlapping and contiguous ranges, so this just compares the
|
|
|
|
|
starting offset. */
|
|
|
|
|
|
|
|
|
|
bool operator< (const range &other) const
|
|
|
|
|
{
|
|
|
|
|
return offset < other.offset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns true if THIS is equal to OTHER. */
|
|
|
|
|
bool operator== (const range &other) const
|
|
|
|
|
{
|
|
|
|
|
return offset == other.offset && length == other.length;
|
|
|
|
|
}
|
|
|
|
|
};
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
Introduce a gdb_ref_ptr specialization for struct value
struct value is internally reference counted and so, while it also has
some ownership rules unique to it, it makes sense to use a gdb_ref_ptr
when managing it automatically.
This patch removes the existing unique_ptr specialization in favor of
a reference-counted pointer. It also introduces two other
clarifications:
1. Rename value_free to value_decref, which I think is more in line
with what the function actually does; and
2. Change release_value to return a gdb_ref_ptr. This change allows
us to remove the confusing release_value_or_incref function,
primarily by making it much simpler to reason about the result of
release_value.
gdb/ChangeLog
2018-04-06 Tom Tromey <tom@tromey.com>
* varobj.c (varobj_clear_saved_item)
(update_dynamic_varobj_children, install_new_value, ~varobj):
Update.
* value.h (value_incref): Move declaration earlier.
(value_decref): Rename from value_free.
(struct value_ref_policy): New.
(value_ref_ptr): New typedef.
(struct value_deleter): Remove.
(gdb_value_up): Remove typedef.
(release_value): Change return type.
(release_value_or_incref): Remove.
* value.c (set_value_parent): Update.
(value_incref): Change return type.
(value_decref): Rename from value_free.
(value_free_to_mark, free_all_values, free_value_chain): Update.
(release_value): Return value_ref_ptr.
(release_value_or_incref): Remove.
(record_latest_value, set_internalvar, clear_internalvar):
Update.
* stack.c (info_frame_command): Don't call value_free.
* python/py-value.c (valpy_dealloc, valpy_new)
(value_to_value_object): Update.
* printcmd.c (do_examine): Update.
* opencl-lang.c (lval_func_free_closure): Update.
* mi/mi-main.c (register_changed_p): Don't call value_free.
* mep-tdep.c (mep_frame_prev_register): Don't call value_free.
* m88k-tdep.c (m88k_frame_prev_register): Don't call value_free.
* m68hc11-tdep.c (m68hc11_frame_prev_register): Don't call
value_free.
* guile/scm-value.c (vlscm_free_value_smob)
(vlscm_scm_from_value): Update.
* frame.c (frame_register_unwind, frame_unwind_register_signed)
(frame_unwind_register_unsigned, get_frame_register_bytes)
(put_frame_register_bytes): Don't call value_free.
* findvar.c (address_from_register): Don't call value_free.
* dwarf2read.c (dwarf2_compute_name): Don't call value_free.
* dwarf2loc.c (entry_data_value_free_closure)
(value_of_dwarf_reg_entry, free_pieced_value_closure)
(dwarf2_evaluate_loc_desc_full): Update.
* breakpoint.c (update_watchpoint, breakpoint_init_inferior)
(~bpstats, bpstats, bpstat_clear_actions, watchpoint_check)
(~watchpoint, watch_command_1)
(invalidate_bp_value_on_memory_change): Update.
* alpha-tdep.c (alpha_register_to_value): Don't call value_free.
2018-04-03 17:45:21 -06:00
|
|
|
|
/* A policy class to interface gdb::ref_ptr with struct value. */
|
|
|
|
|
|
|
|
|
|
struct value_ref_policy
|
|
|
|
|
{
|
2023-01-31 14:22:13 -07:00
|
|
|
|
static void incref (struct value *ptr);
|
|
|
|
|
static void decref (struct value *ptr);
|
Introduce a gdb_ref_ptr specialization for struct value
struct value is internally reference counted and so, while it also has
some ownership rules unique to it, it makes sense to use a gdb_ref_ptr
when managing it automatically.
This patch removes the existing unique_ptr specialization in favor of
a reference-counted pointer. It also introduces two other
clarifications:
1. Rename value_free to value_decref, which I think is more in line
with what the function actually does; and
2. Change release_value to return a gdb_ref_ptr. This change allows
us to remove the confusing release_value_or_incref function,
primarily by making it much simpler to reason about the result of
release_value.
gdb/ChangeLog
2018-04-06 Tom Tromey <tom@tromey.com>
* varobj.c (varobj_clear_saved_item)
(update_dynamic_varobj_children, install_new_value, ~varobj):
Update.
* value.h (value_incref): Move declaration earlier.
(value_decref): Rename from value_free.
(struct value_ref_policy): New.
(value_ref_ptr): New typedef.
(struct value_deleter): Remove.
(gdb_value_up): Remove typedef.
(release_value): Change return type.
(release_value_or_incref): Remove.
* value.c (set_value_parent): Update.
(value_incref): Change return type.
(value_decref): Rename from value_free.
(value_free_to_mark, free_all_values, free_value_chain): Update.
(release_value): Return value_ref_ptr.
(release_value_or_incref): Remove.
(record_latest_value, set_internalvar, clear_internalvar):
Update.
* stack.c (info_frame_command): Don't call value_free.
* python/py-value.c (valpy_dealloc, valpy_new)
(value_to_value_object): Update.
* printcmd.c (do_examine): Update.
* opencl-lang.c (lval_func_free_closure): Update.
* mi/mi-main.c (register_changed_p): Don't call value_free.
* mep-tdep.c (mep_frame_prev_register): Don't call value_free.
* m88k-tdep.c (m88k_frame_prev_register): Don't call value_free.
* m68hc11-tdep.c (m68hc11_frame_prev_register): Don't call
value_free.
* guile/scm-value.c (vlscm_free_value_smob)
(vlscm_scm_from_value): Update.
* frame.c (frame_register_unwind, frame_unwind_register_signed)
(frame_unwind_register_unsigned, get_frame_register_bytes)
(put_frame_register_bytes): Don't call value_free.
* findvar.c (address_from_register): Don't call value_free.
* dwarf2read.c (dwarf2_compute_name): Don't call value_free.
* dwarf2loc.c (entry_data_value_free_closure)
(value_of_dwarf_reg_entry, free_pieced_value_closure)
(dwarf2_evaluate_loc_desc_full): Update.
* breakpoint.c (update_watchpoint, breakpoint_init_inferior)
(~bpstats, bpstats, bpstat_clear_actions, watchpoint_check)
(~watchpoint, watch_command_1)
(invalidate_bp_value_on_memory_change): Update.
* alpha-tdep.c (alpha_register_to_value): Don't call value_free.
2018-04-03 17:45:21 -06:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* A gdb:;ref_ptr pointer to a struct value. */
|
|
|
|
|
|
|
|
|
|
typedef gdb::ref_ptr<struct value, value_ref_policy> value_ref_ptr;
|
|
|
|
|
|
2023-01-31 07:46:56 -07:00
|
|
|
|
/* Note that the fields in this structure are arranged to save a bit
|
|
|
|
|
of memory. */
|
|
|
|
|
|
|
|
|
|
struct value
|
|
|
|
|
{
|
2023-01-31 13:24:00 -07:00
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
/* Values can only be created via "static constructors". */
|
2023-01-31 07:46:56 -07:00
|
|
|
|
explicit value (struct type *type_)
|
2023-02-14 09:34:53 -07:00
|
|
|
|
: m_modifiable (true),
|
2023-02-14 09:37:47 -07:00
|
|
|
|
m_lazy (true),
|
2023-02-14 09:40:35 -07:00
|
|
|
|
m_initialized (true),
|
2023-02-14 09:43:26 -07:00
|
|
|
|
m_stack (false),
|
2023-01-31 07:46:56 -07:00
|
|
|
|
m_is_zero (false),
|
|
|
|
|
m_in_history (false),
|
|
|
|
|
m_type (type_),
|
|
|
|
|
m_enclosing_type (type_)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-01 08:34:58 -07:00
|
|
|
|
/* Values can only be destroyed via the reference-counting
|
|
|
|
|
mechanism. */
|
|
|
|
|
~value ();
|
|
|
|
|
|
|
|
|
|
DISABLE_COPY_AND_ASSIGN (value);
|
|
|
|
|
|
2023-01-31 13:24:00 -07:00
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/* Allocate a lazy value for type TYPE. Its actual content is
|
|
|
|
|
"lazily" allocated too: the content field of the return value is
|
|
|
|
|
NULL; it will be allocated when it is fetched from the target. */
|
|
|
|
|
static struct value *allocate_lazy (struct type *type);
|
|
|
|
|
|
2023-01-31 13:25:17 -07:00
|
|
|
|
/* Allocate a value and its contents for type TYPE. */
|
|
|
|
|
static struct value *allocate (struct type *type);
|
|
|
|
|
|
2023-01-31 13:29:49 -07:00
|
|
|
|
/* Create a computed lvalue, with type TYPE, function pointers
|
|
|
|
|
FUNCS, and closure CLOSURE. */
|
|
|
|
|
static struct value *allocate_computed (struct type *type,
|
|
|
|
|
const struct lval_funcs *funcs,
|
|
|
|
|
void *closure);
|
|
|
|
|
|
2023-01-31 13:30:54 -07:00
|
|
|
|
/* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT. */
|
|
|
|
|
static struct value *allocate_optimized_out (struct type *type);
|
|
|
|
|
|
2023-01-31 13:41:35 -07:00
|
|
|
|
/* Create a value of type TYPE that is zero, and return it. */
|
|
|
|
|
static struct value *zero (struct type *type, enum lval_type lv);
|
|
|
|
|
|
2023-01-31 14:43:22 -07:00
|
|
|
|
/* Return a copy of the value. It contains the same contents, for
|
|
|
|
|
the same memory address, but it's a different block of
|
|
|
|
|
storage. */
|
|
|
|
|
struct value *copy () const;
|
|
|
|
|
|
2023-01-31 07:52:09 -07:00
|
|
|
|
/* Type of the value. */
|
|
|
|
|
struct type *type () const
|
|
|
|
|
{ return m_type; }
|
|
|
|
|
|
2023-01-31 08:24:35 -07:00
|
|
|
|
/* This is being used to change the type of an existing value, that
|
|
|
|
|
code should instead be creating a new value with the changed type
|
|
|
|
|
(but possibly shared content). */
|
|
|
|
|
void deprecated_set_type (struct type *type)
|
|
|
|
|
{ m_type = type; }
|
|
|
|
|
|
2023-01-31 08:31:48 -07:00
|
|
|
|
/* Return the gdbarch associated with the value. */
|
|
|
|
|
struct gdbarch *arch () const;
|
|
|
|
|
|
2023-01-31 09:38:22 -07:00
|
|
|
|
/* Only used for bitfields; number of bits contained in them. */
|
|
|
|
|
LONGEST bitsize () const
|
|
|
|
|
{ return m_bitsize; }
|
|
|
|
|
|
|
|
|
|
void set_bitsize (LONGEST bit)
|
|
|
|
|
{ m_bitsize = bit; }
|
|
|
|
|
|
2023-01-31 09:44:47 -07:00
|
|
|
|
/* Only used for bitfields; position of start of field. For
|
|
|
|
|
little-endian targets, it is the position of the LSB. For
|
|
|
|
|
big-endian targets, it is the position of the MSB. */
|
|
|
|
|
LONGEST bitpos () const
|
|
|
|
|
{ return m_bitpos; }
|
|
|
|
|
|
|
|
|
|
void set_bitpos (LONGEST bit)
|
|
|
|
|
{ m_bitpos = bit; }
|
|
|
|
|
|
2023-01-31 09:56:33 -07:00
|
|
|
|
/* Only used for bitfields; the containing value. This allows a
|
|
|
|
|
single read from the target when displaying multiple
|
|
|
|
|
bitfields. */
|
|
|
|
|
value *parent () const
|
|
|
|
|
{ return m_parent.get (); }
|
|
|
|
|
|
|
|
|
|
void set_parent (struct value *parent)
|
|
|
|
|
{ m_parent = value_ref_ptr::new_reference (parent); }
|
|
|
|
|
|
2023-01-31 10:05:01 -07:00
|
|
|
|
/* Describes offset of a value within lval of a structure in bytes.
|
|
|
|
|
If lval == lval_memory, this is an offset to the address. If
|
|
|
|
|
lval == lval_register, this is a further offset from
|
|
|
|
|
location.address within the registers structure. Note also the
|
|
|
|
|
member embedded_offset below. */
|
|
|
|
|
LONGEST offset () const
|
|
|
|
|
{ return m_offset; }
|
|
|
|
|
|
|
|
|
|
void set_offset (LONGEST offset)
|
|
|
|
|
{ m_offset = offset; }
|
|
|
|
|
|
2023-01-31 10:17:10 -07:00
|
|
|
|
/* The comment from "struct value" reads: ``Is it modifiable? Only
|
|
|
|
|
relevant if lval != not_lval.''. Shouldn't the value instead be
|
|
|
|
|
not_lval and be done with it? */
|
2023-02-14 09:34:53 -07:00
|
|
|
|
bool deprecated_modifiable () const
|
2023-01-31 10:17:10 -07:00
|
|
|
|
{ return m_modifiable; }
|
|
|
|
|
|
2023-02-01 08:25:21 -07:00
|
|
|
|
/* Set or clear the modifiable flag. */
|
2023-02-14 09:34:53 -07:00
|
|
|
|
void set_modifiable (bool val)
|
2023-02-01 08:25:21 -07:00
|
|
|
|
{ m_modifiable = val; }
|
|
|
|
|
|
2023-01-31 10:40:38 -07:00
|
|
|
|
LONGEST pointed_to_offset () const
|
|
|
|
|
{ return m_pointed_to_offset; }
|
|
|
|
|
|
|
|
|
|
void set_pointed_to_offset (LONGEST val)
|
|
|
|
|
{ m_pointed_to_offset = val; }
|
|
|
|
|
|
|
|
|
|
LONGEST embedded_offset () const
|
|
|
|
|
{ return m_embedded_offset; }
|
|
|
|
|
|
|
|
|
|
void set_embedded_offset (LONGEST val)
|
|
|
|
|
{ m_embedded_offset = val; }
|
|
|
|
|
|
2023-02-14 09:37:47 -07:00
|
|
|
|
/* If false, contents of this value are in the contents field. If
|
|
|
|
|
true, contents are in inferior. If the lval field is lval_memory,
|
2023-01-31 10:52:04 -07:00
|
|
|
|
the contents are in inferior memory at location.address plus offset.
|
|
|
|
|
The lval field may also be lval_register.
|
|
|
|
|
|
|
|
|
|
WARNING: This field is used by the code which handles watchpoints
|
|
|
|
|
(see breakpoint.c) to decide whether a particular value can be
|
|
|
|
|
watched by hardware watchpoints. If the lazy flag is set for some
|
|
|
|
|
member of a value chain, it is assumed that this member of the
|
|
|
|
|
chain doesn't need to be watched as part of watching the value
|
|
|
|
|
itself. This is how GDB avoids watching the entire struct or array
|
|
|
|
|
when the user wants to watch a single struct member or array
|
|
|
|
|
element. If you ever change the way lazy flag is set and reset, be
|
|
|
|
|
sure to consider this use as well! */
|
|
|
|
|
|
2023-02-14 09:37:47 -07:00
|
|
|
|
bool lazy () const
|
2023-01-31 10:52:04 -07:00
|
|
|
|
{ return m_lazy; }
|
|
|
|
|
|
2023-02-14 09:37:47 -07:00
|
|
|
|
void set_lazy (bool val)
|
2023-01-31 10:52:04 -07:00
|
|
|
|
{ m_lazy = val; }
|
|
|
|
|
|
2023-01-31 10:19:10 -07:00
|
|
|
|
/* If a value represents a C++ object, then the `type' field gives the
|
|
|
|
|
object's compile-time type. If the object actually belongs to some
|
|
|
|
|
class derived from `type', perhaps with other base classes and
|
|
|
|
|
additional members, then `type' is just a subobject of the real
|
|
|
|
|
thing, and the full object is probably larger than `type' would
|
|
|
|
|
suggest.
|
|
|
|
|
|
|
|
|
|
If `type' is a dynamic class (i.e. one with a vtable), then GDB can
|
|
|
|
|
actually determine the object's run-time type by looking at the
|
|
|
|
|
run-time type information in the vtable. When this information is
|
|
|
|
|
available, we may elect to read in the entire object, for several
|
|
|
|
|
reasons:
|
|
|
|
|
|
|
|
|
|
- When printing the value, the user would probably rather see the
|
|
|
|
|
full object, not just the limited portion apparent from the
|
|
|
|
|
compile-time type.
|
|
|
|
|
|
|
|
|
|
- If `type' has virtual base classes, then even printing `type'
|
|
|
|
|
alone may require reaching outside the `type' portion of the
|
|
|
|
|
object to wherever the virtual base class has been stored.
|
|
|
|
|
|
|
|
|
|
When we store the entire object, `enclosing_type' is the run-time
|
|
|
|
|
type -- the complete object -- and `embedded_offset' is the offset
|
2023-01-31 14:38:30 -07:00
|
|
|
|
of `type' within that larger type, in bytes. The contents()
|
|
|
|
|
method takes `embedded_offset' into account, so most GDB code
|
2023-01-31 10:19:10 -07:00
|
|
|
|
continues to see the `type' portion of the value, just as the
|
|
|
|
|
inferior would.
|
|
|
|
|
|
|
|
|
|
If `type' is a pointer to an object, then `enclosing_type' is a
|
|
|
|
|
pointer to the object's run-time type, and `pointed_to_offset' is
|
|
|
|
|
the offset in bytes from the full object to the pointed-to object
|
|
|
|
|
-- that is, the value `embedded_offset' would have if we followed
|
|
|
|
|
the pointer and fetched the complete object. (I don't really see
|
|
|
|
|
the point. Why not just determine the run-time type when you
|
|
|
|
|
indirect, and avoid the special case? The contents don't matter
|
|
|
|
|
until you indirect anyway.)
|
|
|
|
|
|
|
|
|
|
If we're not doing anything fancy, `enclosing_type' is equal to
|
|
|
|
|
`type', and `embedded_offset' is zero, so everything works
|
|
|
|
|
normally. */
|
|
|
|
|
|
|
|
|
|
struct type *enclosing_type () const
|
|
|
|
|
{ return m_enclosing_type; }
|
|
|
|
|
|
|
|
|
|
void set_enclosing_type (struct type *new_type);
|
|
|
|
|
|
2023-02-14 09:43:26 -07:00
|
|
|
|
bool stack () const
|
2023-01-31 11:11:17 -07:00
|
|
|
|
{ return m_stack; }
|
|
|
|
|
|
2023-02-14 09:43:26 -07:00
|
|
|
|
void set_stack (bool val)
|
2023-01-31 11:11:17 -07:00
|
|
|
|
{ m_stack = val; }
|
|
|
|
|
|
2023-01-31 12:12:39 -07:00
|
|
|
|
/* If this value is lval_computed, return its lval_funcs
|
|
|
|
|
structure. */
|
|
|
|
|
const struct lval_funcs *computed_funcs () const;
|
|
|
|
|
|
|
|
|
|
/* If this value is lval_computed, return its closure. The meaning
|
|
|
|
|
of the returned value depends on the functions this value
|
|
|
|
|
uses. */
|
|
|
|
|
void *computed_closure () const;
|
|
|
|
|
|
2023-01-31 12:16:29 -07:00
|
|
|
|
enum lval_type lval () const
|
|
|
|
|
{ return m_lval; }
|
|
|
|
|
|
2023-02-09 06:35:33 -07:00
|
|
|
|
/* Set the 'lval' of this value. */
|
|
|
|
|
void set_lval (lval_type val)
|
|
|
|
|
{ m_lval = val; }
|
|
|
|
|
|
2023-01-31 12:22:01 -07:00
|
|
|
|
/* Set or return field indicating whether a variable is initialized or
|
|
|
|
|
not, based on debugging information supplied by the compiler.
|
2023-02-14 09:40:35 -07:00
|
|
|
|
true = initialized; false = uninitialized. */
|
|
|
|
|
bool initialized () const
|
2023-01-31 12:22:01 -07:00
|
|
|
|
{ return m_initialized; }
|
|
|
|
|
|
2023-02-14 09:40:35 -07:00
|
|
|
|
void set_initialized (bool value)
|
2023-01-31 12:22:01 -07:00
|
|
|
|
{ m_initialized = value; }
|
|
|
|
|
|
2023-01-31 12:27:30 -07:00
|
|
|
|
/* If lval == lval_memory, return the address in the inferior. If
|
|
|
|
|
lval == lval_register, return the byte offset into the registers
|
|
|
|
|
structure. Otherwise, return 0. The returned address
|
|
|
|
|
includes the offset, if any. */
|
|
|
|
|
CORE_ADDR address () const;
|
|
|
|
|
|
|
|
|
|
/* Like address, except the result does not include value's
|
|
|
|
|
offset. */
|
|
|
|
|
CORE_ADDR raw_address () const;
|
|
|
|
|
|
|
|
|
|
/* Set the address of a value. */
|
|
|
|
|
void set_address (CORE_ADDR);
|
|
|
|
|
|
2023-01-31 12:46:20 -07:00
|
|
|
|
struct internalvar **deprecated_internalvar_hack ()
|
|
|
|
|
{ return &m_location.internalvar; }
|
|
|
|
|
|
|
|
|
|
struct frame_id *deprecated_next_frame_id_hack ();
|
|
|
|
|
|
|
|
|
|
int *deprecated_regnum_hack ();
|
|
|
|
|
|
2023-01-31 13:45:40 -07:00
|
|
|
|
/* contents() and contents_raw() both return the address of the gdb
|
|
|
|
|
buffer used to hold a copy of the contents of the lval.
|
|
|
|
|
contents() is used when the contents of the buffer are needed --
|
|
|
|
|
it uses fetch_lazy() to load the buffer from the process being
|
|
|
|
|
debugged if it hasn't already been loaded (contents_writeable()
|
|
|
|
|
is used when a writeable but fetched buffer is required)..
|
|
|
|
|
contents_raw() is used when data is being stored into the buffer,
|
|
|
|
|
or when it is certain that the contents of the buffer are valid.
|
|
|
|
|
|
|
|
|
|
Note: The contents pointer is adjusted by the offset required to
|
|
|
|
|
get to the real subobject, if the value happens to represent
|
|
|
|
|
something embedded in a larger run-time object. */
|
|
|
|
|
gdb::array_view<gdb_byte> contents_raw ();
|
2023-01-31 14:38:30 -07:00
|
|
|
|
|
|
|
|
|
/* Actual contents of the value. For use of this value; setting it
|
|
|
|
|
uses the stuff above. Not valid if lazy is nonzero. Target
|
|
|
|
|
byte-order. We force it to be aligned properly for any possible
|
|
|
|
|
value. Note that a value therefore extends beyond what is
|
|
|
|
|
declared here. */
|
|
|
|
|
gdb::array_view<const gdb_byte> contents ();
|
|
|
|
|
|
|
|
|
|
/* The ALL variants of the above two methods do not adjust the
|
|
|
|
|
returned pointer by the embedded_offset value. */
|
|
|
|
|
gdb::array_view<const gdb_byte> contents_all ();
|
2023-01-31 13:45:40 -07:00
|
|
|
|
gdb::array_view<gdb_byte> contents_all_raw ();
|
2023-01-31 14:38:30 -07:00
|
|
|
|
|
2023-01-31 13:45:40 -07:00
|
|
|
|
gdb::array_view<gdb_byte> contents_writeable ();
|
|
|
|
|
|
2023-01-31 14:38:30 -07:00
|
|
|
|
/* Like contents_all, but does not require that the returned bits be
|
|
|
|
|
valid. This should only be used in situations where you plan to
|
|
|
|
|
check the validity manually. */
|
|
|
|
|
gdb::array_view<const gdb_byte> contents_for_printing ();
|
|
|
|
|
|
|
|
|
|
/* Like contents_for_printing, but accepts a constant value pointer.
|
|
|
|
|
Unlike contents_for_printing however, the pointed value must
|
|
|
|
|
_not_ be lazy. */
|
|
|
|
|
gdb::array_view<const gdb_byte> contents_for_printing () const;
|
|
|
|
|
|
2023-01-31 13:53:55 -07:00
|
|
|
|
/* Load the actual content of a lazy value. Fetch the data from the
|
|
|
|
|
user's process and clear the lazy flag to indicate that the data in
|
|
|
|
|
the buffer is valid.
|
|
|
|
|
|
|
|
|
|
If the value is zero-length, we avoid calling read_memory, which
|
|
|
|
|
would abort. We mark the value as fetched anyway -- all 0 bytes of
|
|
|
|
|
it. */
|
|
|
|
|
void fetch_lazy ();
|
|
|
|
|
|
2023-01-31 14:11:48 -07:00
|
|
|
|
/* Compare LENGTH bytes of this value's contents starting at OFFSET1
|
|
|
|
|
with LENGTH bytes of VAL2's contents starting at OFFSET2.
|
|
|
|
|
|
|
|
|
|
Note that "contents" refers to the whole value's contents
|
|
|
|
|
(value_contents_all), without any embedded offset adjustment. For
|
|
|
|
|
example, to compare a complete object value with itself, including
|
|
|
|
|
its enclosing type chunk, you'd do:
|
|
|
|
|
|
|
|
|
|
int len = check_typedef (val->enclosing_type ())->length ();
|
|
|
|
|
val->contents_eq (0, val, 0, len);
|
|
|
|
|
|
|
|
|
|
Returns true iff the set of available/valid contents match.
|
|
|
|
|
|
|
|
|
|
Optimized-out contents are equal to optimized-out contents, and are
|
|
|
|
|
not equal to non-optimized-out contents.
|
|
|
|
|
|
|
|
|
|
Unavailable contents are equal to unavailable contents, and are not
|
|
|
|
|
equal to non-unavailable contents.
|
|
|
|
|
|
|
|
|
|
For example, if 'x's represent an unavailable byte, and 'V' and 'Z'
|
|
|
|
|
represent different available/valid bytes, in a value with length
|
|
|
|
|
16:
|
|
|
|
|
|
|
|
|
|
offset: 0 4 8 12 16
|
|
|
|
|
contents: xxxxVVVVxxxxVVZZ
|
|
|
|
|
|
|
|
|
|
then:
|
|
|
|
|
|
|
|
|
|
val->contents_eq(0, val, 8, 6) => true
|
|
|
|
|
val->contents_eq(0, val, 4, 4) => false
|
|
|
|
|
val->contents_eq(0, val, 8, 8) => false
|
|
|
|
|
val->contents_eq(4, val, 12, 2) => true
|
|
|
|
|
val->contents_eq(4, val, 12, 4) => true
|
|
|
|
|
val->contents_eq(3, val, 4, 4) => true
|
|
|
|
|
|
|
|
|
|
If 'x's represent an unavailable byte, 'o' represents an optimized
|
|
|
|
|
out byte, in a value with length 8:
|
|
|
|
|
|
|
|
|
|
offset: 0 4 8
|
|
|
|
|
contents: xxxxoooo
|
|
|
|
|
|
|
|
|
|
then:
|
|
|
|
|
|
|
|
|
|
val->contents_eq(0, val, 2, 2) => true
|
|
|
|
|
val->contents_eq(4, val, 6, 2) => true
|
|
|
|
|
val->contents_eq(0, val, 4, 4) => true
|
|
|
|
|
|
|
|
|
|
We only know whether a value chunk is unavailable or optimized out
|
|
|
|
|
if we've tried to read it. As this routine is used by printing
|
|
|
|
|
routines, which may be printing values in the value history, long
|
|
|
|
|
after the inferior is gone, it works with const values. Therefore,
|
|
|
|
|
this routine must not be called with lazy values. */
|
|
|
|
|
|
|
|
|
|
bool contents_eq (LONGEST offset1, const struct value *val2, LONGEST offset2,
|
|
|
|
|
LONGEST length) const;
|
|
|
|
|
|
|
|
|
|
/* An overload of contents_eq that compares the entirety of both
|
|
|
|
|
values. */
|
|
|
|
|
bool contents_eq (const struct value *val2) const;
|
|
|
|
|
|
2023-01-31 14:17:50 -07:00
|
|
|
|
/* Given a value, determine whether the bits starting at OFFSET and
|
|
|
|
|
extending for LENGTH bits are a synthetic pointer. */
|
|
|
|
|
|
2023-02-14 10:16:26 -07:00
|
|
|
|
bool bits_synthetic_pointer (LONGEST offset, LONGEST length) const;
|
2023-01-31 14:17:50 -07:00
|
|
|
|
|
2023-01-31 14:25:29 -07:00
|
|
|
|
/* Increase this value's reference count. */
|
|
|
|
|
void incref ()
|
|
|
|
|
{ ++m_reference_count; }
|
|
|
|
|
|
|
|
|
|
/* Decrease this value's reference count. When the reference count
|
|
|
|
|
drops to 0, it will be freed. */
|
|
|
|
|
void decref ();
|
|
|
|
|
|
2023-01-31 16:13:08 -07:00
|
|
|
|
/* Given a value, determine whether the contents bytes starting at
|
|
|
|
|
OFFSET and extending for LENGTH bytes are available. This returns
|
2023-02-14 10:21:58 -07:00
|
|
|
|
true if all bytes in the given range are available, false if any
|
2023-01-31 16:13:08 -07:00
|
|
|
|
byte is unavailable. */
|
2023-02-14 10:21:58 -07:00
|
|
|
|
bool bytes_available (LONGEST offset, ULONGEST length) const;
|
2023-01-31 16:13:08 -07:00
|
|
|
|
|
|
|
|
|
/* Given a value, determine whether the contents bits starting at
|
|
|
|
|
OFFSET and extending for LENGTH bits are available. This returns
|
2023-02-14 10:21:58 -07:00
|
|
|
|
true if all bits in the given range are available, false if any
|
2023-01-31 16:13:08 -07:00
|
|
|
|
bit is unavailable. */
|
2023-02-14 10:21:58 -07:00
|
|
|
|
bool bits_available (LONGEST offset, ULONGEST length) const;
|
2023-01-31 16:13:08 -07:00
|
|
|
|
|
|
|
|
|
/* Like bytes_available, but return false if any byte in the
|
|
|
|
|
whole object is unavailable. */
|
2023-02-14 10:21:58 -07:00
|
|
|
|
bool entirely_available ();
|
2023-01-31 16:13:08 -07:00
|
|
|
|
|
|
|
|
|
/* Like entirely_available, but return false if any byte in the
|
|
|
|
|
whole object is available. */
|
2023-02-14 10:21:58 -07:00
|
|
|
|
bool entirely_unavailable ()
|
2023-01-31 16:13:08 -07:00
|
|
|
|
{ return entirely_covered_by_range_vector (m_unavailable); }
|
|
|
|
|
|
|
|
|
|
/* Mark this value's content bytes starting at OFFSET and extending
|
|
|
|
|
for LENGTH bytes as unavailable. */
|
|
|
|
|
void mark_bytes_unavailable (LONGEST offset, ULONGEST length);
|
|
|
|
|
|
|
|
|
|
/* Mark this value's content bits starting at OFFSET and extending
|
|
|
|
|
for LENGTH bits as unavailable. */
|
|
|
|
|
void mark_bits_unavailable (LONGEST offset, ULONGEST length);
|
|
|
|
|
|
2023-02-14 10:21:58 -07:00
|
|
|
|
/* If true, this is the value of a variable which does not actually
|
2023-01-31 16:13:08 -07:00
|
|
|
|
exist in the program, at least partially. If the value is lazy,
|
|
|
|
|
this may fetch it now. */
|
2023-02-14 10:21:58 -07:00
|
|
|
|
bool optimized_out ();
|
2023-01-31 16:13:08 -07:00
|
|
|
|
|
|
|
|
|
/* Given a value, return true if any of the contents bits starting at
|
|
|
|
|
OFFSET and extending for LENGTH bits is optimized out, false
|
|
|
|
|
otherwise. */
|
2023-02-14 10:21:58 -07:00
|
|
|
|
bool bits_any_optimized_out (int bit_offset, int bit_length) const;
|
2023-01-31 16:13:08 -07:00
|
|
|
|
|
|
|
|
|
/* Like optimized_out, but return true iff the whole value is
|
|
|
|
|
optimized out. */
|
2023-02-14 10:21:58 -07:00
|
|
|
|
bool entirely_optimized_out ()
|
2023-01-31 16:13:08 -07:00
|
|
|
|
{
|
|
|
|
|
return entirely_covered_by_range_vector (m_optimized_out);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Mark this value's content bytes starting at OFFSET and extending
|
|
|
|
|
for LENGTH bytes as optimized out. */
|
|
|
|
|
void mark_bytes_optimized_out (int offset, int length);
|
|
|
|
|
|
|
|
|
|
/* Mark this value's content bits starting at OFFSET and extending
|
|
|
|
|
for LENGTH bits as optimized out. */
|
|
|
|
|
void mark_bits_optimized_out (LONGEST offset, LONGEST length);
|
|
|
|
|
|
2023-01-31 16:23:22 -07:00
|
|
|
|
/* Return a version of this that is non-lvalue. */
|
|
|
|
|
struct value *non_lval ();
|
|
|
|
|
|
|
|
|
|
/* Write contents of this value at ADDR and set its lval type to be
|
|
|
|
|
LVAL_MEMORY. */
|
|
|
|
|
void force_lval (CORE_ADDR);
|
|
|
|
|
|
2023-01-31 16:26:38 -07:00
|
|
|
|
/* Set this values's location as appropriate for a component of
|
|
|
|
|
WHOLE --- regardless of what kind of lvalue WHOLE is. */
|
|
|
|
|
void set_component_location (const struct value *whole);
|
|
|
|
|
|
2023-01-31 20:59:39 -07:00
|
|
|
|
/* Build a value wrapping and representing WORKER. The value takes
|
|
|
|
|
ownership of the xmethod_worker object. */
|
|
|
|
|
static struct value *from_xmethod (xmethod_worker_up &&worker);
|
|
|
|
|
|
|
|
|
|
/* Return the type of the result of TYPE_CODE_XMETHOD value METHOD. */
|
|
|
|
|
struct type *result_type_of_xmethod (gdb::array_view<value *> argv);
|
|
|
|
|
|
|
|
|
|
/* Call the xmethod corresponding to the TYPE_CODE_XMETHOD value
|
|
|
|
|
METHOD. */
|
|
|
|
|
struct value *call_xmethod (gdb::array_view<value *> argv);
|
|
|
|
|
|
2023-01-31 21:11:38 -07:00
|
|
|
|
/* Update this value before discarding OBJFILE. COPIED_TYPES is
|
|
|
|
|
used to prevent cycles / duplicates. */
|
|
|
|
|
void preserve (struct objfile *objfile, htab_t copied_types);
|
|
|
|
|
|
2023-02-01 07:27:50 -07:00
|
|
|
|
/* Unpack a bitfield of BITSIZE bits found at BITPOS in the object
|
|
|
|
|
at VALADDR + EMBEDDEDOFFSET that has the type of DEST_VAL and
|
|
|
|
|
store the contents in DEST_VAL, zero or sign extending if the
|
|
|
|
|
type of DEST_VAL is wider than BITSIZE. VALADDR points to the
|
|
|
|
|
contents of this value. If this value's contents required to
|
|
|
|
|
extract the bitfield from are unavailable/optimized out, DEST_VAL
|
|
|
|
|
is correspondingly marked unavailable/optimized out. */
|
|
|
|
|
void unpack_bitfield (struct value *dest_val,
|
|
|
|
|
LONGEST bitpos, LONGEST bitsize,
|
|
|
|
|
const gdb_byte *valaddr, LONGEST embedded_offset)
|
|
|
|
|
const;
|
|
|
|
|
|
|
|
|
|
/* Copy LENGTH bytes of this value's (all) contents
|
|
|
|
|
(value_contents_all) starting at SRC_OFFSET byte, into DST
|
|
|
|
|
value's (all) contents, starting at DST_OFFSET. If unavailable
|
|
|
|
|
contents are being copied from this value, the corresponding DST
|
|
|
|
|
contents are marked unavailable accordingly. DST must not be
|
|
|
|
|
lazy. If this value is lazy, it will be fetched now.
|
|
|
|
|
|
|
|
|
|
It is assumed the contents of DST in the [DST_OFFSET,
|
|
|
|
|
DST_OFFSET+LENGTH) range are wholly available. */
|
|
|
|
|
void contents_copy (struct value *dst, LONGEST dst_offset,
|
|
|
|
|
LONGEST src_offset, LONGEST length);
|
|
|
|
|
|
|
|
|
|
/* Given a value (offset by OFFSET bytes)
|
|
|
|
|
of a struct or union type ARG_TYPE,
|
|
|
|
|
extract and return the value of one of its (non-static) fields.
|
|
|
|
|
FIELDNO says which field. */
|
|
|
|
|
struct value *primitive_field (LONGEST offset, int fieldno,
|
|
|
|
|
struct type *arg_type);
|
|
|
|
|
|
|
|
|
|
/* Create a new value by extracting it from this value. TYPE is the
|
|
|
|
|
type of the new value. BIT_OFFSET and BIT_LENGTH describe the
|
|
|
|
|
offset and field width of the value to extract from this value --
|
|
|
|
|
BIT_LENGTH may differ from TYPE's length in the case where this
|
|
|
|
|
value's type is packed.
|
|
|
|
|
|
|
|
|
|
When the value does come from a non-byte-aligned offset or field
|
|
|
|
|
width, it will be marked non_lval. */
|
|
|
|
|
struct value *from_component_bitsize (struct type *type,
|
|
|
|
|
LONGEST bit_offset,
|
|
|
|
|
LONGEST bit_length);
|
|
|
|
|
|
2023-02-12 08:04:07 -07:00
|
|
|
|
/* Record this value on the value history, and return its location
|
|
|
|
|
in the history. The value is removed from the value chain. */
|
|
|
|
|
int record_latest ();
|
2023-01-31 07:52:09 -07:00
|
|
|
|
|
2023-02-01 08:25:40 -07:00
|
|
|
|
private:
|
|
|
|
|
|
2023-01-31 07:46:56 -07:00
|
|
|
|
/* Type of value; either not an lval, or one of the various
|
|
|
|
|
different possible kinds of lval. */
|
|
|
|
|
enum lval_type m_lval = not_lval;
|
|
|
|
|
|
|
|
|
|
/* Is it modifiable? Only relevant if lval != not_lval. */
|
2023-02-14 09:34:53 -07:00
|
|
|
|
bool m_modifiable : 1;
|
2023-01-31 07:46:56 -07:00
|
|
|
|
|
2023-02-14 09:37:47 -07:00
|
|
|
|
/* If false, contents of this value are in the contents field. If
|
|
|
|
|
true, contents are in inferior. If the lval field is lval_memory,
|
2023-01-31 07:46:56 -07:00
|
|
|
|
the contents are in inferior memory at location.address plus offset.
|
|
|
|
|
The lval field may also be lval_register.
|
|
|
|
|
|
|
|
|
|
WARNING: This field is used by the code which handles watchpoints
|
|
|
|
|
(see breakpoint.c) to decide whether a particular value can be
|
|
|
|
|
watched by hardware watchpoints. If the lazy flag is set for
|
|
|
|
|
some member of a value chain, it is assumed that this member of
|
|
|
|
|
the chain doesn't need to be watched as part of watching the
|
|
|
|
|
value itself. This is how GDB avoids watching the entire struct
|
|
|
|
|
or array when the user wants to watch a single struct member or
|
|
|
|
|
array element. If you ever change the way lazy flag is set and
|
|
|
|
|
reset, be sure to consider this use as well! */
|
2023-02-14 09:37:47 -07:00
|
|
|
|
bool m_lazy : 1;
|
2023-01-31 07:46:56 -07:00
|
|
|
|
|
|
|
|
|
/* If value is a variable, is it initialized or not. */
|
2023-02-14 09:40:35 -07:00
|
|
|
|
bool m_initialized : 1;
|
2023-01-31 07:46:56 -07:00
|
|
|
|
|
|
|
|
|
/* If value is from the stack. If this is set, read_stack will be
|
|
|
|
|
used instead of read_memory to enable extra caching. */
|
2023-02-14 09:43:26 -07:00
|
|
|
|
bool m_stack : 1;
|
2023-01-31 07:46:56 -07:00
|
|
|
|
|
2023-01-31 13:41:35 -07:00
|
|
|
|
/* True if this is a zero value, created by 'value::zero'; false
|
2023-01-31 07:46:56 -07:00
|
|
|
|
otherwise. */
|
|
|
|
|
bool m_is_zero : 1;
|
|
|
|
|
|
|
|
|
|
/* True if this a value recorded in value history; false otherwise. */
|
|
|
|
|
bool m_in_history : 1;
|
|
|
|
|
|
|
|
|
|
/* Location of value (if lval). */
|
|
|
|
|
union
|
|
|
|
|
{
|
|
|
|
|
/* If lval == lval_memory, this is the address in the inferior */
|
|
|
|
|
CORE_ADDR address;
|
|
|
|
|
|
|
|
|
|
/*If lval == lval_register, the value is from a register. */
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
/* Register number. */
|
|
|
|
|
int regnum;
|
|
|
|
|
/* Frame ID of "next" frame to which a register value is relative.
|
|
|
|
|
If the register value is found relative to frame F, then the
|
|
|
|
|
frame id of F->next will be stored in next_frame_id. */
|
|
|
|
|
struct frame_id next_frame_id;
|
|
|
|
|
} reg;
|
|
|
|
|
|
|
|
|
|
/* Pointer to internal variable. */
|
|
|
|
|
struct internalvar *internalvar;
|
|
|
|
|
|
|
|
|
|
/* Pointer to xmethod worker. */
|
|
|
|
|
struct xmethod_worker *xm_worker;
|
|
|
|
|
|
|
|
|
|
/* If lval == lval_computed, this is a set of function pointers
|
|
|
|
|
to use to access and describe the value, and a closure pointer
|
|
|
|
|
for them to use. */
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
/* Functions to call. */
|
|
|
|
|
const struct lval_funcs *funcs;
|
|
|
|
|
|
|
|
|
|
/* Closure for those functions to use. */
|
|
|
|
|
void *closure;
|
|
|
|
|
} computed;
|
|
|
|
|
} m_location {};
|
|
|
|
|
|
|
|
|
|
/* Describes offset of a value within lval of a structure in target
|
|
|
|
|
addressable memory units. Note also the member embedded_offset
|
|
|
|
|
below. */
|
|
|
|
|
LONGEST m_offset = 0;
|
|
|
|
|
|
|
|
|
|
/* Only used for bitfields; number of bits contained in them. */
|
|
|
|
|
LONGEST m_bitsize = 0;
|
|
|
|
|
|
|
|
|
|
/* Only used for bitfields; position of start of field. For
|
|
|
|
|
little-endian targets, it is the position of the LSB. For
|
|
|
|
|
big-endian targets, it is the position of the MSB. */
|
|
|
|
|
LONGEST m_bitpos = 0;
|
|
|
|
|
|
|
|
|
|
/* The number of references to this value. When a value is created,
|
|
|
|
|
the value chain holds a reference, so REFERENCE_COUNT is 1. If
|
|
|
|
|
release_value is called, this value is removed from the chain but
|
|
|
|
|
the caller of release_value now has a reference to this value.
|
|
|
|
|
The caller must arrange for a call to value_free later. */
|
|
|
|
|
int m_reference_count = 1;
|
|
|
|
|
|
|
|
|
|
/* Only used for bitfields; the containing value. This allows a
|
|
|
|
|
single read from the target when displaying multiple
|
|
|
|
|
bitfields. */
|
|
|
|
|
value_ref_ptr m_parent;
|
|
|
|
|
|
|
|
|
|
/* Type of the value. */
|
|
|
|
|
struct type *m_type;
|
|
|
|
|
|
|
|
|
|
/* If a value represents a C++ object, then the `type' field gives
|
|
|
|
|
the object's compile-time type. If the object actually belongs
|
|
|
|
|
to some class derived from `type', perhaps with other base
|
|
|
|
|
classes and additional members, then `type' is just a subobject
|
|
|
|
|
of the real thing, and the full object is probably larger than
|
|
|
|
|
`type' would suggest.
|
|
|
|
|
|
|
|
|
|
If `type' is a dynamic class (i.e. one with a vtable), then GDB
|
|
|
|
|
can actually determine the object's run-time type by looking at
|
|
|
|
|
the run-time type information in the vtable. When this
|
|
|
|
|
information is available, we may elect to read in the entire
|
|
|
|
|
object, for several reasons:
|
|
|
|
|
|
|
|
|
|
- When printing the value, the user would probably rather see the
|
|
|
|
|
full object, not just the limited portion apparent from the
|
|
|
|
|
compile-time type.
|
|
|
|
|
|
|
|
|
|
- If `type' has virtual base classes, then even printing `type'
|
|
|
|
|
alone may require reaching outside the `type' portion of the
|
|
|
|
|
object to wherever the virtual base class has been stored.
|
|
|
|
|
|
|
|
|
|
When we store the entire object, `enclosing_type' is the run-time
|
|
|
|
|
type -- the complete object -- and `embedded_offset' is the
|
|
|
|
|
offset of `type' within that larger type, in target addressable memory
|
2023-01-31 14:38:30 -07:00
|
|
|
|
units. The contents() method takes `embedded_offset' into account,
|
2023-01-31 07:46:56 -07:00
|
|
|
|
so most GDB code continues to see the `type' portion of the value, just
|
|
|
|
|
as the inferior would.
|
|
|
|
|
|
|
|
|
|
If `type' is a pointer to an object, then `enclosing_type' is a
|
|
|
|
|
pointer to the object's run-time type, and `pointed_to_offset' is
|
|
|
|
|
the offset in target addressable memory units from the full object
|
|
|
|
|
to the pointed-to object -- that is, the value `embedded_offset' would
|
|
|
|
|
have if we followed the pointer and fetched the complete object.
|
|
|
|
|
(I don't really see the point. Why not just determine the
|
|
|
|
|
run-time type when you indirect, and avoid the special case? The
|
|
|
|
|
contents don't matter until you indirect anyway.)
|
|
|
|
|
|
|
|
|
|
If we're not doing anything fancy, `enclosing_type' is equal to
|
|
|
|
|
`type', and `embedded_offset' is zero, so everything works
|
|
|
|
|
normally. */
|
|
|
|
|
struct type *m_enclosing_type;
|
|
|
|
|
LONGEST m_embedded_offset = 0;
|
|
|
|
|
LONGEST m_pointed_to_offset = 0;
|
|
|
|
|
|
|
|
|
|
/* Actual contents of the value. Target byte-order.
|
|
|
|
|
|
|
|
|
|
May be nullptr if the value is lazy or is entirely optimized out.
|
|
|
|
|
Guaranteed to be non-nullptr otherwise. */
|
|
|
|
|
gdb::unique_xmalloc_ptr<gdb_byte> m_contents;
|
|
|
|
|
|
|
|
|
|
/* Unavailable ranges in CONTENTS. We mark unavailable ranges,
|
|
|
|
|
rather than available, since the common and default case is for a
|
|
|
|
|
value to be available. This is filled in at value read time.
|
|
|
|
|
The unavailable ranges are tracked in bits. Note that a contents
|
|
|
|
|
bit that has been optimized out doesn't really exist in the
|
|
|
|
|
program, so it can't be marked unavailable either. */
|
|
|
|
|
std::vector<range> m_unavailable;
|
|
|
|
|
|
|
|
|
|
/* Likewise, but for optimized out contents (a chunk of the value of
|
|
|
|
|
a variable that does not actually exist in the program). If LVAL
|
|
|
|
|
is lval_register, this is a register ($pc, $sp, etc., never a
|
|
|
|
|
program variable) that has not been saved in the frame. Not
|
|
|
|
|
saved registers and optimized-out program variables values are
|
|
|
|
|
treated pretty much the same, except not-saved registers have a
|
|
|
|
|
different string representation and related error strings. */
|
|
|
|
|
std::vector<range> m_optimized_out;
|
|
|
|
|
|
|
|
|
|
/* This is only non-zero for values of TYPE_CODE_ARRAY and if the size of
|
|
|
|
|
the array in inferior memory is greater than max_value_size. If these
|
|
|
|
|
conditions are met then, when the value is loaded from the inferior
|
|
|
|
|
GDB will only load a portion of the array into memory, and
|
|
|
|
|
limited_length will be set to indicate the length in octets that were
|
|
|
|
|
loaded from the inferior. */
|
|
|
|
|
ULONGEST m_limited_length = 0;
|
2023-01-31 13:25:17 -07:00
|
|
|
|
|
|
|
|
|
/* Allocate a value and its contents for type TYPE. If CHECK_SIZE
|
|
|
|
|
is true, then apply the usual max-value-size checks. */
|
|
|
|
|
static struct value *allocate (struct type *type, bool check_size);
|
2023-01-31 13:53:55 -07:00
|
|
|
|
|
|
|
|
|
/* Helper for fetch_lazy when the value is a bitfield. */
|
|
|
|
|
void fetch_lazy_bitfield ();
|
|
|
|
|
|
|
|
|
|
/* Helper for fetch_lazy when the value is in memory. */
|
|
|
|
|
void fetch_lazy_memory ();
|
|
|
|
|
|
|
|
|
|
/* Helper for fetch_lazy when the value is in a register. */
|
|
|
|
|
void fetch_lazy_register ();
|
2023-01-31 13:59:56 -07:00
|
|
|
|
|
|
|
|
|
/* Try to limit ourselves to only fetching the limited number of
|
|
|
|
|
elements. However, if this limited number of elements still
|
|
|
|
|
puts us over max_value_size, then we still refuse it and
|
|
|
|
|
return failure here, which will ultimately throw an error. */
|
|
|
|
|
bool set_limited_array_length ();
|
|
|
|
|
|
|
|
|
|
/* Allocate the contents of this value if it has not been allocated
|
|
|
|
|
yet. If CHECK_SIZE is true, then apply the usual max-value-size
|
|
|
|
|
checks. */
|
|
|
|
|
void allocate_contents (bool check_size);
|
2023-01-31 14:11:48 -07:00
|
|
|
|
|
|
|
|
|
/* Helper function for value_contents_eq. The only difference is that
|
|
|
|
|
this function is bit rather than byte based.
|
|
|
|
|
|
|
|
|
|
Compare LENGTH bits of this value's contents starting at OFFSET1
|
|
|
|
|
bits with LENGTH bits of VAL2's contents starting at OFFSET2
|
|
|
|
|
bits. Return true if the available bits match. */
|
|
|
|
|
bool contents_bits_eq (int offset1, const struct value *val2, int offset2,
|
|
|
|
|
int length) const;
|
2023-01-31 14:38:30 -07:00
|
|
|
|
|
|
|
|
|
void require_not_optimized_out () const;
|
|
|
|
|
void require_available () const;
|
2023-01-31 16:13:08 -07:00
|
|
|
|
|
|
|
|
|
/* Returns true if this value is entirely covered by RANGES. If the
|
|
|
|
|
value is lazy, it'll be read now. Note that RANGE is a pointer
|
|
|
|
|
to pointer because reading the value might change *RANGE. */
|
2023-02-14 10:21:58 -07:00
|
|
|
|
bool entirely_covered_by_range_vector (const std::vector<range> &ranges);
|
2023-02-01 07:27:50 -07:00
|
|
|
|
|
|
|
|
|
/* Copy the ranges metadata from this value that overlaps
|
|
|
|
|
[SRC_BIT_OFFSET, SRC_BIT_OFFSET+BIT_LENGTH) into DST,
|
|
|
|
|
adjusted. */
|
|
|
|
|
void ranges_copy_adjusted (struct value *dst, int dst_bit_offset,
|
|
|
|
|
int src_bit_offset, int bit_length) const;
|
|
|
|
|
|
|
|
|
|
/* Copy LENGTH target addressable memory units of this value's (all)
|
|
|
|
|
contents (value_contents_all) starting at SRC_OFFSET, into DST
|
|
|
|
|
value's (all) contents, starting at DST_OFFSET. If unavailable
|
|
|
|
|
contents are being copied from this, the corresponding DST
|
|
|
|
|
contents are marked unavailable accordingly. Neither DST nor
|
|
|
|
|
this value may be lazy values.
|
|
|
|
|
|
|
|
|
|
It is assumed the contents of DST in the [DST_OFFSET,
|
|
|
|
|
DST_OFFSET+LENGTH) range are wholly available. */
|
|
|
|
|
void contents_copy_raw (struct value *dst, LONGEST dst_offset,
|
|
|
|
|
LONGEST src_offset, LONGEST length);
|
|
|
|
|
|
|
|
|
|
/* A helper for value_from_component_bitsize that copies bits from
|
|
|
|
|
this value to DEST. */
|
|
|
|
|
void contents_copy_raw_bitwise (struct value *dst, LONGEST dst_bit_offset,
|
|
|
|
|
LONGEST src_bit_offset, LONGEST bit_length);
|
2023-01-31 07:46:56 -07:00
|
|
|
|
};
|
|
|
|
|
|
2023-01-31 14:22:13 -07:00
|
|
|
|
inline void
|
|
|
|
|
value_ref_policy::incref (struct value *ptr)
|
|
|
|
|
{
|
2023-01-31 14:25:29 -07:00
|
|
|
|
ptr->incref ();
|
2023-01-31 14:22:13 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
|
value_ref_policy::decref (struct value *ptr)
|
|
|
|
|
{
|
2023-01-31 14:25:29 -07:00
|
|
|
|
ptr->decref ();
|
2023-01-31 14:22:13 -07:00
|
|
|
|
}
|
|
|
|
|
|
2012-04-14 12:18:50 +00:00
|
|
|
|
/* Returns value_type or value_enclosing_type depending on
|
|
|
|
|
value_print_options.objectprint.
|
|
|
|
|
|
|
|
|
|
If RESOLVE_SIMPLE_TYPES is 0 the enclosing type will be resolved
|
|
|
|
|
only for pointers and references, else it will be returned
|
|
|
|
|
for all the types (e.g. structures). This option is useful
|
|
|
|
|
to prevent retrieving enclosing type for the base classes fields.
|
|
|
|
|
|
|
|
|
|
REAL_TYPE_FOUND is used to inform whether the real type was found
|
|
|
|
|
(or just static type was used). The NULL may be passed if it is not
|
|
|
|
|
necessary. */
|
|
|
|
|
|
|
|
|
|
extern struct type *value_actual_type (struct value *value,
|
|
|
|
|
int resolve_simple_types,
|
|
|
|
|
int *real_type_found);
|
|
|
|
|
|
2009-02-06 22:50:52 +00:00
|
|
|
|
/* For lval_computed values, this structure holds functions used to
|
|
|
|
|
retrieve and set the value (or portions of the value).
|
|
|
|
|
|
|
|
|
|
For each function, 'V' is the 'this' pointer: an lval_funcs
|
|
|
|
|
function F may always assume that the V it receives is an
|
|
|
|
|
lval_computed value, and has F in the appropriate slot of its
|
|
|
|
|
lval_funcs structure. */
|
|
|
|
|
|
|
|
|
|
struct lval_funcs
|
|
|
|
|
{
|
|
|
|
|
/* Fill in VALUE's contents. This is used to "un-lazy" values. If
|
|
|
|
|
a problem arises in obtaining VALUE's bits, this function should
|
2011-10-09 19:36:06 +00:00
|
|
|
|
call 'error'. If it is NULL value_fetch_lazy on "un-lazy"
|
|
|
|
|
non-optimized-out value is an internal error. */
|
2009-02-06 22:50:52 +00:00
|
|
|
|
void (*read) (struct value *v);
|
|
|
|
|
|
|
|
|
|
/* Handle an assignment TOVAL = FROMVAL by writing the value of
|
|
|
|
|
FROMVAL to TOVAL's location. The contents of TOVAL have not yet
|
|
|
|
|
been updated. If a problem arises in doing so, this function
|
2011-10-09 19:36:06 +00:00
|
|
|
|
should call 'error'. If it is NULL such TOVAL assignment is an error as
|
|
|
|
|
TOVAL is not considered as an lvalue. */
|
2009-02-06 22:50:52 +00:00
|
|
|
|
void (*write) (struct value *toval, struct value *fromval);
|
|
|
|
|
|
2021-09-10 12:40:54 -06:00
|
|
|
|
/* Return true if any part of V is optimized out, false otherwise.
|
|
|
|
|
This will only be called for lazy values -- if the value has been
|
|
|
|
|
fetched, then the value's optimized-out bits are consulted
|
|
|
|
|
instead. */
|
|
|
|
|
bool (*is_optimized_out) (struct value *v);
|
|
|
|
|
|
2010-11-29 21:18:16 +00:00
|
|
|
|
/* If non-NULL, this is used to implement pointer indirection for
|
|
|
|
|
this value. This method may return NULL, in which case value_ind
|
|
|
|
|
will fall back to ordinary indirection. */
|
|
|
|
|
struct value *(*indirect) (struct value *value);
|
|
|
|
|
|
gdb/
Display @entry parameter values even for references.
* ada-valprint.c (ada_val_print_1) <TYPE_CODE_REF>: Try also
coerce_ref_if_computed.
* c-valprint.c (c_val_print) <TYPE_CODE_REF>: Likewise.
* dwarf2expr.c (dwarf_block_to_dwarf_reg_deref): New function.
(execute_stack_op) <DW_OP_GNU_entry_value>: Add -1 deref_size to the
existing push_dwarf_reg_entry_value call. Add new detection calling
dwarf_block_to_dwarf_reg_deref. Update the error message.
(ctx_no_push_dwarf_reg_entry_value): New parameter deref_size.
* dwarf2expr.h
(struct dwarf_expr_context_funcs) <push_dwarf_reg_entry_value>: Add new
parameter deref_size, describe it in the comment.
(ctx_no_push_dwarf_reg_entry_value): Add new parameter deref_size.
(dwarf_block_to_dwarf_reg_deref): New declaration.
* dwarf2loc.c (dwarf_entry_parameter_to_value): Add new parameter
deref_size, describe it in the function comment. New variables
data_src and size, fetch the alternative block accoring to DEREF_SIZE.
(dwarf_expr_push_dwarf_reg_entry_value): Add new parameter deref_size,
describe it in the function comment. Fetch the alternative block
accoring to DEREF_SIZE.
(entry_data_value_coerce_ref, entry_data_value_copy_closure)
(entry_data_value_free_closure, entry_data_value_funcs): New.
(value_of_dwarf_reg_entry): New variables checked_type, target_type,
outer_val, target_val, val and addr. Try to fetch and create also
referenced value content.
(pieced_value_funcs): NULL value for coerce_ref.
(needs_dwarf_reg_entry_value): Add new parameter deref_size.
* f-valprint.c (f_val_print) <TYPE_CODE_REF>: Try also
coerce_ref_if_computed.
* opencl-lang.c (opencl_value_funcs): NULL value for coerce_ref.
* p-valprint.c (pascal_val_print) <TYPE_CODE_REF>: Likewise.
* stack.c (read_frame_arg): Compare also dereferenced values.
* value.c (value_computed_funcs): Make the parameter v const, use
value_lval_const for it.
(value_lval_const, coerce_ref_if_computed): New function.
(coerce_ref): New variable retval. Call also coerce_ref_if_computed.
* value.h (struct lval_funcs): New field coerce_ref.
(value_computed_funcs): Make the parameter v const.
(value_lval_const, coerce_ref_if_computed): New declarations.
gdb/testsuite/
Display @entry parameter values even for references.
* gdb.arch/amd64-entry-value.cc (reference, datap, datap_input): New
functions.
(main): New variables regvar, nodatavarp, stackvar1, stackvar2. Call
reference and datap_input.
* gdb.arch/amd64-entry-value.exp (reference, breakhere_reference): New
breakpoints.
(continue to breakpoint: entry_reference: reference)
(entry_reference: bt at entry)
(continue to breakpoint: entry_reference: breakhere_reference)
(entry_reference: bt, entry_reference: ptype regparam)
(entry_reference: p regparam, entry_reference: ptype regparam@entry)
(entry_reference: p regparam@entry, entry_reference: p ®param@entry)
(entry_reference: p regcopy, entry_reference: p nodataparam)
(entry_reference: p nodataparam@entry): New tests.
2011-10-09 19:43:41 +00:00
|
|
|
|
/* If non-NULL, this is used to implement reference resolving for
|
|
|
|
|
this value. This method may return NULL, in which case coerce_ref
|
|
|
|
|
will fall back to ordinary references resolving. */
|
|
|
|
|
struct value *(*coerce_ref) (const struct value *value);
|
|
|
|
|
|
2010-11-29 21:18:16 +00:00
|
|
|
|
/* If non-NULL, this is used to determine whether the indicated bits
|
|
|
|
|
of VALUE are a synthetic pointer. */
|
2023-02-14 10:16:26 -07:00
|
|
|
|
bool (*check_synthetic_pointer) (const struct value *value,
|
|
|
|
|
LONGEST offset, int length);
|
2010-11-29 21:18:16 +00:00
|
|
|
|
|
2009-02-06 22:50:52 +00:00
|
|
|
|
/* Return a duplicate of VALUE's closure, for use in a new value.
|
|
|
|
|
This may simply return the same closure, if VALUE's is
|
|
|
|
|
reference-counted or statically allocated.
|
|
|
|
|
|
|
|
|
|
This may be NULL, in which case VALUE's closure is re-used in the
|
|
|
|
|
new value. */
|
2010-06-11 15:36:10 +00:00
|
|
|
|
void *(*copy_closure) (const struct value *v);
|
2009-02-06 22:50:52 +00:00
|
|
|
|
|
|
|
|
|
/* Drop VALUE's reference to its closure. Maybe this frees the
|
|
|
|
|
closure; maybe this decrements a reference count; maybe the
|
|
|
|
|
closure is statically allocated and this does nothing.
|
|
|
|
|
|
|
|
|
|
This may be NULL, in which case no action is taken to free
|
|
|
|
|
VALUE's closure. */
|
|
|
|
|
void (*free_closure) (struct value *v);
|
|
|
|
|
};
|
|
|
|
|
|
Print registers not saved in the frame as "<not saved>" instead of "<optimized out>".
Currently, in some scenarios, GDB prints <optimized out> when printing
outer frame registers. An <optimized out> register is a confusing
concept. What this really means is that the register is
call-clobbered, or IOW, not saved by the callee. This patch makes GDB
say that instead.
Before patch:
(gdb) p/x $rax $1 = <optimized out>
(gdb) info registers rax
rax <optimized out>
After patch:
(gdb) p/x $rax
$1 = <not saved>
(gdb) info registers rax
rax <not saved>
However, if for some reason the debug info describes a variable as
being in such a register (**), we still want to print <optimized out>
when printing the variable. IOW, <not saved> is reserved for
inspecting registers at the machine level. The patch uses
lval_register+optimized_out to encode the not saved registers, and
makes it so that optimized out variables always end up in
!lval_register values.
** See <https://sourceware.org/ml/gdb-patches/2012-08/msg00787.html>.
Current/recent enough GCC doesn't mark variables/arguments as being in
call-clobbered registers in the ranges corresponding to function
calls, while older GCCs did. Newer GCCs will just not say where the
variable is, so GDB will end up realizing the variable is optimized
out.
frame_unwind_got_optimized creates not_lval optimized out registers,
so by default, in most cases, we'll see <optimized out>.
value_of_register is the function eval.c uses for evaluating
OP_REGISTER (again, $pc, etc.), and related bits. It isn't used for
anything else. This function makes sure to return lval_register
values. The patch makes "info registers" and the MI equivalent use it
too. I think it just makes a lot of sense, as this makes it so that
when printing machine registers ($pc, etc.), we go through a central
function.
We're likely to need a different encoding at some point, if/when we
support partially saved registers. Even then, I think
value_of_register will still be the spot to tag the intention to print
machine register values differently.
value_from_register however may also return optimized out
lval_register values, so at a couple places where we're computing a
variable's location from a dwarf expression, we convert the resulting
value away from lval_register to a regular optimized out value.
Tested on x86_64 Fedora 17
gdb/
2013-10-02 Pedro Alves <palves@redhat.com>
* cp-valprint.c (cp_print_value_fields): Adjust calls to
val_print_optimized_out.
* jv-valprint.c (java_print_value_fields): Likewise.
* p-valprint.c (pascal_object_print_value_fields): Likewise.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full)
<DWARF_VALUE_REGISTER>: If the register was not saved, return a
new optimized out value.
* findvar.c (address_from_register): Likewise.
* frame.c (put_frame_register): Tweak error string to say the
register was not saved, rather than optimized out.
* infcmd.c (default_print_one_register_info): Adjust call to
val_print_optimized_out. Use value_of_register instead of
get_frame_register_value.
* mi/mi-main.c (output_register): Use value_of_register instead of
get_frame_register_value.
* valprint.c (valprint_check_validity): Likewise.
(val_print_optimized_out): New value parameter. If the value is
lval_register, print <not saved> instead.
(value_check_printable, val_print_scalar_formatted): Adjust calls
to val_print_optimized_out.
* valprint.h (val_print_optimized_out): New value parameter.
* value.c (struct value) <optimized_out>: Extend comment.
(error_value_optimized_out): New function.
(require_not_optimized_out): Use it. Use a different string for
lval_register values.
* value.h (error_value_optimized_out): New declaration.
* NEWS: Mention <not saved>.
gdb/testsuite/
2013-10-02 Pedro Alves <palves@redhat.com>
* gdb.dwarf2/dw2-reg-undefined.exp <pattern_rax_rbx_rcx_print,
pattern_rax_rbx_rcx_info>: Set to "<not saved>".
* gdb.mi/mi-reg-undefined.exp (opt_out_pattern): Delete.
(not_saved_pattern): New.
Replace use of the former with the latter.
gdb/doc/
2013-10-02 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Registers): Expand description of saved registers
in frames. Explain <not saved>.
2013-10-02 16:15:46 +00:00
|
|
|
|
/* Throw an error complaining that the value has been optimized
|
|
|
|
|
out. */
|
|
|
|
|
|
|
|
|
|
extern void error_value_optimized_out (void);
|
|
|
|
|
|
2005-02-08 05:41:10 +00:00
|
|
|
|
/* Pointer to internal variable. */
|
2023-01-31 12:46:20 -07:00
|
|
|
|
#define VALUE_INTERNALVAR(val) (*((val)->deprecated_internalvar_hack ()))
|
2005-02-08 05:41:10 +00:00
|
|
|
|
|
Change meaning of VALUE_FRAME_ID; rename to VALUE_NEXT_FRAME_ID
The VALUE_FRAME_ID macro provides access to a member in struct value
that's used to hold the frame id that's used when determining a
register's value or when assigning to a register. The underlying
member has a long and obscure name. I won't refer to it here, but
will simply refer to VALUE_FRAME_ID as if it's the struct value member
instead of being a convenient macro.
At the moment, without this patch in place, VALUE_FRAME_ID is set in
value_of_register_lazy() and several other locations to hold the frame
id of the frame passed to those functions.
VALUE_FRAME_ID is used in the lval_register case of
value_fetch_lazy(). To fetch the register's value, it calls
get_frame_register_value() which, in turn, calls
frame_unwind_register_value() with frame->next.
A python based unwinder may wish to determine the value of a register
or evaluate an expression containing a register. When it does this,
value_fetch_lazy() will be called under some circumstances. It will
attempt to determine the frame id associated with the frame passed to
it. In so doing, it will end up back in the frame sniffer of the very
same python unwinder that's attempting to learn the value of a
register as part of the sniffing operation. This recursion is not
desirable.
As noted above, when value_fetch_lazy() wants to fetch a register's
value, it does so (indirectly) by unwinding from frame->next.
With this in mind, a solution suggests itself: Change VALUE_FRAME_ID
to hold the frame id associated with the next frame. Then, when it
comes time to obtain the value associated with the register, we can
simply unwind from the frame corresponding to the frame id stored in
VALUE_FRAME_ID. This neatly avoids the python unwinder recursion
problem by changing when the "next" operation occurs. Instead of the
"next" operation occuring when the register value is fetched, it
occurs earlier on when assigning a frame id to VALUE_FRAME_ID.
(Thanks to Pedro for this suggestion.)
This patch implements this idea.
It builds on the patch "Distinguish sentinel frame from null frame".
Without that work in place, it's necessary to check for null_id at
several places and then obtain the sentinel frame.
It also renames most occurences of VALUE_FRAME_ID to
VALUE_NEXT_FRAME_ID to reflect the new meaning of this field.
There are several uses of VALUE_FRAME_ID which were not changed. In
each case, the original meaning of VALUE_FRAME_ID is required to get
correct results. In all but one of these uses, either
put_frame_register_bytes() or get_frame_register_bytes() is being
called with the frame value obtained from VALUE_FRAME_ID. Both of
these functions perform some unwinding by performing a "->next"
operation on the frame passed to it. If we were to use the new
VALUE_NEXT_FRAME_ID macro, this would effectively do two "->next"
operations, which is not what we want.
The VALUE_FRAME_ID macro has been redefined in terms of
VALUE_NEXT_FRAME_ID. It simply fetches the previous frame's id,
providing this id as the value of the macro.
gdb/ChangeLog:
* value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update
comment. Create new VALUE_FRAME_ID which is defined in terms of
VALUE_NEXT_FRAME_ID.
(deprecated_value_frame_id_hack): Rename to
deprecated_value_next_frame_id_hack.
* dwarf2loc.c, findvar.c, frame-unwind.c, sentinel-frame.c,
valarith.c, valops.c, value.c: Adjust nearly all occurences of
VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID. Add comments for those
which did not change.
* value.c (struct value): Rename frame_id field to next_frame_id.
Update comment.
(deprecated_value_frame_id_hack): Rename to
deprecated_value_next_frame_id_hack.
(value_fetch_lazy): Call frame_unwind_register_value()
instead of get_frame_register_value().
* frame.c (get_prev_frame_id_by_id): New function.
* frame.h (get_prev_frame_id_by_id): Declare.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Make
VALUE_NEXT_FRAME_ID refer to the next frame.
* findvar.c (value_of_register_lazy): Likewise.
(default_value_from_register): Likewise.
(value_from_register): Likewise.
* frame_unwind.c (frame_unwind_got_optimized): Likewise.
* sentinel-frame.c (sentinel_frame_prev_register): Likewise.
* value.h (VALUE_FRAME_ID): Update comment describing this macro.
2016-09-27 21:18:44 -07:00
|
|
|
|
/* Frame ID of "next" frame to which a register value is relative. A
|
|
|
|
|
register value is indicated by VALUE_LVAL being set to lval_register.
|
|
|
|
|
So, if the register value is found relative to frame F, then the
|
|
|
|
|
frame id of F->next will be stored in VALUE_NEXT_FRAME_ID. */
|
2023-01-31 12:46:20 -07:00
|
|
|
|
#define VALUE_NEXT_FRAME_ID(val) (*((val)->deprecated_next_frame_id_hack ()))
|
Change meaning of VALUE_FRAME_ID; rename to VALUE_NEXT_FRAME_ID
The VALUE_FRAME_ID macro provides access to a member in struct value
that's used to hold the frame id that's used when determining a
register's value or when assigning to a register. The underlying
member has a long and obscure name. I won't refer to it here, but
will simply refer to VALUE_FRAME_ID as if it's the struct value member
instead of being a convenient macro.
At the moment, without this patch in place, VALUE_FRAME_ID is set in
value_of_register_lazy() and several other locations to hold the frame
id of the frame passed to those functions.
VALUE_FRAME_ID is used in the lval_register case of
value_fetch_lazy(). To fetch the register's value, it calls
get_frame_register_value() which, in turn, calls
frame_unwind_register_value() with frame->next.
A python based unwinder may wish to determine the value of a register
or evaluate an expression containing a register. When it does this,
value_fetch_lazy() will be called under some circumstances. It will
attempt to determine the frame id associated with the frame passed to
it. In so doing, it will end up back in the frame sniffer of the very
same python unwinder that's attempting to learn the value of a
register as part of the sniffing operation. This recursion is not
desirable.
As noted above, when value_fetch_lazy() wants to fetch a register's
value, it does so (indirectly) by unwinding from frame->next.
With this in mind, a solution suggests itself: Change VALUE_FRAME_ID
to hold the frame id associated with the next frame. Then, when it
comes time to obtain the value associated with the register, we can
simply unwind from the frame corresponding to the frame id stored in
VALUE_FRAME_ID. This neatly avoids the python unwinder recursion
problem by changing when the "next" operation occurs. Instead of the
"next" operation occuring when the register value is fetched, it
occurs earlier on when assigning a frame id to VALUE_FRAME_ID.
(Thanks to Pedro for this suggestion.)
This patch implements this idea.
It builds on the patch "Distinguish sentinel frame from null frame".
Without that work in place, it's necessary to check for null_id at
several places and then obtain the sentinel frame.
It also renames most occurences of VALUE_FRAME_ID to
VALUE_NEXT_FRAME_ID to reflect the new meaning of this field.
There are several uses of VALUE_FRAME_ID which were not changed. In
each case, the original meaning of VALUE_FRAME_ID is required to get
correct results. In all but one of these uses, either
put_frame_register_bytes() or get_frame_register_bytes() is being
called with the frame value obtained from VALUE_FRAME_ID. Both of
these functions perform some unwinding by performing a "->next"
operation on the frame passed to it. If we were to use the new
VALUE_NEXT_FRAME_ID macro, this would effectively do two "->next"
operations, which is not what we want.
The VALUE_FRAME_ID macro has been redefined in terms of
VALUE_NEXT_FRAME_ID. It simply fetches the previous frame's id,
providing this id as the value of the macro.
gdb/ChangeLog:
* value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update
comment. Create new VALUE_FRAME_ID which is defined in terms of
VALUE_NEXT_FRAME_ID.
(deprecated_value_frame_id_hack): Rename to
deprecated_value_next_frame_id_hack.
* dwarf2loc.c, findvar.c, frame-unwind.c, sentinel-frame.c,
valarith.c, valops.c, value.c: Adjust nearly all occurences of
VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID. Add comments for those
which did not change.
* value.c (struct value): Rename frame_id field to next_frame_id.
Update comment.
(deprecated_value_frame_id_hack): Rename to
deprecated_value_next_frame_id_hack.
(value_fetch_lazy): Call frame_unwind_register_value()
instead of get_frame_register_value().
* frame.c (get_prev_frame_id_by_id): New function.
* frame.h (get_prev_frame_id_by_id): Declare.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Make
VALUE_NEXT_FRAME_ID refer to the next frame.
* findvar.c (value_of_register_lazy): Likewise.
(default_value_from_register): Likewise.
(value_from_register): Likewise.
* frame_unwind.c (frame_unwind_got_optimized): Likewise.
* sentinel-frame.c (sentinel_frame_prev_register): Likewise.
* value.h (VALUE_FRAME_ID): Update comment describing this macro.
2016-09-27 21:18:44 -07:00
|
|
|
|
|
2005-02-08 05:41:10 +00:00
|
|
|
|
/* Register number if the value is from a register. */
|
2023-01-31 12:46:20 -07:00
|
|
|
|
#define VALUE_REGNUM(val) (*((val)->deprecated_regnum_hack ()))
|
2005-02-07 21:42:36 +00:00
|
|
|
|
|
gdb/
Display @entry parameter values even for references.
* ada-valprint.c (ada_val_print_1) <TYPE_CODE_REF>: Try also
coerce_ref_if_computed.
* c-valprint.c (c_val_print) <TYPE_CODE_REF>: Likewise.
* dwarf2expr.c (dwarf_block_to_dwarf_reg_deref): New function.
(execute_stack_op) <DW_OP_GNU_entry_value>: Add -1 deref_size to the
existing push_dwarf_reg_entry_value call. Add new detection calling
dwarf_block_to_dwarf_reg_deref. Update the error message.
(ctx_no_push_dwarf_reg_entry_value): New parameter deref_size.
* dwarf2expr.h
(struct dwarf_expr_context_funcs) <push_dwarf_reg_entry_value>: Add new
parameter deref_size, describe it in the comment.
(ctx_no_push_dwarf_reg_entry_value): Add new parameter deref_size.
(dwarf_block_to_dwarf_reg_deref): New declaration.
* dwarf2loc.c (dwarf_entry_parameter_to_value): Add new parameter
deref_size, describe it in the function comment. New variables
data_src and size, fetch the alternative block accoring to DEREF_SIZE.
(dwarf_expr_push_dwarf_reg_entry_value): Add new parameter deref_size,
describe it in the function comment. Fetch the alternative block
accoring to DEREF_SIZE.
(entry_data_value_coerce_ref, entry_data_value_copy_closure)
(entry_data_value_free_closure, entry_data_value_funcs): New.
(value_of_dwarf_reg_entry): New variables checked_type, target_type,
outer_val, target_val, val and addr. Try to fetch and create also
referenced value content.
(pieced_value_funcs): NULL value for coerce_ref.
(needs_dwarf_reg_entry_value): Add new parameter deref_size.
* f-valprint.c (f_val_print) <TYPE_CODE_REF>: Try also
coerce_ref_if_computed.
* opencl-lang.c (opencl_value_funcs): NULL value for coerce_ref.
* p-valprint.c (pascal_val_print) <TYPE_CODE_REF>: Likewise.
* stack.c (read_frame_arg): Compare also dereferenced values.
* value.c (value_computed_funcs): Make the parameter v const, use
value_lval_const for it.
(value_lval_const, coerce_ref_if_computed): New function.
(coerce_ref): New variable retval. Call also coerce_ref_if_computed.
* value.h (struct lval_funcs): New field coerce_ref.
(value_computed_funcs): Make the parameter v const.
(value_lval_const, coerce_ref_if_computed): New declarations.
gdb/testsuite/
Display @entry parameter values even for references.
* gdb.arch/amd64-entry-value.cc (reference, datap, datap_input): New
functions.
(main): New variables regvar, nodatavarp, stackvar1, stackvar2. Call
reference and datap_input.
* gdb.arch/amd64-entry-value.exp (reference, breakhere_reference): New
breakpoints.
(continue to breakpoint: entry_reference: reference)
(entry_reference: bt at entry)
(continue to breakpoint: entry_reference: breakhere_reference)
(entry_reference: bt, entry_reference: ptype regparam)
(entry_reference: p regparam, entry_reference: ptype regparam@entry)
(entry_reference: p regparam@entry, entry_reference: p ®param@entry)
(entry_reference: p regcopy, entry_reference: p nodataparam)
(entry_reference: p nodataparam@entry): New tests.
2011-10-09 19:43:41 +00:00
|
|
|
|
/* Return value after lval_funcs->coerce_ref (after check_typedef). Return
|
|
|
|
|
NULL if lval_funcs->coerce_ref is not applicable for whatever reason. */
|
|
|
|
|
|
|
|
|
|
extern struct value *coerce_ref_if_computed (const struct value *arg);
|
|
|
|
|
|
2012-02-21 13:48:59 +00:00
|
|
|
|
/* Setup a new value type and enclosing value type for dereferenced value VALUE.
|
|
|
|
|
ENC_TYPE is the new enclosing type that should be set. ORIGINAL_TYPE and
|
2020-07-09 16:26:23 +01:00
|
|
|
|
ORIGINAL_VAL are the type and value of the original reference or
|
|
|
|
|
pointer. ORIGINAL_VALUE_ADDRESS is the address within VALUE, that is
|
|
|
|
|
the address that was dereferenced.
|
2012-02-21 13:48:59 +00:00
|
|
|
|
|
|
|
|
|
Note, that VALUE is modified by this function.
|
|
|
|
|
|
|
|
|
|
It is a common implementation for coerce_ref and value_ind. */
|
|
|
|
|
|
|
|
|
|
extern struct value * readjust_indirect_value_type (struct value *value,
|
|
|
|
|
struct type *enc_type,
|
2016-04-08 15:05:45 -03:00
|
|
|
|
const struct type *original_type,
|
2020-07-09 16:26:23 +01:00
|
|
|
|
struct value *original_val,
|
|
|
|
|
CORE_ADDR original_value_address);
|
2012-02-21 13:48:59 +00:00
|
|
|
|
|
2003-05-10 23:10:08 +00:00
|
|
|
|
/* Convert a REF to the object referenced. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2004-11-10 Andrew Cagney <cagney@gnu.org>
* value.h (COERCE_REF, COERCE_ARRAY, COERCE_NUMBER, COERCE_ENUM)
(coerce_ref, coerce_array, coerce_number, coerce_enum): Replace
macros with function declarations.
* value.c (coerce_ref, coerce_array, coerce_number)
(coerce_enum): New functions.
(value_as_long, value_as_address): Update.
* ada-lang.c (ada_coerce_ref, ada_value_binop)
(ada_evaluate_subexp, ada_value_assign, ada_value_struct_elt): Update.
* jv-lang.c (evaluate_subexp_java): Update.
* valarith.c (value_less, value_neg, value_complement)
(value_binop, value_add, value_subscript, value_x_binop)
(value_logical_not, value_sub): Update.
* valops.c (check_field, value_struct_elt, value_ind)
(value_find_oload_method_list, value_cast, value_assign): Update.
* eval.c (evaluate_subexp_standard): Update.
2004-11-10 18:52:25 +00:00
|
|
|
|
extern struct value *coerce_ref (struct value *value);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* If ARG is an array, convert it to a pointer.
|
|
|
|
|
If ARG is a function, convert it to a function pointer.
|
|
|
|
|
|
|
|
|
|
References are dereferenced. */
|
|
|
|
|
|
2004-11-10 Andrew Cagney <cagney@gnu.org>
* value.h (COERCE_REF, COERCE_ARRAY, COERCE_NUMBER, COERCE_ENUM)
(coerce_ref, coerce_array, coerce_number, coerce_enum): Replace
macros with function declarations.
* value.c (coerce_ref, coerce_array, coerce_number)
(coerce_enum): New functions.
(value_as_long, value_as_address): Update.
* ada-lang.c (ada_coerce_ref, ada_value_binop)
(ada_evaluate_subexp, ada_value_assign, ada_value_struct_elt): Update.
* jv-lang.c (evaluate_subexp_java): Update.
* valarith.c (value_less, value_neg, value_complement)
(value_binop, value_add, value_subscript, value_x_binop)
(value_logical_not, value_sub): Update.
* valops.c (check_field, value_struct_elt, value_ind)
(value_find_oload_method_list, value_cast, value_assign): Update.
* eval.c (evaluate_subexp_standard): Update.
2004-11-10 18:52:25 +00:00
|
|
|
|
extern struct value *coerce_array (struct value *value);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2015-07-28 11:01:50 -04:00
|
|
|
|
/* Read LENGTH addressable memory units starting at MEMADDR into BUFFER,
|
|
|
|
|
which is (or will be copied to) VAL's contents buffer offset by
|
2017-06-13 15:20:31 +02:00
|
|
|
|
BIT_OFFSET bits. Marks value contents ranges as unavailable if
|
|
|
|
|
the corresponding memory is likewise unavailable. STACK indicates
|
|
|
|
|
whether the memory is known to be stack memory. */
|
2011-02-14 11:21:25 +00:00
|
|
|
|
|
2017-06-13 15:20:31 +02:00
|
|
|
|
extern void read_value_memory (struct value *val, LONGEST bit_offset,
|
2023-02-14 09:43:26 -07:00
|
|
|
|
bool stack, CORE_ADDR memaddr,
|
2011-02-14 11:21:25 +00:00
|
|
|
|
gdb_byte *buffer, size_t length);
|
|
|
|
|
|
2013-01-25 17:16:43 +00:00
|
|
|
|
/* Cast SCALAR_VALUE to the element type of VECTOR_TYPE, then replicate
|
|
|
|
|
into each element of a new vector value with VECTOR_TYPE. */
|
|
|
|
|
|
|
|
|
|
struct value *value_vector_widen (struct value *scalar_value,
|
|
|
|
|
struct type *vector_type);
|
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#include "symtab.h"
|
|
|
|
|
#include "gdbtypes.h"
|
|
|
|
|
#include "expression.h"
|
|
|
|
|
|
2022-07-25 14:06:35 -03:00
|
|
|
|
class frame_info_ptr;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
struct fn_field;
|
|
|
|
|
|
2012-05-18 15:31:42 +00:00
|
|
|
|
extern int print_address_demangle (const struct value_print_options *,
|
|
|
|
|
struct gdbarch *, CORE_ADDR,
|
|
|
|
|
struct ui_file *, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
Target FP: Introduce target-float.{c,h}
This patch introduces the new set of target floating-point handling routines
in target-float.{c,h}. In the end, the intention is that this file will
contain support for all operations in target FP format, fully replacing
both the current doublest.{c,h} and dfp.{c,h}.
To begin with, this patch only adds a target_float_is_zero routine,
which handles the equivalent of decimal_is_zero for both binary and
decimal FP. For the binary case, to avoid conversion to DOUBLEST,
this is implemented using the floatformat_classify routine.
However, it turns out that floatformat_classify actually has a bug
(it was not used to check for zero before), so this is fixed as well.
The new routine is used in both value_logical_not and valpy_nonzero.
There is one extra twist: the code previously used value_as_double
to convert to DOUBLEST and then compare against zero. That routine
performs an extra task: it detects invalid floating-point values
and raises an error. In any place where value_as_double is removed
in favor of some target-float.c routine, we need to replace that check.
To keep this check centralized in one place, I've added a new routine
is_floating_value, which returns a boolean determining whether a
value's type is floating point (binary or decimal), and if so, also
performs the validity check. Since we need to check whether a value
is FP before calling any of the target-float routines anyway, this
seems a good place to add the check without much code size overhead.
In some places where we only want to check for floating-point types
and not perform a validity check (e.g. for the *output* of an operation),
we can use the new is_floating_type routine (in gdbarch) instead.
The validity check itself is done by a new target_float_is_valid
routine in target-float, encapsulating floatformat_is_valid.
ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* Makefile.c (SFILES): Add target-float.c.
(HFILES_NO_SRCDIR): Add target-float.h.
(COMMON_OBS): Add target-float.o.
* target-float.h: New file.
* target-float.c: New file.
* doublest.c (floatformat_classify): Fix detection of float_zero.
* gdbtypes.c (is_floating_type): New function.
* gdbtypes.h (is_floating_type): Add prototype.
* value.c: Do not include "floatformat.h".
(unpack_double): Use target_float_is_valid.
(is_floating_value): New function.
* value.h (is_floating_value): Add prototype-
* valarith.c: Include "target-float.h".
(value_logical_not): Use target_float_is_zero.
* python/py-value.c: Include "target-float.h".
(valpy_nonzero): Use target_float_is_zero.
2017-11-06 15:55:11 +01:00
|
|
|
|
/* Returns true if VAL is of floating-point type. In addition,
|
|
|
|
|
throws an error if the value is an invalid floating-point value. */
|
|
|
|
|
extern bool is_floating_value (struct value *val);
|
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern LONGEST value_as_long (struct value *val);
|
|
|
|
|
extern CORE_ADDR value_as_address (struct value *val);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2023-02-27 11:57:24 -07:00
|
|
|
|
/* Extract the value from VAL as a MPZ. This coerces arrays and
|
|
|
|
|
handles various integer-like types as well. */
|
|
|
|
|
|
|
|
|
|
extern gdb_mpz value_as_mpz (struct value *val);
|
|
|
|
|
|
2005-05-09 Andrew Cagney <cagney@gnu.org>
Use gdb_byte in preference to bfd_byte.
* gdbarch.sh: Update.
* gdbarch.h, gdbarch.c: Re-generate.
* ada-lang.c, ada-lang.h, ada-valprint.c, arch-utils.c: Update.
* c-lang.c, c-lang.h, c-valprint.c, cp-valprint.c: Update.
* f-lang.c, f-lang.h, f-valprint.c, gdbcore.h, jv-lang.h: Update.
* jv-valprint.c, language.c, language.h, m2-lang.c: Update.
* m2-lang.h, m2-valprint.c, objc-lang.c, p-lang.c: Update.
* p-lang.h, p-valprint.c, regcache.c, scm-lang.c: Update.
* scm-lang.h, scm-valprint.c, target.c, target.h: Update.
* tramp-frame.c, valarith.c, valops.c, valprint.c: Update.
* valprint.h, value.c, value.h: Update.
2005-05-09 21:20:35 +00:00
|
|
|
|
extern LONGEST unpack_long (struct type *type, const gdb_byte *valaddr);
|
|
|
|
|
extern CORE_ADDR unpack_pointer (struct type *type, const gdb_byte *valaddr);
|
2011-02-14 11:25:59 +00:00
|
|
|
|
|
2005-04-28 16:15:19 +00:00
|
|
|
|
extern LONGEST unpack_field_as_long (struct type *type,
|
2005-05-09 Andrew Cagney <cagney@gnu.org>
Use gdb_byte in preference to bfd_byte.
* gdbarch.sh: Update.
* gdbarch.h, gdbarch.c: Re-generate.
* ada-lang.c, ada-lang.h, ada-valprint.c, arch-utils.c: Update.
* c-lang.c, c-lang.h, c-valprint.c, cp-valprint.c: Update.
* f-lang.c, f-lang.h, f-valprint.c, gdbcore.h, jv-lang.h: Update.
* jv-valprint.c, language.c, language.h, m2-lang.c: Update.
* m2-lang.h, m2-valprint.c, objc-lang.c, p-lang.c: Update.
* p-lang.h, p-valprint.c, regcache.c, scm-lang.c: Update.
* scm-lang.h, scm-valprint.c, target.c, target.h: Update.
* tramp-frame.c, valarith.c, valops.c, valprint.c: Update.
* valprint.h, value.c, value.h: Update.
2005-05-09 21:20:35 +00:00
|
|
|
|
const gdb_byte *valaddr,
|
2000-05-28 01:12:42 +00:00
|
|
|
|
int fieldno);
|
Add new variant part code
This patch adds the infrastructure for the new variant part code. At
this point, nothing uses this code. This is done in a separate patch
to make it simpler to review.
I examined a few possible approaches to handling variant parts. In
particular, I considered having a DWARF variant part be a union
(similar to how the Rust code works now); and I considered having type
fields have a flag indicating that they are variants.
Having separate types seemed bad conceptually, because these variants
aren't truly separate -- they rely on the "parent" type. And,
changing how fields worked seemed excessively invasive.
So, in the end I thought the approach taken in this patch was both
simple to implement and understand, without losing generality. The
idea in this patch is that all the fields of a type with variant parts
will be stored in a single field array, just as if they'd all been
listed directly. Then, the variants are attached as a dynamic
property. These control which fields end up in the type that's
constructed during dynamic type resolution.
gdb/ChangeLog
2020-04-24 Tom Tromey <tromey@adacore.com>
* gdbtypes.c (is_dynamic_type_internal): Check for variant parts.
(variant::matches, compute_variant_fields_recurse)
(compute_variant_fields_inner, compute_variant_fields): New
functions.
(resolve_dynamic_struct): Check for DYN_PROP_VARIANT_PARTS.
Use resolved_type after type is made.
(operator==): Add new cases.
* gdbtypes.h (TYPE_HAS_VARIANT_PARTS): New macro.
(struct discriminant_range, struct variant, struct variant_part):
New.
(union dynamic_prop_data) <variant_parts, original_type>: New
members.
(enum dynamic_prop_node_kind) <DYN_PROP_VARIANT_PARTS>: New constant.
(enum dynamic_prop_kind) <PROP_TYPE, PROP_VARIANT_PARTS>: New
constants.
* value.c (unpack_bits_as_long): Now public.
* value.h (unpack_bits_as_long): Declare.
2020-04-24 13:40:31 -06:00
|
|
|
|
|
|
|
|
|
/* Unpack a bitfield of the specified FIELD_TYPE, from the object at
|
|
|
|
|
VALADDR, and store the result in *RESULT.
|
|
|
|
|
The bitfield starts at BITPOS bits and contains BITSIZE bits; if
|
|
|
|
|
BITSIZE is zero, then the length is taken from FIELD_TYPE.
|
|
|
|
|
|
|
|
|
|
Extracting bits depends on endianness of the machine. Compute the
|
|
|
|
|
number of least significant bits to discard. For big endian machines,
|
|
|
|
|
we compute the total number of bits in the anonymous object, subtract
|
|
|
|
|
off the bit count from the MSB of the object to the MSB of the
|
|
|
|
|
bitfield, then the size of the bitfield, which leaves the LSB discard
|
|
|
|
|
count. For little endian machines, the discard count is simply the
|
|
|
|
|
number of bits from the LSB of the anonymous object to the LSB of the
|
|
|
|
|
bitfield.
|
|
|
|
|
|
|
|
|
|
If the field is signed, we also do sign extension. */
|
|
|
|
|
|
|
|
|
|
extern LONGEST unpack_bits_as_long (struct type *field_type,
|
|
|
|
|
const gdb_byte *valaddr,
|
|
|
|
|
LONGEST bitpos, LONGEST bitsize);
|
|
|
|
|
|
2011-02-14 11:25:59 +00:00
|
|
|
|
extern int unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr,
|
2016-04-12 15:02:57 -04:00
|
|
|
|
LONGEST embedded_offset, int fieldno,
|
2011-02-14 11:25:59 +00:00
|
|
|
|
const struct value *val, LONGEST *result);
|
|
|
|
|
|
|
|
|
|
extern struct value *value_field_bitfield (struct type *type, int fieldno,
|
|
|
|
|
const gdb_byte *valaddr,
|
2016-04-12 15:02:57 -04:00
|
|
|
|
LONGEST embedded_offset,
|
2011-02-14 11:25:59 +00:00
|
|
|
|
const struct value *val);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2007-05-14 17:21:50 +00:00
|
|
|
|
extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num);
|
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_from_longest (struct type *type, LONGEST num);
|
2010-06-28 21:16:04 +00:00
|
|
|
|
extern struct value *value_from_ulongest (struct type *type, ULONGEST num);
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr);
|
2019-03-07 14:53:37 +00:00
|
|
|
|
extern struct value *value_from_host_double (struct type *type, double d);
|
2014-07-22 10:47:53 -06:00
|
|
|
|
extern struct value *value_from_history_ref (const char *, const char **);
|
Create subobject value in pretty printer
Nowadays, we create a value of subobject in pretty printer with 'address'
being used,
value = value_from_contents_and_address (type, valaddr + embedded_offset,
address + embedded_offset);
set_value_component_location (value, val);
/* set_value_component_location resets the address, so we may
need to set it again. */
if (VALUE_LVAL (value) != lval_internalvar
&& VALUE_LVAL (value) != lval_internalvar_component
&& VALUE_LVAL (value) != lval_computed)
set_value_address (value, address + embedded_offset);
value_from_contents_and_address creates a value from memory, but the
value we are pretty-printing may not from memory at all.
Instead of using value_from_contents_and_address, we create a value
of subobject with the same location as object's but different offset.
We avoid using address in this way. As a result, parameter 'address'
in apply_val_pretty_printer is no longer needed, we can remove it in
next step.
We've already had the location of the 'whole' value, so it is safe
to assume we can create a value of 'component' or 'suboject' value
at the same location but with different offset.
gdb:
2016-11-21 Yao Qi <yao.qi@linaro.org>
* guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer):
Don't call value_from_contents_and_address and
set_value_address. Call value_from_component.
* python/py-prettyprint.c (gdbpy_apply_val_pretty_printer):
Likewise.
* value.c (value_from_component): New function.
* value.h (value_from_component): Likewise.
* valarith.c (value_subscripted_rvalue): Call
value_from_component.
2016-11-21 14:15:06 +00:00
|
|
|
|
extern struct value *value_from_component (struct value *, struct type *,
|
|
|
|
|
LONGEST);
|
1999-06-14 18:08:47 +00:00
|
|
|
|
|
2023-02-27 11:57:24 -07:00
|
|
|
|
/* Convert the value V into a newly allocated value. */
|
|
|
|
|
extern struct value *value_from_mpz (struct type *type, const gdb_mpz &v);
|
2022-09-27 12:53:25 -06:00
|
|
|
|
|
2004-11-09 Andrew Cagney <cagney@gnu.org>
* value.h (struct value): Delete field bfd_section.
(VALUE_BFD_SECTION): Delete macro.
(COERCE_REF): Update.
(value_at, value_at_lazy): Delete asection parameter.
* printcmd.c (print_formatted, x_command): Update.
(do_examine): Delete asection parameter.
(next_section): Delete variable.
* valops.c (value_cast, value_at, value_at_lazy)
(value_coerce_function, value_addr, value_ind, value_string)
(find_rt_vbase_offset, value_full_object): Update.
* hpacc-abi.c (hpacc_virtual_fn_field)
(hpacc_value_rtti_type): Update.
* gnu-v3-abi.c (gnuv3_rtti_type, gnuv3_virtual_fn_field)
(gnuv3_baseclass_offset): Update.
* f-valprint.c (f_val_print): Update.
* c-valprint.c (c_val_print): Update.
* p-valprint.c (pascal_val_print): Update.
* jv-valprint.c (java_value_print): Update.
* jv-lang.c (java_class_from_object, evaluate_subexp_java): Update.
* ada-lang.c (ada_value_primitive_packed_val)
(ada_evaluate_subexp): Update.
* dwarf2loc.c (dwarf2_evaluate_loc_desc): Update.
* expprint.c (print_subexp_standard): Update.
* infcall.c (call_function_by_hand): Update.
* valarith.c (value_add): Update.
* eval.c (evaluate_subexp_standard): Update.
* values.c (allocate_value, value_copy, value_static_field): Update.
* findvar.c (read_var_value, locate_var_value): Update.
2004-11-09 14:43:27 +00:00
|
|
|
|
extern struct value *value_at (struct type *type, CORE_ADDR addr);
|
2023-03-01 10:33:20 -07:00
|
|
|
|
|
|
|
|
|
/* Return a new value given a type and an address. The new value is
|
|
|
|
|
lazy. If FRAME is given, it is used when resolving dynamic
|
|
|
|
|
properties. */
|
|
|
|
|
|
|
|
|
|
extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr,
|
|
|
|
|
frame_info_ptr frame = nullptr);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2022-09-09 12:50:33 -06:00
|
|
|
|
/* Like value_at, but ensures that the result is marked not_lval.
|
|
|
|
|
This can be important if the memory is "volatile". */
|
|
|
|
|
extern struct value *value_at_non_lval (struct type *type, CORE_ADDR addr);
|
|
|
|
|
|
2014-05-08 11:26:44 -06:00
|
|
|
|
extern struct value *value_from_contents_and_address_unresolved
|
|
|
|
|
(struct type *, const gdb_byte *, CORE_ADDR);
|
2023-03-01 10:33:20 -07:00
|
|
|
|
extern struct value *value_from_contents_and_address
|
|
|
|
|
(struct type *, const gdb_byte *, CORE_ADDR,
|
|
|
|
|
frame_info_ptr frame = nullptr);
|
2011-05-12 17:40:55 +00:00
|
|
|
|
extern struct value *value_from_contents (struct type *, const gdb_byte *);
|
2008-11-24 23:21:16 +00:00
|
|
|
|
|
Use address_from_register in dwarf2-frame.c:read_addr_from_reg
This patch fixes a problem that prevented use of the Dwarf unwinders on SPU,
because dwarf2-frame.c common code did not support the situation where the
stack and/or frame pointer is maintained in a *vector* register. This is
because read_addr_from_reg is hard-coded to assume that such pointers can
be read from registers via a simple get_frame_register / unpack_pointer
operation.
Now, there *is* a routine address_from_register that calls into the
appropriate tdep routines to handle pointer values in "weird" registers
like on SPU, but it turns out I cannot simply change dwarf2-frame.c to
use address_from_register. This is because address_from_register uses
value_from_register to create a (temporary) value, and that routine
at some point calls get_frame_id in order to set up that value's
VALUE_FRAME_ID entry.
However, the dwarf2-frame.c read_addr_from_reg routine will be called
during early unwinding (to unwind the frame's CFA), at which point the
frame's ID is not actually known yet! This would cause an assert.
On the other hand, we may notice that VALUE_FRAME_ID is only needed in the
value returned by value_from_register if that value is later used as an
lvalue. But this is obviously never done to the temporary value used in
address_from_register. So, if we could change address_from_register to
not call value_from_register but instead accept constructing a value
that doesn't have VALUE_FRAME_ID set, things should be fine.
To do that, we can change the value_from_register callback to accept
a FRAME_ID instead of a FRAME; the only existing uses of the FRAME
argument were either to extract its frame ID, or its gdbarch. (To
keep a way of getting at the latter, we also change the callback's
type from "f" to "m".) Together with the required follow-on changes
in the existing value_from_register implementations (including the
default one), this seems to fix the problem.
As another minor interface cleanup, I've removed the explicit TYPE
argument from address_from_register. This routine really always
uses a default pointer type, and in the new implementation it -to
some extent- relies on that fact, in that it will now no longer
handle types that require gdbarch_convert_register_p handling.
gdb:
2014-04-17 Ulrich Weigand <uweigand@de.ibm.com>
* gdbarch.sh (value_from_register): Make class "m" instead of "f".
Replace FRAME argument with FRAME_ID.
* gdbarch.c, gdbarch.h: Regenerate.
* findvar.c (default_value_from_register): Add GDBARCH argument;
replace FRAME by FRAME_ID. No longer call get_frame_id.
(value_from_register): Update call to gdbarch_value_from_register.
* value.h (default_value_from_register): Update prototype.
* s390-linux-tdep.c (s390_value_from_register): Update interface
and call to default_value_from_register.
* spu-tdep.c (spu_value_from_register): Likewise.
* findvar.c (address_from_register): Remove TYPE argument.
Do not call value_from_register; use gdbarch_value_from_register
with null_frame_id instead.
* value.h (address_from_register): Update prototype.
* dwarf2-frame.c (read_addr_from_reg): Use address_from_register.
* dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for
address_from_register interface change.
2014-04-17 14:01:39 +02:00
|
|
|
|
extern struct value *default_value_from_register (struct gdbarch *gdbarch,
|
|
|
|
|
struct type *type,
|
2007-01-08 20:03:49 +00:00
|
|
|
|
int regnum,
|
Use address_from_register in dwarf2-frame.c:read_addr_from_reg
This patch fixes a problem that prevented use of the Dwarf unwinders on SPU,
because dwarf2-frame.c common code did not support the situation where the
stack and/or frame pointer is maintained in a *vector* register. This is
because read_addr_from_reg is hard-coded to assume that such pointers can
be read from registers via a simple get_frame_register / unpack_pointer
operation.
Now, there *is* a routine address_from_register that calls into the
appropriate tdep routines to handle pointer values in "weird" registers
like on SPU, but it turns out I cannot simply change dwarf2-frame.c to
use address_from_register. This is because address_from_register uses
value_from_register to create a (temporary) value, and that routine
at some point calls get_frame_id in order to set up that value's
VALUE_FRAME_ID entry.
However, the dwarf2-frame.c read_addr_from_reg routine will be called
during early unwinding (to unwind the frame's CFA), at which point the
frame's ID is not actually known yet! This would cause an assert.
On the other hand, we may notice that VALUE_FRAME_ID is only needed in the
value returned by value_from_register if that value is later used as an
lvalue. But this is obviously never done to the temporary value used in
address_from_register. So, if we could change address_from_register to
not call value_from_register but instead accept constructing a value
that doesn't have VALUE_FRAME_ID set, things should be fine.
To do that, we can change the value_from_register callback to accept
a FRAME_ID instead of a FRAME; the only existing uses of the FRAME
argument were either to extract its frame ID, or its gdbarch. (To
keep a way of getting at the latter, we also change the callback's
type from "f" to "m".) Together with the required follow-on changes
in the existing value_from_register implementations (including the
default one), this seems to fix the problem.
As another minor interface cleanup, I've removed the explicit TYPE
argument from address_from_register. This routine really always
uses a default pointer type, and in the new implementation it -to
some extent- relies on that fact, in that it will now no longer
handle types that require gdbarch_convert_register_p handling.
gdb:
2014-04-17 Ulrich Weigand <uweigand@de.ibm.com>
* gdbarch.sh (value_from_register): Make class "m" instead of "f".
Replace FRAME argument with FRAME_ID.
* gdbarch.c, gdbarch.h: Regenerate.
* findvar.c (default_value_from_register): Add GDBARCH argument;
replace FRAME by FRAME_ID. No longer call get_frame_id.
(value_from_register): Update call to gdbarch_value_from_register.
* value.h (default_value_from_register): Update prototype.
* s390-linux-tdep.c (s390_value_from_register): Update interface
and call to default_value_from_register.
* spu-tdep.c (spu_value_from_register): Likewise.
* findvar.c (address_from_register): Remove TYPE argument.
Do not call value_from_register; use gdbarch_value_from_register
with null_frame_id instead.
* value.h (address_from_register): Update prototype.
* dwarf2-frame.c (read_addr_from_reg): Use address_from_register.
* dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for
address_from_register interface change.
2014-04-17 14:01:39 +02:00
|
|
|
|
struct frame_id frame_id);
|
2007-01-08 20:03:49 +00:00
|
|
|
|
|
2011-10-27 17:05:40 +00:00
|
|
|
|
extern void read_frame_register_value (struct value *value,
|
2022-07-25 14:06:35 -03:00
|
|
|
|
frame_info_ptr frame);
|
2011-10-27 17:05:40 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_from_register (struct type *type, int regnum,
|
2022-07-25 14:06:35 -03:00
|
|
|
|
frame_info_ptr frame);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
Use address_from_register in dwarf2-frame.c:read_addr_from_reg
This patch fixes a problem that prevented use of the Dwarf unwinders on SPU,
because dwarf2-frame.c common code did not support the situation where the
stack and/or frame pointer is maintained in a *vector* register. This is
because read_addr_from_reg is hard-coded to assume that such pointers can
be read from registers via a simple get_frame_register / unpack_pointer
operation.
Now, there *is* a routine address_from_register that calls into the
appropriate tdep routines to handle pointer values in "weird" registers
like on SPU, but it turns out I cannot simply change dwarf2-frame.c to
use address_from_register. This is because address_from_register uses
value_from_register to create a (temporary) value, and that routine
at some point calls get_frame_id in order to set up that value's
VALUE_FRAME_ID entry.
However, the dwarf2-frame.c read_addr_from_reg routine will be called
during early unwinding (to unwind the frame's CFA), at which point the
frame's ID is not actually known yet! This would cause an assert.
On the other hand, we may notice that VALUE_FRAME_ID is only needed in the
value returned by value_from_register if that value is later used as an
lvalue. But this is obviously never done to the temporary value used in
address_from_register. So, if we could change address_from_register to
not call value_from_register but instead accept constructing a value
that doesn't have VALUE_FRAME_ID set, things should be fine.
To do that, we can change the value_from_register callback to accept
a FRAME_ID instead of a FRAME; the only existing uses of the FRAME
argument were either to extract its frame ID, or its gdbarch. (To
keep a way of getting at the latter, we also change the callback's
type from "f" to "m".) Together with the required follow-on changes
in the existing value_from_register implementations (including the
default one), this seems to fix the problem.
As another minor interface cleanup, I've removed the explicit TYPE
argument from address_from_register. This routine really always
uses a default pointer type, and in the new implementation it -to
some extent- relies on that fact, in that it will now no longer
handle types that require gdbarch_convert_register_p handling.
gdb:
2014-04-17 Ulrich Weigand <uweigand@de.ibm.com>
* gdbarch.sh (value_from_register): Make class "m" instead of "f".
Replace FRAME argument with FRAME_ID.
* gdbarch.c, gdbarch.h: Regenerate.
* findvar.c (default_value_from_register): Add GDBARCH argument;
replace FRAME by FRAME_ID. No longer call get_frame_id.
(value_from_register): Update call to gdbarch_value_from_register.
* value.h (default_value_from_register): Update prototype.
* s390-linux-tdep.c (s390_value_from_register): Update interface
and call to default_value_from_register.
* spu-tdep.c (spu_value_from_register): Likewise.
* findvar.c (address_from_register): Remove TYPE argument.
Do not call value_from_register; use gdbarch_value_from_register
with null_frame_id instead.
* value.h (address_from_register): Update prototype.
* dwarf2-frame.c (read_addr_from_reg): Use address_from_register.
* dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for
address_from_register interface change.
2014-04-17 14:01:39 +02:00
|
|
|
|
extern CORE_ADDR address_from_register (int regnum,
|
2022-07-25 14:06:35 -03:00
|
|
|
|
frame_info_ptr frame);
|
2006-11-22 13:44:45 +00:00
|
|
|
|
|
2011-10-20 12:31:30 +00:00
|
|
|
|
extern struct value *value_of_variable (struct symbol *var,
|
|
|
|
|
const struct block *b);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
* ada-exp.y (write_object_renaming, write_var_or_type)
(write_ambiguous_var, write_var_from_sym): Make blocks const.
* ada-lang.c (replace_operator_with_call)
(find_old_style_renaming_symbol): Make blocks const.
* ada-lang.h (ada_find_renaming_symbol): Update.
(struct ada_symbol_info) <block>: Now const.
* breakpoint.c (watch_command_1): Update.
* breakpoint.h (struct watchpoint) <exp_valid_block,
cond_exp_valid_block>: Now const.
* c-exp.y (classify_inner_name, classify_name): Make block
argument const.
* expprint.c (print_subexp_standard) <OP_VAR_VALUE>: Make 'b'
const.
* expression.h (innermost_block, parse_exp_1): Update.
(union exp_element) <block>: Now const.
* gdbtypes.c (lookup_template_type, lookup_enum, lookup_union)
(lookup_struct): Make block argument const.
* gdbtypes.h (lookup_template_type): Update.
* go-exp.y (classify_name, classify_packaged_name)
(package_name_p): Make block argument const.
* objc-lang.c (lookup_struct_typedef): Make block argument const.
* objc-lang.h (lookup_struct_typedef): Update.
* parse.c (parse_exp_in_context, parse_exp_1)
(write_exp_elt_block): Make block arguments const.
(expression_context_block, innermost_block): Now const.
* parser-defs.h (write_exp_elt_block): Update.
(expression_context_block, innermost_block, block_found): Now
const.
* printcmd.c (struct display) <block>: Now const.
* symtab.h (lookup_struct, lookup_union, lookup_enum): Update.
* valops.c (address_of_variable): Make block argument const.
* value.h (value_of_variable): Update.
* varobj.c (struct varobj_root) <valid_block>: Now const.
2012-12-03 19:59:14 +00:00
|
|
|
|
extern struct value *address_of_variable (struct symbol *var,
|
|
|
|
|
const struct block *b);
|
2009-01-15 15:38:07 +00:00
|
|
|
|
|
2022-07-25 14:06:35 -03:00
|
|
|
|
extern struct value *value_of_register (int regnum, frame_info_ptr frame);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2022-07-25 14:06:35 -03:00
|
|
|
|
struct value *value_of_register_lazy (frame_info_ptr frame, int regnum);
|
2008-04-30 21:13:49 +00:00
|
|
|
|
|
PR python/20190 - compute TLS symbol without a frame
PR python/20190 arose from an exception I noticed when trying to use
the Python unwinder for Spider Monkey in Firefox.
The problem is that the unwinder wants to examine the value of a
thread-local variable. However, sympy_value rejects this because
symbol_read_needs_frame returns true for a TLS variable.
This problem arose once before, though in a different context:
https://sourceware.org/bugzilla/show_bug.cgi?id=11803
At the time Pedro and Daniel pointed out a simpler way to fix that bug
(see links in 20190 if you are interested); but for this new bug I
couldn't think of a similar fix and ended up implementing Daniel's
other suggestion:
https://sourceware.org/ml/gdb-patches/2010-07/msg00393.html
That is, this patch makes it possible to detect whether a symbol needs
a specific frame, or whether it just needs the inferior to have
registers.
Built and regtested on x86-64 Fedora 24.
2016-07-26 Tom Tromey <tom@tromey.com>
* symtab.c (register_symbol_computed_impl): Update.
PR python/20190:
* value.h (symbol_read_needs): Declare.
(symbol_read_needs_frame): Add comment.
* symtab.h (struct symbol_computed_ops) <read_variable>: Update
comment.
<get_symbol_read_needs>: Rename. Change return type.
* findvar.c (symbol_read_needs): New function.
(symbol_read_needs_frame): Rewrite.
(default_read_var_value): Use symbol_read_needs.
* dwarf2loc.c (struct symbol_needs_baton): Rename.
<needs>: Renamed from needs_frame. Changed type.
(needs_frame_read_addr_from_reg, symbol_needs_get_reg_value)
(symbol_needs_read_mem, symbol_needs_frame_base)
(symbol_needs_frame_cfa, symbol_needs_tls_address)
(symbol_needs_dwarf_call): Rename.
(needs_dwarf_reg_entry_value): Update.
(symbol_needs_ctx_funcs, dwarf2_loc_desc_get_symbol_read_needs):
Rename and update.
(locexpr_get_symbol_read_needs, loclist_symbol_needs): Likewise.
(dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update.
* defs.h (enum symbol_needs_kind): New.
2016-07-26 Tom Tromey <tom@tromey.com>
PR python/20190:
* gdb.threads/tls.exp (check_thread_local): Add python symbol
test.
2016-06-03 14:11:08 -06:00
|
|
|
|
/* Return the symbol's reading requirement. */
|
|
|
|
|
|
|
|
|
|
extern enum symbol_needs_kind symbol_read_needs (struct symbol *);
|
|
|
|
|
|
|
|
|
|
/* Return true if the symbol needs a frame. This is a wrapper for
|
|
|
|
|
symbol_read_needs that simply checks for SYMBOL_NEEDS_FRAME. */
|
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
extern int symbol_read_needs_frame (struct symbol *);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *read_var_value (struct symbol *var,
|
2015-02-05 17:00:06 +01:00
|
|
|
|
const struct block *var_block,
|
2022-07-25 14:06:35 -03:00
|
|
|
|
frame_info_ptr frame);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *allocate_repeat_value (struct type *type, int count);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_mark (void);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2016-04-08 15:05:45 -03:00
|
|
|
|
extern void value_free_to_mark (const struct value *mark);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
Add scoped_value_mark
This adds a scoped_value_mark class, that records the value mark in
the constructor and then calls value_free_to_mark in the destructor.
It then updates various spots in gdb to use this class, rather than a
cleanup.
It would be better overall to replace "struct value *" with a
shared_ptr, maybe eliminating the need for this class (watchpoints
would perhaps need some new mechanism as well). However, that's
difficult to do.
2017-01-10 Tom Tromey <tom@tromey.com>
* python/py-value.c (valpy_dereference, valpy_referenced_value)
(valpy_reference_value, valpy_const_value, valpy_get_address)
(valpy_get_dynamic_type, valpy_lazy_string, valpy_do_cast)
(valpy_getitem, valpy_call, valpy_binop_throw, valpy_negative)
(valpy_absolute, valpy_richcompare_throw): Use scoped_value_mark.
* dwarf2loc.c (dwarf2_loc_desc_get_symbol_read_needs): Use
scoped_value_mark.
* dwarf2-frame.c (execute_stack_op): Use scoped_value_mark.
* value.h (scoped_value_mark): New class.
2016-11-21 18:02:11 -07:00
|
|
|
|
/* A helper class that uses value_mark at construction time and calls
|
|
|
|
|
value_free_to_mark in the destructor. This is used to clear out
|
|
|
|
|
temporary values created during the lifetime of this object. */
|
|
|
|
|
class scoped_value_mark
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
scoped_value_mark ()
|
|
|
|
|
: m_value (value_mark ())
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~scoped_value_mark ()
|
|
|
|
|
{
|
2016-11-21 21:04:59 -07:00
|
|
|
|
free_to_mark ();
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-16 17:26:09 -06:00
|
|
|
|
scoped_value_mark (scoped_value_mark &&other) = default;
|
|
|
|
|
|
|
|
|
|
DISABLE_COPY_AND_ASSIGN (scoped_value_mark);
|
|
|
|
|
|
2016-11-21 21:04:59 -07:00
|
|
|
|
/* Free the values currently on the value stack. */
|
|
|
|
|
void free_to_mark ()
|
|
|
|
|
{
|
2023-05-25 11:14:15 +00:00
|
|
|
|
if (!m_freed)
|
2016-11-21 21:04:59 -07:00
|
|
|
|
{
|
|
|
|
|
value_free_to_mark (m_value);
|
2023-05-25 11:14:15 +00:00
|
|
|
|
m_freed = true;
|
2016-11-21 21:04:59 -07:00
|
|
|
|
}
|
Add scoped_value_mark
This adds a scoped_value_mark class, that records the value mark in
the constructor and then calls value_free_to_mark in the destructor.
It then updates various spots in gdb to use this class, rather than a
cleanup.
It would be better overall to replace "struct value *" with a
shared_ptr, maybe eliminating the need for this class (watchpoints
would perhaps need some new mechanism as well). However, that's
difficult to do.
2017-01-10 Tom Tromey <tom@tromey.com>
* python/py-value.c (valpy_dereference, valpy_referenced_value)
(valpy_reference_value, valpy_const_value, valpy_get_address)
(valpy_get_dynamic_type, valpy_lazy_string, valpy_do_cast)
(valpy_getitem, valpy_call, valpy_binop_throw, valpy_negative)
(valpy_absolute, valpy_richcompare_throw): Use scoped_value_mark.
* dwarf2loc.c (dwarf2_loc_desc_get_symbol_read_needs): Use
scoped_value_mark.
* dwarf2-frame.c (execute_stack_op): Use scoped_value_mark.
* value.h (scoped_value_mark): New class.
2016-11-21 18:02:11 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
const struct value *m_value;
|
2023-05-25 11:14:15 +00:00
|
|
|
|
bool m_freed = false;
|
Add scoped_value_mark
This adds a scoped_value_mark class, that records the value mark in
the constructor and then calls value_free_to_mark in the destructor.
It then updates various spots in gdb to use this class, rather than a
cleanup.
It would be better overall to replace "struct value *" with a
shared_ptr, maybe eliminating the need for this class (watchpoints
would perhaps need some new mechanism as well). However, that's
difficult to do.
2017-01-10 Tom Tromey <tom@tromey.com>
* python/py-value.c (valpy_dereference, valpy_referenced_value)
(valpy_reference_value, valpy_const_value, valpy_get_address)
(valpy_get_dynamic_type, valpy_lazy_string, valpy_do_cast)
(valpy_getitem, valpy_call, valpy_binop_throw, valpy_negative)
(valpy_absolute, valpy_richcompare_throw): Use scoped_value_mark.
* dwarf2loc.c (dwarf2_loc_desc_get_symbol_read_needs): Use
scoped_value_mark.
* dwarf2-frame.c (execute_stack_op): Use scoped_value_mark.
* value.h (scoped_value_mark): New class.
2016-11-21 18:02:11 -07:00
|
|
|
|
};
|
|
|
|
|
|
gdb: building inferior strings from within GDB
History Of This Patch
=====================
This commit aims to address PR gdb/21699. There have now been a
couple of attempts to fix this issue. Simon originally posted two
patches back in 2021:
https://sourceware.org/pipermail/gdb-patches/2021-July/180894.html
https://sourceware.org/pipermail/gdb-patches/2021-July/180896.html
Before Pedro then posted a version of his own:
https://sourceware.org/pipermail/gdb-patches/2021-July/180970.html
After this the conversation halted. Then in 2023 I (Andrew) also took
a look at this bug and posted two versions:
https://sourceware.org/pipermail/gdb-patches/2023-April/198570.html
https://sourceware.org/pipermail/gdb-patches/2023-April/198680.html
The approach taken in my first patch was pretty similar to what Simon
originally posted back in 2021. My second attempt was only a slight
variation on the first.
Pedro then pointed out his older patch, and so we arrive at this
patch. The GDB changes here are mostly Pedro's work, but updated by
me (Andrew), any mistakes are mine.
The tests here are a combinations of everyone's work, and the commit
message is new, but copies bits from everyone's earlier work.
Problem Description
===================
Bug PR gdb/21699 makes the observation that using $_as_string with
GDB's printf can cause GDB to print unexpected data from the
inferior. The reproducer is pretty simple:
#include <stddef.h>
static char arena[100];
/* Override malloc() so value_coerce_to_target() gets a known
pointer, and we know we"ll see an error if $_as_string() gives
a string that isn't null terminated. */
void
*malloc (size_t size)
{
memset (arena, 'x', sizeof (arena));
if (size > sizeof (arena))
return NULL;
return arena;
}
int
main ()
{
return 0;
}
And then in a GDB session:
$ gdb -q test
Reading symbols from /tmp/test...
(gdb) start
Temporary breakpoint 1 at 0x4004c8: file test.c, line 17.
Starting program: /tmp/test
Temporary breakpoint 1, main () at test.c:17
17 return 0;
(gdb) printf "%s\n", $_as_string("hello")
"hello"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
(gdb) quit
The problem above is caused by how value_cstring is used within
py-value.c, but once we understand the issue then it turns out that
value_cstring is used in an unexpected way in many places within GDB.
Within py-value.c we have a null-terminated C-style string. We then
pass a pointer to this string, along with the length of this
string (so not including the null-character) to value_cstring.
In value_cstring GDB allocates an array value of the given character
type, and copies in requested number of characters. However
value_cstring does not add a null-character of its own. This means
that the value created by calling value_cstring is only
null-terminated if the null-character is included in the passed in
length. In py-value.c this is not the case, and indeed, in most uses
of value_cstring, this is not the case.
When GDB tries to print one of these strings the value contents are
pushed to the inferior, and then read back as a C-style string, that
is, GDB reads inferior memory until it finds a null-terminator. For
the py-value.c case, no null-terminator is pushed into the inferior,
so GDB will continue reading inferior memory until a null-terminator
is found, with unpredictable results.
Patch Description
=================
The first thing this patch does is better define what the arguments
for the two function value_cstring and value_string should represent.
The comments in the header file are updated to describe whether the
length argument should, or should not, include a null-character.
Also, the data argument is changed to type gdb_byte. The functions as
they currently exist will handle wide-characters, in which case more
than one 'char' would be needed for each character. As such using
gdb_byte seems to make more sense.
To avoid adding casts throughout GDB, I've also added an overload that
still takes a 'char *', but asserts that the character type being used
is of size '1'.
The value_cstring function is now responsible for adding a null
character at the end of the string value it creates.
However, once we start looking at how value_cstring is used, we
realise there's another, related, problem. Not every language's
strings are null terminated. Fortran and Ada strings, for example,
are just an array of characters, GDB already has the function
value_string which can be used to create such values.
Consider this example using current GDB:
(gdb) set language ada
(gdb) p $_gdb_setting("arch")
$1 = (97, 117, 116, 111)
(gdb) ptype $
type = array (1 .. 4) of char
(gdb) p $_gdb_maint_setting("test-settings string")
$2 = (0)
(gdb) ptype $
type = array (1 .. 1) of char
This shows two problems, first, the $_gdb_setting and
$_gdb_maint_setting functions are calling value_cstring using the
builtin_char character, rather than a language appropriate type. In
the first call, the 'arch' case, the value_cstring call doesn't
include the null character, so the returned array only contains the
expected characters. But, in the $_gdb_maint_setting example we do
end up including the null-character, even though this is not expected
for Ada strings.
This commit adds a new language method language_defn::value_string,
this function takes a pointer and length and creates a language
appropriate value that represents the string. For C, C++, etc this
will be a null-terminated string (by calling value_cstring), and for
Fortran and Ada this can be a bounded array of characters with no null
terminator. Additionally, this new language_defn::value_string
function is responsible for selecting a language appropriate character
type.
After this commit the only calls to value_cstring are from the C
expression evaluator and from the default language_defn::value_string.
And the only calls to value_string are from Fortan, Ada, and ObjectC
related code.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21699
Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Co-Authored-By: Pedro Alves <pedro@palves.net>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2021-07-13 14:44:27 -04:00
|
|
|
|
/* Create not_lval value representing a NULL-terminated C string. The
|
|
|
|
|
resulting value has type TYPE_CODE_ARRAY. The string passed in should
|
|
|
|
|
not include embedded null characters.
|
|
|
|
|
|
|
|
|
|
PTR points to the string data; COUNT is number of characters (does
|
|
|
|
|
not include the NULL terminator) pointed to by PTR, each character is of
|
|
|
|
|
type (and size of) CHAR_TYPE. */
|
|
|
|
|
|
|
|
|
|
extern struct value *value_cstring (const gdb_byte *ptr, ssize_t count,
|
2009-06-17 18:47:35 +00:00
|
|
|
|
struct type *char_type);
|
gdb: building inferior strings from within GDB
History Of This Patch
=====================
This commit aims to address PR gdb/21699. There have now been a
couple of attempts to fix this issue. Simon originally posted two
patches back in 2021:
https://sourceware.org/pipermail/gdb-patches/2021-July/180894.html
https://sourceware.org/pipermail/gdb-patches/2021-July/180896.html
Before Pedro then posted a version of his own:
https://sourceware.org/pipermail/gdb-patches/2021-July/180970.html
After this the conversation halted. Then in 2023 I (Andrew) also took
a look at this bug and posted two versions:
https://sourceware.org/pipermail/gdb-patches/2023-April/198570.html
https://sourceware.org/pipermail/gdb-patches/2023-April/198680.html
The approach taken in my first patch was pretty similar to what Simon
originally posted back in 2021. My second attempt was only a slight
variation on the first.
Pedro then pointed out his older patch, and so we arrive at this
patch. The GDB changes here are mostly Pedro's work, but updated by
me (Andrew), any mistakes are mine.
The tests here are a combinations of everyone's work, and the commit
message is new, but copies bits from everyone's earlier work.
Problem Description
===================
Bug PR gdb/21699 makes the observation that using $_as_string with
GDB's printf can cause GDB to print unexpected data from the
inferior. The reproducer is pretty simple:
#include <stddef.h>
static char arena[100];
/* Override malloc() so value_coerce_to_target() gets a known
pointer, and we know we"ll see an error if $_as_string() gives
a string that isn't null terminated. */
void
*malloc (size_t size)
{
memset (arena, 'x', sizeof (arena));
if (size > sizeof (arena))
return NULL;
return arena;
}
int
main ()
{
return 0;
}
And then in a GDB session:
$ gdb -q test
Reading symbols from /tmp/test...
(gdb) start
Temporary breakpoint 1 at 0x4004c8: file test.c, line 17.
Starting program: /tmp/test
Temporary breakpoint 1, main () at test.c:17
17 return 0;
(gdb) printf "%s\n", $_as_string("hello")
"hello"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
(gdb) quit
The problem above is caused by how value_cstring is used within
py-value.c, but once we understand the issue then it turns out that
value_cstring is used in an unexpected way in many places within GDB.
Within py-value.c we have a null-terminated C-style string. We then
pass a pointer to this string, along with the length of this
string (so not including the null-character) to value_cstring.
In value_cstring GDB allocates an array value of the given character
type, and copies in requested number of characters. However
value_cstring does not add a null-character of its own. This means
that the value created by calling value_cstring is only
null-terminated if the null-character is included in the passed in
length. In py-value.c this is not the case, and indeed, in most uses
of value_cstring, this is not the case.
When GDB tries to print one of these strings the value contents are
pushed to the inferior, and then read back as a C-style string, that
is, GDB reads inferior memory until it finds a null-terminator. For
the py-value.c case, no null-terminator is pushed into the inferior,
so GDB will continue reading inferior memory until a null-terminator
is found, with unpredictable results.
Patch Description
=================
The first thing this patch does is better define what the arguments
for the two function value_cstring and value_string should represent.
The comments in the header file are updated to describe whether the
length argument should, or should not, include a null-character.
Also, the data argument is changed to type gdb_byte. The functions as
they currently exist will handle wide-characters, in which case more
than one 'char' would be needed for each character. As such using
gdb_byte seems to make more sense.
To avoid adding casts throughout GDB, I've also added an overload that
still takes a 'char *', but asserts that the character type being used
is of size '1'.
The value_cstring function is now responsible for adding a null
character at the end of the string value it creates.
However, once we start looking at how value_cstring is used, we
realise there's another, related, problem. Not every language's
strings are null terminated. Fortran and Ada strings, for example,
are just an array of characters, GDB already has the function
value_string which can be used to create such values.
Consider this example using current GDB:
(gdb) set language ada
(gdb) p $_gdb_setting("arch")
$1 = (97, 117, 116, 111)
(gdb) ptype $
type = array (1 .. 4) of char
(gdb) p $_gdb_maint_setting("test-settings string")
$2 = (0)
(gdb) ptype $
type = array (1 .. 1) of char
This shows two problems, first, the $_gdb_setting and
$_gdb_maint_setting functions are calling value_cstring using the
builtin_char character, rather than a language appropriate type. In
the first call, the 'arch' case, the value_cstring call doesn't
include the null character, so the returned array only contains the
expected characters. But, in the $_gdb_maint_setting example we do
end up including the null-character, even though this is not expected
for Ada strings.
This commit adds a new language method language_defn::value_string,
this function takes a pointer and length and creates a language
appropriate value that represents the string. For C, C++, etc this
will be a null-terminated string (by calling value_cstring), and for
Fortran and Ada this can be a bounded array of characters with no null
terminator. Additionally, this new language_defn::value_string
function is responsible for selecting a language appropriate character
type.
After this commit the only calls to value_cstring are from the C
expression evaluator and from the default language_defn::value_string.
And the only calls to value_string are from Fortan, Ada, and ObjectC
related code.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21699
Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Co-Authored-By: Pedro Alves <pedro@palves.net>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2021-07-13 14:44:27 -04:00
|
|
|
|
|
|
|
|
|
/* Specialisation of value_cstring above. In this case PTR points to
|
|
|
|
|
single byte characters. CHAR_TYPE must have a length of 1. */
|
|
|
|
|
inline struct value *value_cstring (const char *ptr, ssize_t count,
|
|
|
|
|
struct type *char_type)
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (char_type->length () == 1);
|
|
|
|
|
return value_cstring ((const gdb_byte *) ptr, count, char_type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create a not_lval value with type TYPE_CODE_STRING, the resulting value
|
|
|
|
|
has type TYPE_CODE_STRING.
|
|
|
|
|
|
|
|
|
|
PTR points to the string data; COUNT is number of characters pointed to
|
|
|
|
|
by PTR, each character has the type (and size of) CHAR_TYPE.
|
|
|
|
|
|
|
|
|
|
Note that string types are like array of char types with a lower bound
|
|
|
|
|
defined by the language (usually zero or one). Also the string may
|
|
|
|
|
contain embedded null characters. */
|
|
|
|
|
|
|
|
|
|
extern struct value *value_string (const gdb_byte *ptr, ssize_t count,
|
2009-06-17 18:47:35 +00:00
|
|
|
|
struct type *char_type);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
gdb: building inferior strings from within GDB
History Of This Patch
=====================
This commit aims to address PR gdb/21699. There have now been a
couple of attempts to fix this issue. Simon originally posted two
patches back in 2021:
https://sourceware.org/pipermail/gdb-patches/2021-July/180894.html
https://sourceware.org/pipermail/gdb-patches/2021-July/180896.html
Before Pedro then posted a version of his own:
https://sourceware.org/pipermail/gdb-patches/2021-July/180970.html
After this the conversation halted. Then in 2023 I (Andrew) also took
a look at this bug and posted two versions:
https://sourceware.org/pipermail/gdb-patches/2023-April/198570.html
https://sourceware.org/pipermail/gdb-patches/2023-April/198680.html
The approach taken in my first patch was pretty similar to what Simon
originally posted back in 2021. My second attempt was only a slight
variation on the first.
Pedro then pointed out his older patch, and so we arrive at this
patch. The GDB changes here are mostly Pedro's work, but updated by
me (Andrew), any mistakes are mine.
The tests here are a combinations of everyone's work, and the commit
message is new, but copies bits from everyone's earlier work.
Problem Description
===================
Bug PR gdb/21699 makes the observation that using $_as_string with
GDB's printf can cause GDB to print unexpected data from the
inferior. The reproducer is pretty simple:
#include <stddef.h>
static char arena[100];
/* Override malloc() so value_coerce_to_target() gets a known
pointer, and we know we"ll see an error if $_as_string() gives
a string that isn't null terminated. */
void
*malloc (size_t size)
{
memset (arena, 'x', sizeof (arena));
if (size > sizeof (arena))
return NULL;
return arena;
}
int
main ()
{
return 0;
}
And then in a GDB session:
$ gdb -q test
Reading symbols from /tmp/test...
(gdb) start
Temporary breakpoint 1 at 0x4004c8: file test.c, line 17.
Starting program: /tmp/test
Temporary breakpoint 1, main () at test.c:17
17 return 0;
(gdb) printf "%s\n", $_as_string("hello")
"hello"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
(gdb) quit
The problem above is caused by how value_cstring is used within
py-value.c, but once we understand the issue then it turns out that
value_cstring is used in an unexpected way in many places within GDB.
Within py-value.c we have a null-terminated C-style string. We then
pass a pointer to this string, along with the length of this
string (so not including the null-character) to value_cstring.
In value_cstring GDB allocates an array value of the given character
type, and copies in requested number of characters. However
value_cstring does not add a null-character of its own. This means
that the value created by calling value_cstring is only
null-terminated if the null-character is included in the passed in
length. In py-value.c this is not the case, and indeed, in most uses
of value_cstring, this is not the case.
When GDB tries to print one of these strings the value contents are
pushed to the inferior, and then read back as a C-style string, that
is, GDB reads inferior memory until it finds a null-terminator. For
the py-value.c case, no null-terminator is pushed into the inferior,
so GDB will continue reading inferior memory until a null-terminator
is found, with unpredictable results.
Patch Description
=================
The first thing this patch does is better define what the arguments
for the two function value_cstring and value_string should represent.
The comments in the header file are updated to describe whether the
length argument should, or should not, include a null-character.
Also, the data argument is changed to type gdb_byte. The functions as
they currently exist will handle wide-characters, in which case more
than one 'char' would be needed for each character. As such using
gdb_byte seems to make more sense.
To avoid adding casts throughout GDB, I've also added an overload that
still takes a 'char *', but asserts that the character type being used
is of size '1'.
The value_cstring function is now responsible for adding a null
character at the end of the string value it creates.
However, once we start looking at how value_cstring is used, we
realise there's another, related, problem. Not every language's
strings are null terminated. Fortran and Ada strings, for example,
are just an array of characters, GDB already has the function
value_string which can be used to create such values.
Consider this example using current GDB:
(gdb) set language ada
(gdb) p $_gdb_setting("arch")
$1 = (97, 117, 116, 111)
(gdb) ptype $
type = array (1 .. 4) of char
(gdb) p $_gdb_maint_setting("test-settings string")
$2 = (0)
(gdb) ptype $
type = array (1 .. 1) of char
This shows two problems, first, the $_gdb_setting and
$_gdb_maint_setting functions are calling value_cstring using the
builtin_char character, rather than a language appropriate type. In
the first call, the 'arch' case, the value_cstring call doesn't
include the null character, so the returned array only contains the
expected characters. But, in the $_gdb_maint_setting example we do
end up including the null-character, even though this is not expected
for Ada strings.
This commit adds a new language method language_defn::value_string,
this function takes a pointer and length and creates a language
appropriate value that represents the string. For C, C++, etc this
will be a null-terminated string (by calling value_cstring), and for
Fortran and Ada this can be a bounded array of characters with no null
terminator. Additionally, this new language_defn::value_string
function is responsible for selecting a language appropriate character
type.
After this commit the only calls to value_cstring are from the C
expression evaluator and from the default language_defn::value_string.
And the only calls to value_string are from Fortan, Ada, and ObjectC
related code.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21699
Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Co-Authored-By: Pedro Alves <pedro@palves.net>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2021-07-13 14:44:27 -04:00
|
|
|
|
/* Specialisation of value_string above. In this case PTR points to
|
|
|
|
|
single byte characters. CHAR_TYPE must have a length of 1. */
|
|
|
|
|
inline struct value *value_string (const char *ptr, ssize_t count,
|
|
|
|
|
struct type *char_type)
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (char_type->length () == 1);
|
|
|
|
|
return value_string ((const gdb_byte *) ptr, count, char_type);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-29 09:14:01 -06:00
|
|
|
|
extern struct value *value_array (int lowbound,
|
2023-08-28 12:40:35 -06:00
|
|
|
|
gdb::array_view<struct value *> elemvec);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_concat (struct value *arg1, struct value *arg2);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_binop (struct value *arg1, struct value *arg2,
|
|
|
|
|
enum exp_opcode op);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
* value.h (value_subscript, value_subscripted_rvalue,
value_bitstring_subscript, value_ptradd): Use LONGEST instead
of value as type of the index argument.
(value_ptrsub): Remove.
* valarith.c (value_subscript, value_subscripted_rvalue,
value_bitstring_subscript, value_ptradd): Use LONGEST instead
of value as type of the index argument.
(value_ptrsub): Remove.
* wrapper.h (gdb_value_subscript): Use LONGEST instead of
value as type of the index argument.
* wrapper.c (gdb_value_subscript): Likewise.
Update calls to gdb_value_subscript, value_subscript,
value_subscripted_rvalue, value_bitstring_subscript and
value_ptradd to use LONGEST instead of value as index
argument type. Use value_ptradd instead of value_ptrsub.
* ada-lang.c (ada_value_subscript, ada_value_ptr_subscript,
ada_tag_name_2): Update.
* ada-tasks.c (read_atcb): Update.
* eval.c (evaluate_subexp_standard): Update.
* valarith.c (value_subscript): Update.
* gnu-v2-abi.c (gnuv2_virtual_fn_field): Update.
* gnu-v3-abi.c (gnuv3_get_virtual_fn, gnuv3_baseclass_offset,
gnuv3_method_ptr_to_value): Update.
* jv-lang.c (evaluate_subexp_java): Update.
* m2-lang.c (evaluate_subexp_modula2): Update.
* python/python-value.c (valpy_getitem, valpy_binop): Update.
* wrapper.c (gdb_value_subscript): Update.
* varobj.c (c_describe_child): Update.
2009-06-29 13:24:41 +00:00
|
|
|
|
extern struct value *value_ptradd (struct value *arg1, LONGEST arg2);
|
* value.h (value_add, value_sub): Remove.
(value_ptradd, value_ptrsub, value_ptrdiff): Add prototypes.
* valarith.c (value_add, value_sub): Remove.
(value_ptradd, value_ptrsub, value_ptrdiff): New functions.
(find_size_for_pointer_math): Add assertion. Update comment.
(value_binop): Update comment.
* eval.c (ptrmath_type_p): New function.
(evaluate_subexp_standard): Replace value_add and value_sub
by value_ptradd, value_ptrsub, value_ptrdiff or value_binop.
Use builtin_type_uint8 instead of builtin_type_char to hold
the increment for BINOP_{PRE,POST}{IN,DE}CREMENT operations.
* valarith.c (value_subscript): Replace value_add by
value_ptradd. Replace value_sub by value_binop.
* ada-lang.c (ada_value_ptr_subscript): Likewise.
(ada_tag_name_2): Replace value_add by value_ptradd.
(ada_evaluate_subexp): Replace value_add and value_sub by
value_binop.
* m2-lang.c (evaluate_subexp_modula2): Replace value_add
by value_ptradd.
* gnu-v2-abi.c (gnuv2_virtual_fn_field): Likewise.
* gnu-v3-abi.c (gnuv3_method_ptr_to_value): Likewise.
2008-09-11 14:13:46 +00:00
|
|
|
|
|
|
|
|
|
extern LONGEST value_ptrdiff (struct value *arg1, struct value *arg2);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2019-07-10 21:49:32 -04:00
|
|
|
|
/* Return true if VAL does not live in target memory, but should in order
|
|
|
|
|
to operate on it. Otherwise return false. */
|
|
|
|
|
|
|
|
|
|
extern bool value_must_coerce_to_target (struct value *arg1);
|
2008-03-21 15:02:38 +00:00
|
|
|
|
|
|
|
|
|
extern struct value *value_coerce_to_target (struct value *arg1);
|
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_coerce_array (struct value *arg1);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_coerce_function (struct value *arg1);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_ind (struct value *arg1);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_addr (struct value *arg1);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2017-03-20 13:47:41 -07:00
|
|
|
|
extern struct value *value_ref (struct value *arg1, enum type_code refcode);
|
2006-07-13 04:31:42 +00:00
|
|
|
|
|
2005-01-27 16:45:09 +00:00
|
|
|
|
extern struct value *value_assign (struct value *toval,
|
|
|
|
|
struct value *fromval);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2023-03-01 14:29:28 -07:00
|
|
|
|
/* The unary + operation. */
|
2005-03-08 14:35:20 +00:00
|
|
|
|
extern struct value *value_pos (struct value *arg1);
|
|
|
|
|
|
2023-03-01 14:29:28 -07:00
|
|
|
|
/* The unary - operation. */
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_neg (struct value *arg1);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2023-03-01 14:29:28 -07:00
|
|
|
|
/* The unary ~ operation -- but note that it also implements the GCC
|
|
|
|
|
extension, where ~ of a complex number is the complex
|
|
|
|
|
conjugate. */
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_complement (struct value *arg1);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_struct_elt (struct value **argp,
|
2021-06-22 19:27:53 +01:00
|
|
|
|
gdb::optional<gdb::array_view <value *>> args,
|
2010-02-08 20:55:43 +00:00
|
|
|
|
const char *name, int *static_memfuncp,
|
|
|
|
|
const char *err);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2013-12-27 12:20:59 -08:00
|
|
|
|
extern struct value *value_struct_elt_bitpos (struct value **argp,
|
|
|
|
|
int bitpos,
|
|
|
|
|
struct type *field_type,
|
|
|
|
|
const char *err);
|
|
|
|
|
|
2003-09-25 16:39:39 +00:00
|
|
|
|
extern struct value *value_aggregate_elt (struct type *curtype,
|
2014-03-27 12:16:38 -06:00
|
|
|
|
const char *name,
|
2009-11-10 22:17:58 +00:00
|
|
|
|
struct type *expect_type,
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 18:05:45 +00:00
|
|
|
|
int want_address,
|
|
|
|
|
enum noside noside);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_static_field (struct type *type, int fieldno);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2010-06-07 16:11:35 +00:00
|
|
|
|
enum oload_search_type { NON_METHOD, METHOD, BOTH };
|
|
|
|
|
|
invoke_xmethod & array_view
This replaces more pointer+length with gdb::array_view. This time,
around invoke_xmethod, and then propagating the fallout around, which
inevitably leaks to the overload resolution code.
There are several places in the code that want to grab a slice of an
array, by advancing the array pointer, and decreasing the length
pointer. This patch introduces a pair of new
gdb::array_view::slice(...) methods to make that convenient and clear.
Unit test included.
gdb/ChangeLog:
2018-11-21 Pedro Alves <palves@redhat.com>
* common/array-view.h (array_view::splice(size_type, size_t)): New.
(array_view::splice(size_type)): New.
* eval.c (eval_call, evaluate_funcall): Adjust to use array_view.
* extension.c (xmethod_worker::get_arg_types): Adjust to return an
std::vector.
(xmethod_worker::get_result_type): Adjust to use gdb::array_view.
* extension.h: Include "common/array-view.h".
(xmethod_worker::invoke): Adjust to use gdb::array_view.
(xmethod_worker::get_arg_types): Adjust to return an std::vector.
(xmethod_worker::get_result_type): Adjust to use gdb::array_view.
(xmethod_worker::do_get_arg_types): Adjust to use std::vector.
(xmethod_worker::do_get_result_type): Adjust to use
gdb::array_view.
* gdbtypes.c (rank_function): Adjust to use gdb::array_view.
* gdbtypes.h: Include "common/array-view.h".
(rank_function): Adjust to use gdb::array_view.
* python/py-xmethods.c (python_xmethod_worker::invoke)
(python_xmethod_worker::do_get_arg_types)
(python_xmethod_worker::do_get_result_type)
(python_xmethod_worker::invoke): Adjust to new interfaces.
* valarith.c (value_user_defined_cpp_op, value_user_defined_op)
(value_x_binop, value_x_unop): Adjust to use gdb::array_view.
* valops.c (find_overload_match, find_oload_champ_namespace)
(find_oload_champ_namespace_loop, find_oload_champ): Adjust to use
gdb:array_view and the new xmethod_worker interfaces.
* value.c (result_type_of_xmethod, call_xmethod): Adjust to use
gdb::array_view.
* value.h (find_overload_match, result_type_of_xmethod)
(call_xmethod): Adjust to use gdb::array_view.
* unittests/array-view-selftests.c: Add slicing tests.
2018-11-21 11:55:12 +00:00
|
|
|
|
extern int find_overload_match (gdb::array_view<value *> args,
|
2010-06-07 16:11:35 +00:00
|
|
|
|
const char *name,
|
2013-01-25 22:31:43 +00:00
|
|
|
|
enum oload_search_type method,
|
2002-01-04 17:51:38 +00:00
|
|
|
|
struct value **objp, struct symbol *fsym,
|
2002-01-04 05:20:09 +00:00
|
|
|
|
struct value **valp, struct symbol **symp,
|
2014-07-09 10:25:48 -07:00
|
|
|
|
int *staticp, const int no_adl,
|
|
|
|
|
enum noside noside);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_field (struct value *arg1, int fieldno);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2016-04-12 15:02:57 -04:00
|
|
|
|
extern struct type *value_rtti_indirect_type (struct value *, int *, LONGEST *,
|
2012-02-21 13:48:59 +00:00
|
|
|
|
int *);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_full_object (struct value *, struct type *, int,
|
|
|
|
|
int, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2012-05-21 19:47:54 +00:00
|
|
|
|
extern struct value *value_cast_pointers (struct type *, struct value *, int);
|
2006-07-13 04:31:42 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_cast (struct type *type, struct value *arg2);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2010-01-18 20:54:35 +00:00
|
|
|
|
extern struct value *value_reinterpret_cast (struct type *type,
|
|
|
|
|
struct value *arg);
|
|
|
|
|
|
|
|
|
|
extern struct value *value_dynamic_cast (struct type *type, struct value *arg);
|
|
|
|
|
|
2011-07-27 19:31:30 +00:00
|
|
|
|
extern struct value *value_one (struct type *type);
|
2008-02-04 00:23:05 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_repeat (struct value *arg1, int count);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
* value.h (value_subscript, value_subscripted_rvalue,
value_bitstring_subscript, value_ptradd): Use LONGEST instead
of value as type of the index argument.
(value_ptrsub): Remove.
* valarith.c (value_subscript, value_subscripted_rvalue,
value_bitstring_subscript, value_ptradd): Use LONGEST instead
of value as type of the index argument.
(value_ptrsub): Remove.
* wrapper.h (gdb_value_subscript): Use LONGEST instead of
value as type of the index argument.
* wrapper.c (gdb_value_subscript): Likewise.
Update calls to gdb_value_subscript, value_subscript,
value_subscripted_rvalue, value_bitstring_subscript and
value_ptradd to use LONGEST instead of value as index
argument type. Use value_ptradd instead of value_ptrsub.
* ada-lang.c (ada_value_subscript, ada_value_ptr_subscript,
ada_tag_name_2): Update.
* ada-tasks.c (read_atcb): Update.
* eval.c (evaluate_subexp_standard): Update.
* valarith.c (value_subscript): Update.
* gnu-v2-abi.c (gnuv2_virtual_fn_field): Update.
* gnu-v3-abi.c (gnuv3_get_virtual_fn, gnuv3_baseclass_offset,
gnuv3_method_ptr_to_value): Update.
* jv-lang.c (evaluate_subexp_java): Update.
* m2-lang.c (evaluate_subexp_modula2): Update.
* python/python-value.c (valpy_getitem, valpy_binop): Update.
* wrapper.c (gdb_value_subscript): Update.
* varobj.c (c_describe_child): Update.
2009-06-29 13:24:41 +00:00
|
|
|
|
extern struct value *value_subscript (struct value *array, LONGEST index);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2023-08-07 06:35:51 -06:00
|
|
|
|
/* Assuming VAL is array-like (see type::is_array_like), return an
|
|
|
|
|
array form of VAL. */
|
|
|
|
|
extern struct value *value_to_array (struct value *val);
|
|
|
|
|
|
2008-09-11 14:10:24 +00:00
|
|
|
|
extern struct value *value_bitstring_subscript (struct type *type,
|
|
|
|
|
struct value *bitstring,
|
* value.h (value_subscript, value_subscripted_rvalue,
value_bitstring_subscript, value_ptradd): Use LONGEST instead
of value as type of the index argument.
(value_ptrsub): Remove.
* valarith.c (value_subscript, value_subscripted_rvalue,
value_bitstring_subscript, value_ptradd): Use LONGEST instead
of value as type of the index argument.
(value_ptrsub): Remove.
* wrapper.h (gdb_value_subscript): Use LONGEST instead of
value as type of the index argument.
* wrapper.c (gdb_value_subscript): Likewise.
Update calls to gdb_value_subscript, value_subscript,
value_subscripted_rvalue, value_bitstring_subscript and
value_ptradd to use LONGEST instead of value as index
argument type. Use value_ptradd instead of value_ptrsub.
* ada-lang.c (ada_value_subscript, ada_value_ptr_subscript,
ada_tag_name_2): Update.
* ada-tasks.c (read_atcb): Update.
* eval.c (evaluate_subexp_standard): Update.
* valarith.c (value_subscript): Update.
* gnu-v2-abi.c (gnuv2_virtual_fn_field): Update.
* gnu-v3-abi.c (gnuv3_get_virtual_fn, gnuv3_baseclass_offset,
gnuv3_method_ptr_to_value): Update.
* jv-lang.c (evaluate_subexp_java): Update.
* m2-lang.c (evaluate_subexp_modula2): Update.
* python/python-value.c (valpy_getitem, valpy_binop): Update.
* wrapper.c (gdb_value_subscript): Update.
* varobj.c (c_describe_child): Update.
2009-06-29 13:24:41 +00:00
|
|
|
|
LONGEST index);
|
2008-09-11 14:10:24 +00:00
|
|
|
|
|
2003-10-02 04:40:58 +00:00
|
|
|
|
extern struct value *register_value_being_returned (struct type *valtype,
|
|
|
|
|
struct regcache *retbuf);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2005-05-09 Andrew Cagney <cagney@gnu.org>
Use gdb_byte in preference to bfd_byte.
* gdbarch.sh: Update.
* gdbarch.h, gdbarch.c: Re-generate.
* ada-lang.c, ada-lang.h, ada-valprint.c, arch-utils.c: Update.
* c-lang.c, c-lang.h, c-valprint.c, cp-valprint.c: Update.
* f-lang.c, f-lang.h, f-valprint.c, gdbcore.h, jv-lang.h: Update.
* jv-valprint.c, language.c, language.h, m2-lang.c: Update.
* m2-lang.h, m2-valprint.c, objc-lang.c, p-lang.c: Update.
* p-lang.h, p-valprint.c, regcache.c, scm-lang.c: Update.
* scm-lang.h, scm-valprint.c, target.c, target.h: Update.
* tramp-frame.c, valarith.c, valops.c, valprint.c: Update.
* valprint.h, value.c, value.h: Update.
2005-05-09 21:20:35 +00:00
|
|
|
|
extern int value_bit_index (struct type *type, const gdb_byte *addr,
|
2005-01-28 16:45:16 +00:00
|
|
|
|
int index);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2013-02-06 19:40:04 +00:00
|
|
|
|
extern enum return_value_convention
|
|
|
|
|
struct_return_convention (struct gdbarch *gdbarch, struct value *function,
|
|
|
|
|
struct type *value_type);
|
|
|
|
|
|
2009-06-17 18:43:24 +00:00
|
|
|
|
extern int using_struct_return (struct gdbarch *gdbarch,
|
2012-05-16 14:35:09 +00:00
|
|
|
|
struct value *function,
|
2008-04-22 11:03:42 +00:00
|
|
|
|
struct type *value_type);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
(Ada) fix handling of minimal symbols (UNOP_CAST and UNOP_ADDR)
Consider a program which provides a symbol without debugging
information. For instance, compiling the following code without -g:
Some_Minimal_Symbol : Integer := 1234;
pragma Export (C, Some_Minimal_Symbol, "some_minsym");
Trying to print this variable with GDB now causes an error, which
is now expected:
(gdb) p some_minsym
'some_minsym' has unknown type; cast it to its declared type
However, trying to cast this symbol, or to take its address
does not work:
(gdb) p integer(some_minsym)
'some_minsym' has unknown type; cast it to its declared type
(gdb) p &some_minsym
'some_minsym' has unknown type; cast it to its declared type
Another manisfestation of this issue can be seen when trying to
insert an Ada exception catchpoint for a specific standard exception
(this only occurs if the Ada runtime is built without debugging
information, which is the default). For instance:
$ (gdb) catch exception constraint_error
warning: failed to reevaluate internal exception condition for catchpoint 0: 'constraint_error' has unknown type; cast it to its declared type
This is because, internally, the cachtpoint uses a condition referencing
a minimal symbol, more precisely:
long_integer (e) = long_integer (&constraint_error)
This patch fixes all issues listed above:
1. resolve_subexp: Special-case the handling of OP_VAR_MSYM_VALUE
expression elements, where there are no ambiguities to be resolved
in that situation;
2. ada_evaluate_subexp: Enhance the handling of the UNOP_CAST
handling so as to process the case where the target of
the cast is a minimal symbol (as well as a symbol with debugging
information). This mimics what's done in C.
gdb/ChangeLog:
* ada-lang.c (resolve_subexp): Add handling of OP_VAR_MSYM_VALUE.
(ada_evaluate_subexp_for_cast): New function.
(ada_evaluate_subexp) <UNOP_CAST>: Replace code by call to
ada_evaluate_subexp_for_cast.
(ada_evaluate_subexp) <nosideret>: Replace code by call to
eval_skip_value.
* eval.c (evaluate_var_value): Make non-static.
(evaluate_var_msym_value, eval_skip_value): Likewise.
* value.h (evaluate_var_value, evaluate_var_msym_value)
(eval_skip_value): Declare.
gdb/testsuite/ChangeLog:
* gdb.ada/minsyms: New testcase.
Tested on x86_64-linux. No regression. Fixes the following failures:
catch_ex.exp: continuing to Program_Error exception
catch_ex.exp: continuing to failed assertion
catch_ex.exp: continuing to unhandled exception
catch_ex.exp: continuing to program completion
complete.exp: p <Exported_Capitalized>
complete.exp: p Exported_Capitalized
complete.exp: p exported_capitalized
mi_catch_ex.exp: catch Program_Error (unexpected output)
mi_catch_ex.exp: continue to exception catchpoint hit (unknown output after running)
mi_catch_ex.exp: continue to assert failure catchpoint hit (unknown output after running)
mi_catch_ex.exp: continue to unhandled exception catchpoint hit (unknown output after running)
mi_ex_cond.exp: catch C_E if i = 2 (unexpected output)
2017-11-15 19:02:33 -05:00
|
|
|
|
extern value *evaluate_var_value (enum noside noside, const block *blk,
|
|
|
|
|
symbol *var);
|
|
|
|
|
|
|
|
|
|
extern value *evaluate_var_msym_value (enum noside noside,
|
|
|
|
|
struct objfile *objfile,
|
|
|
|
|
minimal_symbol *msymbol);
|
|
|
|
|
|
Add an expr::operation_up to struct expression
This adds an expr::operation_up to struct expression, and then
modifies various parts of GDB to use this member when it is non-null.
The list of such spots was a bit surprising to me, and found only
after writing most of the code and then noticing what no longer
compiled.
In a few spots, new accessor methods are added to operation
subclasses, so that code that dissects an expression will work with
the new scheme.
After this change, code that constructs an expression can be switched
to the new form without breaking.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* ada-exp.h (class ada_var_value_operation) <get_symbol>: Remove;
now in superclass.
* value.h (fetch_subexp_value): Add "op" parameter.
* value.c (init_if_undefined_command): Update.
* tracepoint.c (validate_actionline, encode_actions_1): Update.
* stap-probe.c (stap_probe::compile_to_ax): Update.
* printcmd.c (set_command): Update.
* ppc-linux-nat.c (ppc_linux_nat_target::check_condition):
Update.
* parser-defs.h (struct expr_builder) <set_operation>: New
method.
* parse.c (parse_exp_in_context, exp_uses_objfile): Update.
* expression.h (struct expression) <first_opcode>: Update.
<op>: New member.
* expprint.c (dump_raw_expression, dump_prefix_expression):
Update.
* expop.h (class var_value_operation) <get_symbol>: New method.
(class register_operation) <get_name>: New method.
(class equal_operation): No longer a typedef, now a subclass.
(class unop_memval_operation) <get_type>: New method.
(class assign_operation) <get_lhs>: New method.
(class unop_cast_operation) <get_type>: New method.
* eval.c (evaluate_expression, evaluate_type)
(evaluate_subexpression_type): Update.
(fetch_subexp_value): Add "op" parameter.
(parse_and_eval_type): Update.
* dtrace-probe.c (dtrace_probe::compile_to_ax): Update.
* breakpoint.c (update_watchpoint, watchpoint_check)
(watchpoint_exp_is_const, watch_command_1): Update.
* ax-gdb.c (gen_trace_for_expr, gen_eval_for_expr, gen_printf):
Update.
2021-03-08 07:27:57 -07:00
|
|
|
|
namespace expr { class operation; };
|
Remove union exp_element
This removes union exp_element functions that either create such
elements or walk them. struct expression no longer holds
exp_elements. A couple of language_defn methods are also removed, as
they are obsolete.
Note that this patch also removes the print_expression code. The only
in-tree caller of this was from dump_prefix_expression, which is only
called when expression debugging is enabled. Implementing this would
involve a fair amount of code, and it seems to me that prefix dumping
is preferable anyway, as it is unambiguous. So, I have not
reimplemented this feature.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* value.h (evaluate_subexp_with_coercion): Don't declare.
* parse.c (exp_descriptor_standard): Remove.
(expr_builder::expr_builder, expr_builder::release): Update.
(expression::expression): Remove size_t parameter.
(expression::~expression): Simplify.
(expression::resize): Remove.
(write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym)
(write_exp_elt_msym, write_exp_elt_block, write_exp_elt_objfile)
(write_exp_elt_longcst, write_exp_elt_floatcst)
(write_exp_elt_type, write_exp_elt_intern, write_exp_string)
(write_exp_string_vector, write_exp_bitstring): Remove.
* p-lang.h (class pascal_language) <opcode_print_table,
op_print_tab>: Remove.
* p-lang.c (pascal_language::op_print_tab): Remove.
* opencl-lang.c (class opencl_language) <opcode_print_table>:
Remove.
* objc-lang.c (objc_op_print_tab): Remove.
(class objc_language) <opcode_print_table>: Remove.
* m2-lang.h (class m2_language) <opcode_print_table,
op_print_tab>: Remove.
* m2-lang.c (m2_language::op_print_tab): Remove.
* language.h (struct language_defn) <post_parser, expression_ops,
opcode_print_table>: Remove.
* language.c (language_defn::expression_ops)
(auto_or_unknown_language::opcode_print_table): Remove.
* go-lang.h (class go_language) <opcode_print_table,
op_print_tab>: Remove.
* go-lang.c (go_language::op_print_tab): Remove.
* f-lang.h (class f_language) <opcode_print_table>: Remove
<op_print_tab>: Remove.
* f-lang.c (f_language::op_print_tab): Remove.
* expression.h (union exp_element): Remove.
(struct expression): Remove size_t parameter from constructor.
<resize>: Remove.
<first_opcode>: Update.
<nelts, elts>: Remove.
(EXP_ELEM_TO_BYTES, BYTES_TO_EXP_ELEM): Remove.
(evaluate_subexp_standard, print_expression, op_string)
(dump_raw_expression): Don't declare.
* expprint.c (print_expression, print_subexp)
(print_subexp_funcall, print_subexp_standard, op_string)
(dump_raw_expression, dump_subexp, dump_subexp_body)
(dump_subexp_body_funcall, dump_subexp_body_standard): Remove.
(dump_prefix_expression): Update.
* eval.c (evaluate_subexp): Remove.
(evaluate_expression, evaluate_type): Update.
(evaluate_subexpression_type): Remove.
(fetch_subexp_value): Remove "pc" parameter. Update.
(extract_field_op, evaluate_struct_tuple, evaluate_funcall)
(evaluate_subexp_standard, evaluate_subexp_for_address)
(evaluate_subexp_with_coercion, evaluate_subexp_for_sizeof)
(evaluate_subexp_for_cast): Remove.
(parse_and_eval_type): Update.
* dtrace-probe.c (dtrace_probe::compile_to_ax): Update.
* d-lang.c (d_op_print_tab): Remove.
(class d_language) <opcode_print_table>: Remove.
* c-lang.h (c_op_print_tab): Don't declare.
* c-lang.c (c_op_print_tab): Remove.
(class c_language, class cplus_language, class asm_language, class
minimal_language) <opcode_print_table>: Remove.
* breakpoint.c (update_watchpoint, watchpoint_check)
(watchpoint_exp_is_const, watch_command_1): Update.
* ax-gdb.h (union exp_element): Don't declare.
* ax-gdb.c (const_var_ref, const_expr, maybe_const_expr)
(gen_repeat, gen_sizeof, gen_expr_for_cast, gen_expr)
(gen_expr_binop_rest): Remove.
(gen_trace_for_expr, gen_eval_for_expr, gen_printf): Update.
* ada-lang.c (ada_op_print_tab): Remove.
(class ada_language) <post_parser, opcode_print_table>: Remove.
2021-03-08 07:27:57 -07:00
|
|
|
|
extern void fetch_subexp_value (struct expression *exp,
|
Add an expr::operation_up to struct expression
This adds an expr::operation_up to struct expression, and then
modifies various parts of GDB to use this member when it is non-null.
The list of such spots was a bit surprising to me, and found only
after writing most of the code and then noticing what no longer
compiled.
In a few spots, new accessor methods are added to operation
subclasses, so that code that dissects an expression will work with
the new scheme.
After this change, code that constructs an expression can be switched
to the new form without breaking.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* ada-exp.h (class ada_var_value_operation) <get_symbol>: Remove;
now in superclass.
* value.h (fetch_subexp_value): Add "op" parameter.
* value.c (init_if_undefined_command): Update.
* tracepoint.c (validate_actionline, encode_actions_1): Update.
* stap-probe.c (stap_probe::compile_to_ax): Update.
* printcmd.c (set_command): Update.
* ppc-linux-nat.c (ppc_linux_nat_target::check_condition):
Update.
* parser-defs.h (struct expr_builder) <set_operation>: New
method.
* parse.c (parse_exp_in_context, exp_uses_objfile): Update.
* expression.h (struct expression) <first_opcode>: Update.
<op>: New member.
* expprint.c (dump_raw_expression, dump_prefix_expression):
Update.
* expop.h (class var_value_operation) <get_symbol>: New method.
(class register_operation) <get_name>: New method.
(class equal_operation): No longer a typedef, now a subclass.
(class unop_memval_operation) <get_type>: New method.
(class assign_operation) <get_lhs>: New method.
(class unop_cast_operation) <get_type>: New method.
* eval.c (evaluate_expression, evaluate_type)
(evaluate_subexpression_type): Update.
(fetch_subexp_value): Add "op" parameter.
(parse_and_eval_type): Update.
* dtrace-probe.c (dtrace_probe::compile_to_ax): Update.
* breakpoint.c (update_watchpoint, watchpoint_check)
(watchpoint_exp_is_const, watch_command_1): Update.
* ax-gdb.c (gen_trace_for_expr, gen_eval_for_expr, gen_printf):
Update.
2021-03-08 07:27:57 -07:00
|
|
|
|
expr::operation *op,
|
2010-07-07 16:15:18 +00:00
|
|
|
|
struct value **valp, struct value **resultp,
|
2018-04-03 20:20:01 -06:00
|
|
|
|
std::vector<value_ref_ptr> *val_chain,
|
2020-11-16 16:12:44 +00:00
|
|
|
|
bool preserve_errors);
|
2010-07-07 16:15:18 +00:00
|
|
|
|
|
2023-04-28 08:45:48 -06:00
|
|
|
|
extern struct value *parse_and_eval (const char *exp, parser_flags flags = 0);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2013-03-12 17:39:45 +00:00
|
|
|
|
extern struct value *parse_to_comma_and_eval (const char **expp);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2020-12-13 09:51:42 -07:00
|
|
|
|
extern struct type *parse_and_eval_type (const char *p, int length);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2013-03-12 17:39:45 +00:00
|
|
|
|
extern CORE_ADDR parse_and_eval_address (const char *exp);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2013-05-14 20:37:57 +00:00
|
|
|
|
extern LONGEST parse_and_eval_long (const char *exp);
|
2000-10-30 15:32:51 +00:00
|
|
|
|
|
2008-09-11 14:14:20 +00:00
|
|
|
|
extern void unop_promote (const struct language_defn *language,
|
|
|
|
|
struct gdbarch *gdbarch,
|
|
|
|
|
struct value **arg1);
|
|
|
|
|
|
|
|
|
|
extern void binop_promote (const struct language_defn *language,
|
|
|
|
|
struct gdbarch *gdbarch,
|
|
|
|
|
struct value **arg1, struct value **arg2);
|
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *access_value_history (int num);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2022-01-24 15:19:43 +00:00
|
|
|
|
/* Return the number of items in the value history. */
|
|
|
|
|
|
|
|
|
|
extern ULONGEST value_history_count ();
|
|
|
|
|
|
2009-07-02 12:11:19 +00:00
|
|
|
|
extern struct value *value_of_internalvar (struct gdbarch *gdbarch,
|
|
|
|
|
struct internalvar *var);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2009-06-03 18:16:44 +00:00
|
|
|
|
extern int get_internalvar_integer (struct internalvar *var, LONGEST *l);
|
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern void set_internalvar (struct internalvar *var, struct value *val);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2009-06-03 18:16:44 +00:00
|
|
|
|
extern void set_internalvar_integer (struct internalvar *var, LONGEST l);
|
|
|
|
|
|
2009-07-02 12:11:19 +00:00
|
|
|
|
extern void set_internalvar_string (struct internalvar *var,
|
|
|
|
|
const char *string);
|
|
|
|
|
|
2009-06-03 18:16:44 +00:00
|
|
|
|
extern void clear_internalvar (struct internalvar *var);
|
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
extern void set_internalvar_component (struct internalvar *var,
|
2016-04-12 15:02:57 -04:00
|
|
|
|
LONGEST offset,
|
|
|
|
|
LONGEST bitpos, LONGEST bitsize,
|
2002-01-04 05:20:09 +00:00
|
|
|
|
struct value *newvalue);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
gdb/
2009-03-05 Tom Tromey <tromey@redhat.com>
Add support for convenience functions in Python.
* Makefile.in (SUBDIR_PYTHON_OBS): Add python-function.o.
(SUBDIR_PYTHON_SRCS): Add python-function.c.
(python-function.o): New target.
* eval.c: Include "python/python.h" and <ctype.h>.
(evaluate_subexp_standard): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* gdbtypes.h (type_code): Add TYPE_CODE_INTERNAL_FUNCTION.
* parse.c (write_exp_string): Remove duplicate word in comment.
* python/python-function.c: New file.
* python/python-internal.h (gdbpy_initialize_functions): Add
prototype.
* python/python.c (_initialize_python): Call
gdbpy_initialize_functions.
* valprint.c (value_check_printable): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* value.c: Include "cli/cli-decode.h".
(internal_function): New struct.
(functionlist, internal_fn_type): New static variables.
(lookup_only_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(create_internalvar): Likewise. Initialize new field.
(set_internal_var): Fix typo in comment. Don't allow assignment
to canonical variable.
(value_create_internal_function, value_internal_function_name,
call_internal_function, function_command, function_destroyer,
add_internal_function): New functions.
(_initialize_values): Create `function' placeholder command.
Initialize internal_fn_type.
* value.h (lookup_only_internalvar, create_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(internal_function_fn, add_internal_function, call_internal_function,
value_internal_function_name): Add prototypes.
(struct internalvar) <canonical>: New field.
gdb/doc/
2008-03-05 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Convenience Vars): Document convenience functions.
(Functions In Python): New node.
(Python API): Update.
gdb/testsuite/
2009-03-05 Thiago Jung Bauermann <bauerman@br.ibm.com>
* gdb.python/python-function.exp: New file.
2009-03-21 03:03:56 +00:00
|
|
|
|
extern struct internalvar *lookup_only_internalvar (const char *name);
|
2007-10-01 01:39:52 +00:00
|
|
|
|
|
gdb/
2009-03-05 Tom Tromey <tromey@redhat.com>
Add support for convenience functions in Python.
* Makefile.in (SUBDIR_PYTHON_OBS): Add python-function.o.
(SUBDIR_PYTHON_SRCS): Add python-function.c.
(python-function.o): New target.
* eval.c: Include "python/python.h" and <ctype.h>.
(evaluate_subexp_standard): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* gdbtypes.h (type_code): Add TYPE_CODE_INTERNAL_FUNCTION.
* parse.c (write_exp_string): Remove duplicate word in comment.
* python/python-function.c: New file.
* python/python-internal.h (gdbpy_initialize_functions): Add
prototype.
* python/python.c (_initialize_python): Call
gdbpy_initialize_functions.
* valprint.c (value_check_printable): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* value.c: Include "cli/cli-decode.h".
(internal_function): New struct.
(functionlist, internal_fn_type): New static variables.
(lookup_only_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(create_internalvar): Likewise. Initialize new field.
(set_internal_var): Fix typo in comment. Don't allow assignment
to canonical variable.
(value_create_internal_function, value_internal_function_name,
call_internal_function, function_command, function_destroyer,
add_internal_function): New functions.
(_initialize_values): Create `function' placeholder command.
Initialize internal_fn_type.
* value.h (lookup_only_internalvar, create_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(internal_function_fn, add_internal_function, call_internal_function,
value_internal_function_name): Add prototypes.
(struct internalvar) <canonical>: New field.
gdb/doc/
2008-03-05 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Convenience Vars): Document convenience functions.
(Functions In Python): New node.
(Python API): Update.
gdb/testsuite/
2009-03-05 Thiago Jung Bauermann <bauerman@br.ibm.com>
* gdb.python/python-function.exp: New file.
2009-03-21 03:03:56 +00:00
|
|
|
|
extern struct internalvar *create_internalvar (const char *name);
|
2007-10-01 01:39:52 +00:00
|
|
|
|
|
Introduce class completion_tracker & rewrite completion<->readline interaction
This patch reworks the whole completion machinery, and prepares it
for later enhancements.
Adds a new "completion_tracker" class that is meant to hold everything
about the state of the current completion operation.
This class now has the responsibility of tracking the list of
completion matches, and checking whether the max completions limit has
been reached. You can look at this as this patch starting out by
C++fying the existing "completion_tracker" in symtab.c (it's just an
htab_t typedef currently), moving it to completer.h/c, and then making
it a class/generalizing/enhancing it.
Unlike with the current tracking, completion_tracker now checks
whether the limit has been reached on each completion match list
insertion. This both simplifies the max-completions handling code
(maybe_add_completion_enum is gone, for example), and is a
prerequisite for follow up patches.
The current completion_tracker is only used for symbol completions,
and the symbol code gets at the current instance via globals. This
patch cleans that up by adding a completion_tracker reference to the
signature of the completion functions, and passing the tracker around
everywhere necessary.
Then, the patch changes how the completion match list is handed over
to readline. Currently, we're using the rl_completion_entry_function
readline entry point, and the patch switches to
rl_attempted_completion_function. A following patch will want to let
GDB itself decide the common completion prefix between all matches
(what readline calls the "lowest common denominator"), instead of
having readline compute it, and that's not possible with the
rl_completion_entry_function entry point. Also,
rl_attempted_completion_function lets GDB hand over the match list to
readline as an array in one go instead of passing down matches one by
one, so from that angle it's a nicer entry point anyway.
Lastly, the patch catches exceptions around the readline entry points,
because we can't let C++ exceptions cross readline. We handle that in
the readline input entry point, but the completion entry point isn't
guarded, so GDB can abort if completion throws. E.g., in current
master:
(gdb) b -function "fun<tab>
terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR'
Aborted (core dumped)
This patch fixes that. This will be exercised in the new tests added
later on in the series.
gdb/ChangeLog:
2017-07-17 Pedro Alves <palves@redhat.com>
* ada-lang.c (symbol_completion_match): Adjust comments.
(symbol_completion_add): Replace vector parameter with
completion_tracker parameter. Use it.
(ada_make_symbol_completion_list): Rename to...
(ada_collect_symbol_completion_matches): ... this. Add
completion_tracker parameter and use it.
(ada_language_defn): Adjust.
* break-catch-syscall.c (catch_syscall_completer): Adjust
prototype and work with completion_tracker instead of VEC.
* breakpoint.c (condition_completer): Adjust prototype and work
with completion_tracker instead of VEC.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Adjust to renames.
* cli/cli-cmds.c (complete_command): Rework using
completion_tracker. Catch exceptions when completing.
* cli/cli-decode.c (integer_unlimited_completer)
(complete_on_cmdlist, complete_on_enum): Adjust prototype and work
with completion_tracker instead of VEC.
* command.h (struct completion_tracker): Forward declare.
(completer_ftype, completer_handle_brkchars_ftype): Change
types.
(complete_on_cmdlist, complete_on_enum): Adjust.
* completer.c: Include <algorithm>.
(struct gdb_completer_state): New.
(current_completion): New global.
(readline_line_completion_function): Delete.
(noop_completer, filename_completer)
(filename_completer_handle_brkchars, complete_files_symbols)
(linespec_location_completer): Adjust to work with a
completion_tracker instead of a VEC.
(string_or_empty): New.
(collect_explicit_location_matches): Adjust to work with a
completion_tracker instead of a VEC.
(explicit_location_completer): Rename to ...
(complete_explicit_location): ... this and adjust to work with a
completion_tracker instead of a VEC.
(location_completer): Adjust to work with a completion_tracker
instead of a VEC.
(add_struct_fields): Adjust to work with a completion_list instead
of VEC.
(expression_completer): Rename to ...
(complete_expression): ... this and adjust to work with a
completion_tracker instead of a VEC. Use complete_files_symbols.
(expression_completer): Reimplement on top of complete_expression.
(symbol_completer): Adjust to work with a completion_tracker
instead of a VEC.
(enum complete_line_internal_reason): Add describing comments.
(complete_line_internal_normal_command): Adjust to work with a
completion_tracker instead of a VEC.
(complete_line_internal): Rename to ...
(complete_line_internal_1): ... this and adjust to work with a
completion_tracker instead of a VEC. Assert TEXT is NULL in the
handle_brkchars phase.
(new_completion_tracker): Delete.
(complete_line_internal): Reimplement as TRY/CATCH wrapper around
complete_line_internal_1.
(free_completion_tracker): Delete.
(INITIAL_COMPLETION_HTAB_SIZE): New.
(completion_tracker::completion_tracker)
(completion_tracker::~completion_tracker): New.
(maybe_add_completion): Delete.
(completion_tracker::maybe_add_completion)
(completion_tracker::add_completion)
(completion_tracker::add_completions): New.
(throw_max_completions_reached_error): Delete.
(complete_line): Adjust to work with a completion_tracker instead
of a VEC. Don't create a completion_tracker_t or check for max
completions here.
(command_completer, command_completer_handle_brkchars)
(signal_completer, reg_or_group_completer_1)
(reg_or_group_completer, default_completer_handle_brkchars):
Adjust to work with a completion_tracker.
(gdb_completion_word_break_characters_throw): New.
(gdb_completion_word_break_characters): Reimplement.
(line_completion_function): Delete.
(completion_tracker::recompute_lowest_common_denominator)
(expand_preserving_ws)
(completion_tracker::build_completion_result)
(completion_result::completion_result)
(completion_result::completion_result)
(completion_result::~completion_result)
(completion_result::completion_result)
(completion_result::release_match_list, compare_cstrings)
(completion_result::sort_match_list)
(completion_result::reset_match_list)
(gdb_rl_attempted_completion_function_throw)
(gdb_rl_attempted_completion_function): New.
* completer.h (completion_list, struct completion_result)
(class completion_tracker): New.
(complete_line): Add completion_tracker parameter.
(readline_line_completion_function): Delete.
(gdb_rl_attempted_completion_function): New.
(noop_completer, filename_completer, expression_completer)
(location_completer, symbol_completer, command_completer)
(signal_completer, reg_or_group_completer): Update prototypes.
(completion_tracker_t, new_completion_tracker)
(make_cleanup_free_completion_tracker): Delete.
(enum maybe_add_completion_enum): Delete.
(maybe_add_completion): Delete.
(throw_max_completions_reached_error): Delete.
* corefile.c (complete_set_gnutarget): Adjust to work with a
completion_tracker instead of a VEC.
* cp-abi.c (cp_abi_completer): Adjust to work with a
completion_tracker instead of a VEC.
* d-lang.c (d_language_defn): Adjust.
* disasm.c (disassembler_options_completer): Adjust to work with a
completion_tracker instead of a VEC.
* f-lang.c (f_make_symbol_completion_list): Rename to ...
(f_collect_symbol_completion_matches): ... this. Adjust to work
with a completion_tracker instead of a VEC.
(f_language_defn): Adjust.
* go-lang.c (go_language_defn): Adjust.
* guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer):
Adjust to work with a completion_tracker instead of a VEC.
* infrun.c (handle_completer): Likewise.
* interps.c (interpreter_completer): Likewise.
* interps.h (interpreter_completer): Likewise.
* language.c (unknown_language_defn, auto_language_defn)
(local_language_defn): Adjust.
* language.h (language_defn::la_make_symbol_completion_list):
Rename to ...
(language_defn::la_collect_symbol_completion_matches): ... this
and adjust to work with a completion_tracker instead of a VEC.
* m2-lang.c (m2_language_defn): Adjust.
* objc-lang.c (objc_language_defn): Adjust.
* opencl-lang.c (opencl_language_defn): Adjust.
* p-lang.c (pascal_language_defn): Adjust.
* python/py-cmd.c (cmdpy_completer_helper): Handle NULL word.
(cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work
with a completion_tracker.
* rust-lang.c (rust_language_defn): Adjust.
* symtab.c (free_completion_list, do_free_completion_list)
(return_val, completion_tracker): Delete.
(completion_list_add_name, completion_list_add_symbol)
(completion_list_add_msymbol, completion_list_objc_symbol)
(completion_list_add_fields, add_symtab_completions): Add
completion_tracker parameter and use it.
(default_make_symbol_completion_list_break_on_1): Rename to...
(default_collect_symbol_completion_matches_break_on): ... this.
Add completion_tracker parameter and use it instead of allocating
a completion tracker here.
(default_make_symbol_completion_list_break_on): Delete old
implementation.
(default_make_symbol_completion_list): Delete.
(default_collect_symbol_completion_matches): New.
(make_symbol_completion_list): Delete.
(collect_symbol_completion_matches): New.
(make_symbol_completion_type): Rename to ...
(collect_symbol_completion_matches_type): ... this. Add
completion_tracker parameter and use it instead of VEC.
(make_file_symbol_completion_list_1): Rename to...
(collect_file_symbol_completion_matches): ... this. Add
completion_tracker parameter and use it instead of VEC.
(make_file_symbol_completion_list): Delete.
(add_filename_to_list): Use completion_list instead of a VEC.
(add_partial_filename_data::list): Now a completion_list.
(make_source_files_completion_list): Work with a completion_list
instead of a VEC.
* symtab.h: Include "completer.h".
(default_make_symbol_completion_list_break_on)
(default_make_symbol_completion_list, make_symbol_completion_list)
(make_symbol_completion_type, make_file_symbol_completion_list)
(make_source_files_completion_list): Delete.
(default_collect_symbol_completion_matches_break_on)
(default_collect_symbol_completion_matches)
(collect_symbol_completion_matches)
(collect_symbol_completion_matches_type)
(collect_file_symbol_completion_matches)
(make_source_files_completion_list): New.
* top.c (init_main): Don't install a rl_completion_entry_function
hook. Install a rl_attempted_completion_function hook instead.
* tui/tui-layout.c (layout_completer): Adjust to work with a
completion_tracker.
* tui/tui-regs.c (tui_reggroup_completer):
* tui/tui-win.c (window_name_completer, focus_completer)
(winheight_completer): Adjust to work with a completion_tracker.
* value.c: Include "completer.h".
(complete_internalvar): Adjust to work with a completion_tracker.
* value.h (complete_internalvar): Likewise.
2017-07-17 14:45:59 +01:00
|
|
|
|
extern void complete_internalvar (completion_tracker &tracker,
|
|
|
|
|
const char *name);
|
2012-06-13 15:50:22 +00:00
|
|
|
|
|
2012-04-27 20:38:39 +00:00
|
|
|
|
/* An internalvar can be dynamically computed by supplying a vector of
|
|
|
|
|
function pointers to perform various operations. */
|
|
|
|
|
|
|
|
|
|
struct internalvar_funcs
|
|
|
|
|
{
|
|
|
|
|
/* Compute the value of the variable. The DATA argument passed to
|
|
|
|
|
the function is the same argument that was passed to
|
|
|
|
|
`create_internalvar_type_lazy'. */
|
|
|
|
|
|
|
|
|
|
struct value *(*make_value) (struct gdbarch *arch,
|
|
|
|
|
struct internalvar *var,
|
|
|
|
|
void *data);
|
|
|
|
|
|
|
|
|
|
/* Update the agent expression EXPR with bytecode to compute the
|
|
|
|
|
value. VALUE is the agent value we are updating. The DATA
|
|
|
|
|
argument passed to this function is the same argument that was
|
|
|
|
|
passed to `create_internalvar_type_lazy'. If this pointer is
|
|
|
|
|
NULL, then the internalvar cannot be compiled to an agent
|
|
|
|
|
expression. */
|
|
|
|
|
|
|
|
|
|
void (*compile_to_ax) (struct internalvar *var,
|
|
|
|
|
struct agent_expr *expr,
|
|
|
|
|
struct axs_value *value,
|
|
|
|
|
void *data);
|
|
|
|
|
};
|
|
|
|
|
|
2013-08-13 19:25:04 +00:00
|
|
|
|
extern struct internalvar *create_internalvar_type_lazy (const char *name,
|
|
|
|
|
const struct internalvar_funcs *funcs,
|
|
|
|
|
void *data);
|
2012-04-27 20:38:39 +00:00
|
|
|
|
|
|
|
|
|
/* Compile an internal variable to an agent expression. VAR is the
|
|
|
|
|
variable to compile; EXPR and VALUE are the agent expression we are
|
|
|
|
|
updating. This will return 0 if there is no known way to compile
|
|
|
|
|
VAR, and 1 if VAR was successfully compiled. It may also throw an
|
|
|
|
|
exception on error. */
|
|
|
|
|
|
|
|
|
|
extern int compile_internalvar_to_ax (struct internalvar *var,
|
|
|
|
|
struct agent_expr *expr,
|
|
|
|
|
struct axs_value *value);
|
2009-02-06 22:59:01 +00:00
|
|
|
|
|
gdb/
2009-03-05 Tom Tromey <tromey@redhat.com>
Add support for convenience functions in Python.
* Makefile.in (SUBDIR_PYTHON_OBS): Add python-function.o.
(SUBDIR_PYTHON_SRCS): Add python-function.c.
(python-function.o): New target.
* eval.c: Include "python/python.h" and <ctype.h>.
(evaluate_subexp_standard): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* gdbtypes.h (type_code): Add TYPE_CODE_INTERNAL_FUNCTION.
* parse.c (write_exp_string): Remove duplicate word in comment.
* python/python-function.c: New file.
* python/python-internal.h (gdbpy_initialize_functions): Add
prototype.
* python/python.c (_initialize_python): Call
gdbpy_initialize_functions.
* valprint.c (value_check_printable): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* value.c: Include "cli/cli-decode.h".
(internal_function): New struct.
(functionlist, internal_fn_type): New static variables.
(lookup_only_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(create_internalvar): Likewise. Initialize new field.
(set_internal_var): Fix typo in comment. Don't allow assignment
to canonical variable.
(value_create_internal_function, value_internal_function_name,
call_internal_function, function_command, function_destroyer,
add_internal_function): New functions.
(_initialize_values): Create `function' placeholder command.
Initialize internal_fn_type.
* value.h (lookup_only_internalvar, create_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(internal_function_fn, add_internal_function, call_internal_function,
value_internal_function_name): Add prototypes.
(struct internalvar) <canonical>: New field.
gdb/doc/
2008-03-05 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Convenience Vars): Document convenience functions.
(Functions In Python): New node.
(Python API): Update.
gdb/testsuite/
2009-03-05 Thiago Jung Bauermann <bauerman@br.ibm.com>
* gdb.python/python-function.exp: New file.
2009-03-21 03:03:56 +00:00
|
|
|
|
extern struct internalvar *lookup_internalvar (const char *name);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern int value_equal (struct value *arg1, struct value *arg2);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2009-12-30 17:33:35 +00:00
|
|
|
|
extern int value_equal_contents (struct value *arg1, struct value *arg2);
|
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern int value_less (struct value *arg1, struct value *arg2);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2021-08-26 18:17:40 -06:00
|
|
|
|
/* Simulate the C operator ! -- return true if ARG1 contains zero. */
|
|
|
|
|
extern bool value_logical_not (struct value *arg1);
|
|
|
|
|
|
|
|
|
|
/* Returns true if the value VAL represents a true value. */
|
|
|
|
|
static inline bool
|
|
|
|
|
value_true (struct value *val)
|
|
|
|
|
{
|
|
|
|
|
return !value_logical_not (val);
|
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* C++ */
|
|
|
|
|
|
2011-09-08 14:54:20 +00:00
|
|
|
|
extern struct value *value_of_this (const struct language_defn *lang);
|
|
|
|
|
|
|
|
|
|
extern struct value *value_of_this_silent (const struct language_defn *lang);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_x_binop (struct value *arg1, struct value *arg2,
|
|
|
|
|
enum exp_opcode op,
|
|
|
|
|
enum exp_opcode otherop,
|
|
|
|
|
enum noside noside);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_x_unop (struct value *arg1, enum exp_opcode op,
|
|
|
|
|
enum noside noside);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2005-01-27 16:45:09 +00:00
|
|
|
|
extern struct value *value_fn_field (struct value **arg1p, struct fn_field *f,
|
2016-04-12 15:02:57 -04:00
|
|
|
|
int j, struct type *type, LONGEST offset);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2010-02-11 21:45:25 +00:00
|
|
|
|
extern int binop_types_user_defined_p (enum exp_opcode op,
|
|
|
|
|
struct type *type1,
|
|
|
|
|
struct type *type2);
|
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern int binop_user_defined_p (enum exp_opcode op, struct value *arg1,
|
|
|
|
|
struct value *arg2);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern int unop_user_defined_p (enum exp_opcode op, struct value *arg1);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2011-05-06 14:12:18 +00:00
|
|
|
|
extern int destructor_name_p (const char *name, struct type *type);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
Introduce a gdb_ref_ptr specialization for struct value
struct value is internally reference counted and so, while it also has
some ownership rules unique to it, it makes sense to use a gdb_ref_ptr
when managing it automatically.
This patch removes the existing unique_ptr specialization in favor of
a reference-counted pointer. It also introduces two other
clarifications:
1. Rename value_free to value_decref, which I think is more in line
with what the function actually does; and
2. Change release_value to return a gdb_ref_ptr. This change allows
us to remove the confusing release_value_or_incref function,
primarily by making it much simpler to reason about the result of
release_value.
gdb/ChangeLog
2018-04-06 Tom Tromey <tom@tromey.com>
* varobj.c (varobj_clear_saved_item)
(update_dynamic_varobj_children, install_new_value, ~varobj):
Update.
* value.h (value_incref): Move declaration earlier.
(value_decref): Rename from value_free.
(struct value_ref_policy): New.
(value_ref_ptr): New typedef.
(struct value_deleter): Remove.
(gdb_value_up): Remove typedef.
(release_value): Change return type.
(release_value_or_incref): Remove.
* value.c (set_value_parent): Update.
(value_incref): Change return type.
(value_decref): Rename from value_free.
(value_free_to_mark, free_all_values, free_value_chain): Update.
(release_value): Return value_ref_ptr.
(release_value_or_incref): Remove.
(record_latest_value, set_internalvar, clear_internalvar):
Update.
* stack.c (info_frame_command): Don't call value_free.
* python/py-value.c (valpy_dealloc, valpy_new)
(value_to_value_object): Update.
* printcmd.c (do_examine): Update.
* opencl-lang.c (lval_func_free_closure): Update.
* mi/mi-main.c (register_changed_p): Don't call value_free.
* mep-tdep.c (mep_frame_prev_register): Don't call value_free.
* m88k-tdep.c (m88k_frame_prev_register): Don't call value_free.
* m68hc11-tdep.c (m68hc11_frame_prev_register): Don't call
value_free.
* guile/scm-value.c (vlscm_free_value_smob)
(vlscm_scm_from_value): Update.
* frame.c (frame_register_unwind, frame_unwind_register_signed)
(frame_unwind_register_unsigned, get_frame_register_bytes)
(put_frame_register_bytes): Don't call value_free.
* findvar.c (address_from_register): Don't call value_free.
* dwarf2read.c (dwarf2_compute_name): Don't call value_free.
* dwarf2loc.c (entry_data_value_free_closure)
(value_of_dwarf_reg_entry, free_pieced_value_closure)
(dwarf2_evaluate_loc_desc_full): Update.
* breakpoint.c (update_watchpoint, breakpoint_init_inferior)
(~bpstats, bpstats, bpstat_clear_actions, watchpoint_check)
(~watchpoint, watch_command_1)
(invalidate_bp_value_on_memory_change): Update.
* alpha-tdep.c (alpha_register_to_value): Don't call value_free.
2018-04-03 17:45:21 -06:00
|
|
|
|
extern value_ref_ptr release_value (struct value *val);
|
2011-12-22 19:51:10 +00:00
|
|
|
|
|
* gdbtypes.c (make_pointer_type, make_reference_type,
smash_to_memberptr_type, lookup_array_range_type, check_stub_method):
Use type architecture instead of current_gdbarch.
* gdbtypes.h (address_space_name_to_int, address_space_int_to_name):
Add GDBARCH paramter.
* gdbtypes.c (address_space_name_to_int, address_space_int_to_name):
Add GDBARCH parameter. Use it instead of current_gdbarch.
* c-typeprint.c (c_type_print_modifier): Update call.
* parse.c (push_type_address_space): Likewise.
* findvar.c (extract_typed_address, store_typed_address): Use type
architecture instead of current_gdbarch.
* value.c (value_as_address, unpack_field_as_long): Use type architecture
instead of current_gdbarch.
* doublest.c (floatformat_from_length): Add GDBARCH argument. Use it
instead of current_gdbarch.
(floatformat_from_type): Pass type architecture.
* infcall.c (find_function_addr): Use type architecture instead
of current_gdbarch.
* valarith.c (value_bitstring_subscript, value_x_binop, value_neg,
value_bit_index): Use type architecture instead of current_gdbarch.
* valops.c (value_cast, value_slice): Likewise.
* value.h (modify_field): Add TYPE argument.
* value.c (modify_field): Add TYPE argument. Use type architecture
instead of current_gdbarch.
(set_internalvar_component): Likewise.
* eval.c (evaluate_struct_tuple): Update call.
* valops.c (value_assign): Likewise.
* ada-lang.c (modify_general_field): Likewise. Add TYPE argument.
(make_array_descriptor): Update calls.
(move_bits): Add BITS_BIG_ENDIAN_P argument. Use it instead of
current_gdbarch.
(ada_value_assign, value_assign_to_component): Update calls.
(decode_packed_array, ada_value_primitive_packed_val, ada_value_assign,
value_assign_to_component): Use type arch instead of current_gdbarch.
* printcmd.c (float_type_from_length): Remove GDBARCH argument,
use type architecture instead.
(print_scalar_formatted, printf_command): Update calls. Use type
architecture instead of current_gdbarch.
* valprint.c (val_print_type_code_int): Use type architecture
instead of current_gdbarch.
* varobj.c (value_get_print_value): Likewise.
* python/python-prettyprint.c (print_string_repr): Add GDBARCH
argument. Use it instead of current_gdbarch.
(apply_val_pretty_printer): Update call.
* ada-valprint.c (ada_val_print_1): Use type architecture instead
of current_gdbarch.
* c-valprint.c (print_function_pointer_address): Add GDBARCH argument.
Use it instead of current_gdbarch.
(c_val_print): Update calls passing type architecture.
* f-valprint.c (f_val_print): Use type architecture instead of
current_gdbarch.
* jv-valprint (java_value_print): Likewise.
* m2-valprint.c (print_function_pointer_address): Add GDBARCH argument.
Use it instead of current_gdbarch.
(print_unpacked_pointer): Update calls passing type architecture.
* scm-valprint.c (scm_scmval_print): Use type architecture instead of
current_gdbarch.
* gnu-v3-abi.c (get_class_arch): Remove.
(gnuv3_rtti_type): Use get_type_arch instead of get_class_arch. Remove
special-case check for Java classes.
(gnuv3_virtual_fn_field, gnuv3_baseclass_offset, gnuv3_print_method_ptr,
gnuv3_method_ptr_size, gnuv3_make_method_ptr, gnuv3_method_ptr_to_value):
Use get_type_arch instead of get_class_arch.
2009-07-02 12:57:14 +00:00
|
|
|
|
extern void modify_field (struct type *type, gdb_byte *addr,
|
2016-04-12 15:02:57 -04:00
|
|
|
|
LONGEST fieldval, LONGEST bitpos, LONGEST bitsize);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
* gdbtypes.h (struct main_type): Change type of name,tag_name,
and fields.name members from char * to const char *. All uses updated.
(struct cplus_struct_type): Change type of fn_fieldlists.name member
from char * to const char *. All uses updated.
(type_name_no_tag): Update.
(lookup_unsigned_typename, lookup_signed_typename): Update.
* gdbtypes.c (type_name_no_tag): Change result type
from char * to const char *. All callers updated.
(lookup_unsigned_typename, lookup_signed_typename): Change type of
name parameter from char * to const char *.
* symtab.h (struct cplus_specific): Change type of demangled_name
member from char * to const char *. All uses updated.
(struct general_symbol_info): Change type of name and
mangled_lang.demangled_name members from char * to const char *.
All uses updated.
(symbol_get_demangled_name, symbol_natural_name): Update.
(symbol_demangled_name, symbol_search_name): Update.
* symtab.c (symbol_get_demangled_name): Change result type
from char * to const char *. All callers updated.
(symbol_natural_name, symbol_demangled_name): Ditto.
(symbol_search_name): Ditto.
(completion_list_add_name): Change type of symname,sym_text,
text,word parameters from char * to const char *.
(completion_list_objc_symbol): Change type of sym_text,
text,word parameters from char * to const char *.
* ada-lang.c (find_struct_field): Change type of name parameter
from char * to const char *.
(encoded_ordered_before): Similarly for N0,N1 parameters.
(old_renaming_is_invisible): Similarly for function_name parameter.
(ada_type_name): Change result type from char * to const char *.
All callers updated.
* ada-lang.h (ada_type_name): Update.
* buildsym.c (hashname): Change type of name parameter
from char * to const char *.
* buildsym.h (hashname): Update.
* dbxread.c (end_psymtab): Change type of include_list parameter
from char ** to const char **.
* dwarf2read.c (determine_prefix): Change result type
from char * to const char *. All callers updated.
* f-lang.c (find_common_for_function): Change type of name, funcname
parameters from char * to const char *.
* f-lang.c (find_common_for_function): Update.
* f-valprint.c (list_all_visible_commons): Change type of funcname
parameters from char * to const char *.
* gdbarch.sh (static_transform_name): Change type of name parameter
and result from char * to const char *.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
of name parameter from char * to const char *.
* jv-lang.c (java_primitive_type_from_name): Ditto.
(java_demangled_signature_length): Similarly for signature parameter.
(java_demangled_signature_copy): Ditto.
(java_demangle_type_signature): Ditto.
* jv-lang.h (java_primitive_type_from_name): Update.
(java_demangle_type_signature): Update.
* objc-lang.c (specialcmp): Change type of a,b parameters
from char * to const char *.
* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
from char * to const char *. All callers updated.
* p-lang.h (is_pascal_string_type): Update.
* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
of name parameter from char * to const char *.
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* defs.h (fprintf_symbol_filtered): Update.
* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
* stabsread.h (end_psymtab): Update.
* stack.c (find_frame_funname): Change type of funname parameter
from char ** to const char **.
* stack.h (find_frame_funname): Update.
* typeprint.c (type_print): Change type of varstring parameter
from char * to const char *.
* value.h (type_print): Update.
* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
from char * to const char *. All callers updated.
(xcoff_end_psymtab): Change type of include_list parameter
from char ** to const char **. All callers updated.
(swap_sym): Similarly for name parameter. All callers updated.
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
2012-02-07 04:48:23 +00:00
|
|
|
|
extern void type_print (struct type *type, const char *varstring,
|
2005-01-27 16:45:09 +00:00
|
|
|
|
struct ui_file *stream, int show);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
Use ui_file_as_string throughout more
This replaces most of the remaining ui_file_xstrdup calls with
ui_file_as_string calls. Whenever a call was replaced, that led to a
cascade of other necessary adjustments throughout, to make the code
use std::string instead of raw pointers. And then whenever I added a
std::string as member of a struct, I needed to adjust
allocation/destruction of said struct to use new/delete instead of
xmalloc/xfree.
The stopping point was once gdb built again. These doesn't seem to be
a way to reasonably split this out further.
Maybe-not-obvious changes:
- demangle_for_lookup returns a cleanup today. To get rid of that,
and avoid unnecessary string dupping/copying, this introduces a
demangle_result_storage type that the caller instantiates and
passes to demangle_for_lookup.
- Many methods returned a "char *" to indicate that the caller owns
the memory and must free it. Those are switched to return a
std::string instead. Methods that return a "view" into some
internal string return a "const char *" instead. I.e., we only
copy/allocate when necessary.
gdb/ChangeLog:
2016-11-08 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_name_for_lookup, type_as_string): Use and return
std::string.
(type_as_string_and_cleanup): Delete.
(ada_lookup_struct_elt_type): Use type_as_string.
* ada-lang.h (ada_name_for_lookup): Now returns std::string.
* ada-varobj.c (ada_varobj_scalar_image): Return a std::string.
(ada_varobj_describe_child): Make 'child_name' and
'child_path_expr' parameters std::string pointers.
(ada_varobj_describe_struct_child, ada_varobj_describe_ptr_child):
Likewise, and use string_printf.
(ada_varobj_describe_simple_array_child)
(ada_varobj_describe_child): Likewise.
(ada_varobj_get_name_of_child, ada_varobj_get_path_expr_of_child)
(ada_varobj_get_value_image)
(ada_varobj_get_value_of_array_variable)
(ada_varobj_get_value_of_variable, ada_name_of_variable)
(ada_name_of_child, ada_path_expr_of_child)
(ada_value_of_variable): Now returns std::string. Use
string_printf.
(ada_value_of_child): Adjust.
* break-catch-throw.c (check_status_exception_catchpoint): Adjust
to use std::string.
* breakpoint.c (watch_command_1): Adjust to use std::string.
* c-lang.c (c_get_string): Adjust to use std::string.
* c-typeprint.c (print_name_maybe_canonical): Use std::string.
* c-varobj.c (varobj_is_anonymous_child): Use ==/!= std::string
operators.
(c_name_of_variable): Now returns a std::string.
(c_describe_child): The 'cname' and 'cfull_expression' output
parameters are now std::string pointers. Adjust.
(c_name_of_child, c_path_expr_of_child, c_value_of_variable)
(cplus_number_of_children): Adjust to use std::string and
string_printf.
(cplus_name_of_variable): Now returns a std::string.
(cplus_describe_child): The 'cname' and 'cfull_expression' output
parameters are now std::string pointers. Adjust.
(cplus_name_of_child, cplus_path_expr_of_child)
(cplus_value_of_variable): Now returns a std::string.
* cp-abi.c (cplus_typename_from_type_info): Return std::string.
* cp-abi.h (cplus_typename_from_type_info): Return std::string.
(struct cp_abi_ops) <get_typename_from_type_info>: Return
std::string.
* cp-support.c (inspect_type): Use std::string.
(cp_canonicalize_string_full, cp_canonicalize_string_no_typedefs)
(cp_canonicalize_string): Return std::string and adjust.
* cp-support.h (cp_canonicalize_string)
(cp_canonicalize_string_no_typedefs, cp_canonicalize_string_full):
Return std::string.
* dbxread.c (read_dbx_symtab): Use std::string.
* dwarf2read.c (dwarf2_canonicalize_name): Adjust to use std::string.
* gdbcmd.h (lookup_struct_elt_type): Adjust to use std::string.
* gnu-v3-abi.c (gnuv3_get_typeid): Use std::string.
(gnuv3_get_typename_from_type_info): Return a std::string and
adjust.
(gnuv3_get_type_from_type_info): Adjust to use std::string.
* guile/guile.c (gdbscm_execute_gdb_command): Adjust to use
std::string.
* infcmd.c (print_return_value_1): Adjust to use std::string.
* linespec.c (find_linespec_symbols): Adjust to
demangle_for_lookup API change. Use std::string.
* mi/mi-cmd-var.c (print_varobj, mi_cmd_var_set_format)
(mi_cmd_var_info_type, mi_cmd_var_info_path_expression)
(mi_cmd_var_info_expression, mi_cmd_var_evaluate_expression)
(mi_cmd_var_assign, varobj_update_one): Adjust to use std::string.
* minsyms.c (lookup_minimal_symbol): Use std::string.
* python/py-varobj.c (py_varobj_iter_next): Use new instead of
XNEW. vitem->name is a std::string now, adjust.
* rust-exp.y (convert_ast_to_type, convert_name): Adjust to use
std::string.
* stabsread.c (define_symbol): Adjust to use std::string.
* symtab.c (demangle_for_lookup): Now returns 'const char *'. Add
a demangle_result_storage parameter. Use it for storage.
(lookup_symbol_in_language)
(lookup_symbol_in_objfile_from_linkage_name): Adjust to new
demangle_for_lookup API.
* symtab.h (struct demangle_result_storage): New type.
(demangle_for_lookup): Now returns 'const char *'. Add a
demangle_result_storage parameter.
* typeprint.c (type_to_string): Return std::string and use
ui_file_as_string.
* value.h (type_to_string): Change return type to std::string.
* varobj-iter.h (struct varobj_item) <name>: Now a std::string.
(varobj_iter_delete): Use delete instead of xfree.
* varobj.c (create_child): Return std::string instead of char * in
output parameter.
(name_of_variable, name_of_child, my_value_of_variable): Return
std::string instead of char *.
(varobj_create, varobj_get_handle): Constify 'objname' parameter.
Adjust to std::string fields.
(varobj_get_objname): Return a const char * instead of a char *.
(varobj_get_expression): Return a std::string.
(varobj_list_children): Adjust to use std::string.
(varobj_get_type): Return a std::string.
(varobj_get_path_expr): Return a const char * instead of a char *.
Adjust to std::string fields.
(varobj_get_formatted_value, varobj_get_value): Return a
std::string.
(varobj_set_value): Change type of 'expression' parameter to
std::string. Use std::string.
(install_new_value): Use std::string.
(delete_variable_1): Adjust to use std::string.
(create_child): Change the 'name' parameter to a std::string
reference. Swap it into the new item's name.
(create_child_with_value): Swap item's name into the new child's
name. Use string_printf.
(new_variable): Use new instead of XNEW.
(free_variable): Don't xfree fields that are now std::string.
(name_of_variable, name_of_child): Now returns std::string.
(value_of_root): Adjust to use std::string.
(my_value_of_variable, varobj_value_get_print_value): Return
and use std::string.
(varobj_value_get_print_value): Adjust to use ui_file_as_string
and std::string.
* varobj.h (struct varobj) <name, path_expr, obj_name,
print_value>: Now std::string's.
<name_of_variable, name_of_child, path_expr_of_child,
value_of_variable>: Return std::string.
(varobj_create, varobj_get_handle): Constify 'objname' parameter.
(varobj_get_objname): Return a const char * instead of a char *.
(varobj_get_expression, varobj_get_type): Return a std::string.
(varobj_get_path_expr): Return a const char * instead of a char *.
(varobj_get_formatted_value, varobj_get_value): Return a
std::string.
(varobj_set_value): Constify 'expression' parameter.
(varobj_value_get_print_value): Return a std::string.
2016-11-08 15:26:47 +00:00
|
|
|
|
extern std::string type_to_string (struct type *type);
|
2009-02-05 12:16:25 +00:00
|
|
|
|
|
2005-05-09 Andrew Cagney <cagney@gnu.org>
Use gdb_byte in preference to bfd_byte.
* gdbarch.sh: Update.
* gdbarch.h, gdbarch.c: Re-generate.
* ada-lang.c, ada-lang.h, ada-valprint.c, arch-utils.c: Update.
* c-lang.c, c-lang.h, c-valprint.c, cp-valprint.c: Update.
* f-lang.c, f-lang.h, f-valprint.c, gdbcore.h, jv-lang.h: Update.
* jv-valprint.c, language.c, language.h, m2-lang.c: Update.
* m2-lang.h, m2-valprint.c, objc-lang.c, p-lang.c: Update.
* p-lang.h, p-valprint.c, regcache.c, scm-lang.c: Update.
* scm-lang.h, scm-valprint.c, target.c, target.h: Update.
* tramp-frame.c, valarith.c, valops.c, valprint.c: Update.
* valprint.h, value.c, value.h: Update.
2005-05-09 21:20:35 +00:00
|
|
|
|
extern gdb_byte *baseclass_addr (struct type *type, int index,
|
|
|
|
|
gdb_byte *valaddr,
|
2005-04-28 16:15:19 +00:00
|
|
|
|
struct value **valuep, int *errp);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2005-01-27 16:45:09 +00:00
|
|
|
|
extern void print_longest (struct ui_file *stream, int format,
|
2000-02-02 00:21:19 +00:00
|
|
|
|
int use_local, LONGEST val);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2005-05-09 Andrew Cagney <cagney@gnu.org>
Use gdb_byte in preference to bfd_byte.
* gdbarch.sh: Update.
* gdbarch.h, gdbarch.c: Re-generate.
* ada-lang.c, ada-lang.h, ada-valprint.c, arch-utils.c: Update.
* c-lang.c, c-lang.h, c-valprint.c, cp-valprint.c: Update.
* f-lang.c, f-lang.h, f-valprint.c, gdbcore.h, jv-lang.h: Update.
* jv-valprint.c, language.c, language.h, m2-lang.c: Update.
* m2-lang.h, m2-valprint.c, objc-lang.c, p-lang.c: Update.
* p-lang.h, p-valprint.c, regcache.c, scm-lang.c: Update.
* scm-lang.h, scm-valprint.c, target.c, target.h: Update.
* tramp-frame.c, valarith.c, valops.c, valprint.c: Update.
* valprint.h, value.c, value.h: Update.
2005-05-09 21:20:35 +00:00
|
|
|
|
extern void print_floating (const gdb_byte *valaddr, struct type *type,
|
2005-01-27 16:45:09 +00:00
|
|
|
|
struct ui_file *stream);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2012-03-01 19:22:22 +00:00
|
|
|
|
extern void value_print (struct value *val, struct ui_file *stream,
|
|
|
|
|
const struct value_print_options *options);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2018-04-03 20:20:01 -06:00
|
|
|
|
/* Release values from the value chain and return them. Values
|
|
|
|
|
created after MARK are released. If MARK is nullptr, or if MARK is
|
|
|
|
|
not found on the value chain, then all values are released. Values
|
|
|
|
|
are returned in reverse order of creation; that is, newest
|
|
|
|
|
first. */
|
|
|
|
|
|
|
|
|
|
extern std::vector<value_ref_ptr> value_release_to_mark
|
|
|
|
|
(const struct value *mark);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2012-03-01 19:23:36 +00:00
|
|
|
|
extern void common_val_print (struct value *val,
|
|
|
|
|
struct ui_file *stream, int recurse,
|
|
|
|
|
const struct value_print_options *options,
|
|
|
|
|
const struct language_defn *language);
|
2005-02-28 17:00:49 +00:00
|
|
|
|
|
2010-10-15 18:54:13 +00:00
|
|
|
|
extern int val_print_string (struct type *elttype, const char *encoding,
|
|
|
|
|
CORE_ADDR addr, int len,
|
gdb
* varobj.c (value_get_print_value): Include valprint.h.
(value_get_print_value): Use get_formatted_print_options.
* value.h (struct value_print_options): Declare.
(value_print, val_print, common_val_print, val_print_string):
Update.
* value.c: Include valprint.h.
(show_values): Use get_user_print_options.
(show_convenience): Likewise.
* valprint.h (prettyprint_arrays, prettyprint_structs): Don't
declare.
(struct value_print_options): New type.
(vtblprint, unionprint, addressprint, objectprint, print_max,
inspect_it, repeat_count_threshold, output_format,
stop_print_at_null): Don't declare.
(user_print_options, get_user_print_options,
get_raw_print_options, get_formatted_print_options): Declare.
(print_array_indexes_p): Don't declare.
(maybe_print_array_index, val_print_array_elements): Update.
* valprint.c (print_max): Remove.
(user_print_options): New global.
(get_user_print_options, get_raw_print_options,
get_formatted_print_options): New functions.
(print_array_indexes, repeat_count_threshold, stop_print_at_null,
prettyprint_structs, prettyprint_arrays, unionprint,
addressprint): Remove.
(val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
(common_val_print): Likewise.
(print_array_indexes_p): Remove.
(maybe_print_array_index): Remove format, pretty arguments; add
options. Update.
(val_print_array_elements): Remove format, deref_ref, pretty
arguments; add options. Update.
(val_print_string): Add options argument. Update.
(_initialize_valprint): Use user_print_options.
(output_format): Remove.
(set_output_radix_1): Use user_print_options.
* typeprint.c: Include valprint.h.
(objectprint): Don't declare.
(whatis_exp): Use get_user_print_options.
* tui/tui-regs.c: Include valprint.h.
(tui_register_format): Use get_formatted_print_options.
* tracepoint.c: Include valprint.h.
(addressprint): Don't declare.
(trace_mention): Use get_user_print_options.
(tracepoints_info): Likewise.
* stack.c (print_frame_args): Use get_raw_print_options.
(print_frame_info): Use get_user_print_options.
(print_frame): Likewise.
* sh64-tdep.c: Include valprint.h
(sh64_do_register): Use get_formatted_print_options.
* scm-valprint.c (scm_inferior_print): Remove format, deref_ref,
pretty arguments; add options.
(scm_scmlist_print): Likewise. Update.
(scm_scmval_print): Likewise.
(scm_val_print): Likewise.
(scm_value_print): Remove format, pretty arguments; add options.
Update.
* scm-lang.h (scm_value_print, scm_val_print, scm_scmval_print):
Update.
* scm-lang.c (scm_printstr): Add options argument.
* python/python-value.c: Include valprint.h.
(valpy_str): Use get_user_print_options.
* printcmd.c: Include valprint.h.
(addressprint): Don't declare.
(inspect_it): Remove.
(print_formatted): Remove format option; add options. Update.
(print_scalar_formatted): Likewise.
(print_address_demangle): Use get_user_print_options.
(do_examine): Use get_formatted_print_options.
(print_command_1): Likewise.
(output_command): Use get_formatted_print_options.
(do_one_display): Likewise.
(print_variable_value): Use get_user_print_options.
* p-valprint.c (pascal_val_print): Remove format, deref_ref,
pretty arguments; add options. Update.
(pascal_value_print): Remove format, pretty arguments; add
options. Update.
(vtblprint, objectprint): Don't declare.
(pascal_static_field_print): Remove.
(pascal_object_print_value_fields): Remove format, pretty
arguments; add options. Update.
(pascal_object_print_static_field): Likewise.
(_initialize_pascal_valprint): Use user_print_options. Update.
* p-lang.h (pascal_val_print, pascal_value_print,
pascal_printstr, pascal_object_print_value_fields): Update.
(vtblprint, static_field_print): Don't declare.
* p-lang.c (pascal_printstr): Add options argument. Update.
* objc-lang.c (objc_printstr): Add options argument. Update.
* mt-tdep.c: Include valprint.h.
(mt_registers_info): Use get_raw_print_options.
* mips-tdep.c: Include valprint.h.
(mips_print_fp_register): Use get_formatted_print_options.
(mips_print_register): Likewise.
* mi/mi-main.c: Include valprint.h.
(get_register): Use get_user_print_options.
(mi_cmd_data_evaluate_expression): Likewise.
(mi_cmd_data_read_memory): Use get_formatted_print_options.
* mi/mi-cmd-stack.c: Include valprint.h.
(list_args_or_locals): Use get_raw_print_options.
* m2-valprint.c (print_function_pointer_address): Add addressprint
argument.
(m2_print_long_set): Remove format, pretty arguments.
(m2_print_unbounded_array): Remove format, deref_ref, pretty
arguments; add options. Update.
(print_unpacked_pointer): Remove format argument; add options.
Now static. Update.
(print_variable_at_address): Remove format, deref_ref, pretty
arguments; add options. Update.
(m2_print_array_contents): Likewise.
(m2_val_print): Likewise.
* m2-lang.h (m2_val_print): Update.
* m2-lang.c (m2_printstr): Add options argument. Update.
* language.h (struct value_print_options): Declare.
(struct language_defn) <la_printstr>: Add options argument.
<la_val_print>: Remove format, deref_ref, pretty argument; add
options.
<la_value_print>: Remove format, pretty arguments; add options.
<la_print_array_index>: Likewise.
(LA_VAL_PRINT, LA_VALUE_PRINT, LA_PRINT_STRING,
LA_PRINT_ARRAY_INDEX): Update.
(default_print_array_index): Update.
* language.c (default_print_array_index): Remove format, pretty
arguments; add options. Update.
(unk_lang_printstr): Add options argument.
(unk_lang_val_print): Remove format, deref_ref, pretty arguments;
add options.
(unk_lang_value_print): Remove format, pretty arguments; add
options.
* jv-valprint.c (java_value_print): Remove format, pretty
arguments; add options. Update.
(java_print_value_fields): Likewise.
(java_val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
* jv-lang.h (java_val_print, java_value_print): Declare.
* infcmd.c: Include valprint.h.
(print_return_value): Use get_raw_print_options.
(default_print_registers_info): Use get_user_print_options,
get_formatted_print_options.
(registers_info): Use get_formatted_print_options.
* gdbtypes.h (struct value_print_options): Declare.
(print_scalar_formatted): Update.
* f-valprint.c (f77_print_array_1): Remove format, deref_ref,
pretty arguments; add options. Update.
(f77_print_array): Likewise.
(f_val_print): Likewise.
* f-lang.h (f_val_print): Update.
* f-lang.c (f_printstr): Add options argument. Update.
(c_value_print): Update declaration.
* expprint.c: Include valprint.h.
(print_subexp_standard): Use get_raw_print_options,
get_user_print_options.
* eval.c: Include valprint.h.
(objectprint): Don't declare.
(evaluate_subexp_standard): Use get_user_print_options.
* cp-valprint.c (vtblprint, objectprint, static_field_print):
Remove.
(cp_print_value_fields): Remove format, pretty arguments; add
options. Update.
(cp_print_value): Likewise.
(cp_print_static_field): Likewise.
(_initialize_cp_valprint): Use user_print_options. Update.
* c-valprint.c (print_function_pointer_address): Add addressprint
argument.
(c_val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
(c_value_print): Add options argument. Update.
* c-lang.h (c_val_print, c_value_print, c_printstr): Update.
(vtblprint, static_field_print): Don't declare.
(cp_print_value_fields): Update.
* c-lang.c (c_printstr): Add options argument. Update.
* breakpoint.c: Include valprint.h.
(addressprint): Don't declare.
(watchpoint_value_print): Use get_user_print_options.
(print_one_breakpoint_location): Likewise.
(breakpoint_1, print_it_catch_fork, print_it_catch_vfork, mention,
print_exception_catchpoint): Likewise.
* auxv.c (fprint_target_auxv): Don't declare addressprint. Use
get_user_print_options.
* ada-valprint.c (struct ada_val_print_args): Remove format,
deref_ref, and pretty; add options.
(print_optional_low_bound): Add options argument.
(val_print_packed_array_elements): Remove format and pretty
arguments; add options. Update.
(printstr): Add options argument. Update.
(ada_printstr): Likewise.
(ada_val_print): Remove format, deref_ref, pretty arguments; add
options argument. Update.
(ada_val_print_stub): Update.
(ada_val_print_array): Remove format, deref_ref, pretty arguments;
add options. Update.
(ada_val_print_1): Likewise.
(print_variant_part): Likewise.
(ada_value_print): Remove format, pretty arguments; add options.
Update.
(print_record): Likewise.
(print_field_values): Likewise.
* ada-lang.h (ada_val_print, ada_value_print, ada_printstr):
Update.
* ada-lang.c (ada_print_array_index): Add options argument; remove
format and pretty arguments.
(print_one_exception): Use get_user_print_options.
gdb/testsuite
* gdb.base/exprs.exp (test_expr): Add enum formatting tests.
2008-10-28 17:19:58 +00:00
|
|
|
|
struct ui_file *stream,
|
|
|
|
|
const struct value_print_options *options);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2008-12-22 23:11:56 +00:00
|
|
|
|
extern void print_variable_and_value (const char *name,
|
|
|
|
|
struct symbol *var,
|
2022-07-25 14:06:35 -03:00
|
|
|
|
frame_info_ptr frame,
|
2008-12-22 23:11:56 +00:00
|
|
|
|
struct ui_file *stream,
|
|
|
|
|
int indent);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2005-01-27 16:45:09 +00:00
|
|
|
|
extern void typedef_print (struct type *type, struct symbol *news,
|
|
|
|
|
struct ui_file *stream);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2020-11-10 15:46:17 -07:00
|
|
|
|
extern const char *internalvar_name (const struct internalvar *var);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
gdb/
* Makefile.in (gdbtypes_h, gdbtypes.o, utils.o): Update.
* defs.h (hashtab_obstack_allocate, dummy_obstack_deallocate): Add
prototypes.
* dwarf2read.c (read_subroutine_type): Use TYPE_ZALLOC.
(hashtab_obstack_allocate, dummy_obstack_deallocate): Moved to...
* utils.c (hashtab_obstack_allocate, dummy_obstack_deallocate):
...here.
* gdbtypes.c: Include "hashtab.h".
(build_gdbtypes): Remove extra prototype.
(struct type_pair, type_pair_hash, type_pair_eq)
(create_copied_types_hash, copy_type_recursive): New.
* gdbtypes.h: Include "hashtab.h".
(TYPE_ZALLOC): New.
(create_copied_types_hash, copy_type_recursive): New prototypes.
* objfiles.c (free_objfile): Call preserve_values.
* symfile.c (reread_symbols): Likewise.
(clear_symtab_users): Remove calls to clear_value_history and
clear_internalvars.
* value.c (clear_value_history, clear_internalvars): Removed.
(preserve_one_value, preserve_values): New functions.
* value.h (clear_value_history, clear_internalvars): Removed.
(preserve_values): New prototype.
* tracepoint.c (_initialize_tracepoint): Do not initialize convenience
variables here.
gdb/doc/
* gdb.texinfo (Files): Remove obsolete bits from the description
of "symbol-file".
2006-02-01 23:14:11 +00:00
|
|
|
|
extern void preserve_values (struct objfile *);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* From values.c */
|
|
|
|
|
|
2015-04-25 07:04:40 -07:00
|
|
|
|
extern struct value *make_cv_value (int, int, struct value *);
|
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
/* From valops.c */
|
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *varying_to_slice (struct value *);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_slice (struct value *, int, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2020-04-01 14:09:52 -06:00
|
|
|
|
/* Create a complex number. The type is the complex type; the values
|
|
|
|
|
are cast to the underlying scalar type before the complex number is
|
|
|
|
|
created. */
|
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_literal_complex (struct value *, struct value *,
|
|
|
|
|
struct type *);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2020-04-01 14:09:52 -06:00
|
|
|
|
/* Return the real part of a complex value. */
|
|
|
|
|
|
|
|
|
|
extern struct value *value_real_part (struct value *value);
|
|
|
|
|
|
|
|
|
|
/* Return the imaginary part of a complex value. */
|
|
|
|
|
|
|
|
|
|
extern struct value *value_imaginary_part (struct value *value);
|
|
|
|
|
|
2008-09-11 14:27:34 +00:00
|
|
|
|
extern struct value *find_function_in_inferior (const char *,
|
|
|
|
|
struct objfile **);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2002-01-04 05:20:09 +00:00
|
|
|
|
extern struct value *value_allocate_space_in_inferior (int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
gdb/
2009-03-05 Tom Tromey <tromey@redhat.com>
Add support for convenience functions in Python.
* Makefile.in (SUBDIR_PYTHON_OBS): Add python-function.o.
(SUBDIR_PYTHON_SRCS): Add python-function.c.
(python-function.o): New target.
* eval.c: Include "python/python.h" and <ctype.h>.
(evaluate_subexp_standard): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* gdbtypes.h (type_code): Add TYPE_CODE_INTERNAL_FUNCTION.
* parse.c (write_exp_string): Remove duplicate word in comment.
* python/python-function.c: New file.
* python/python-internal.h (gdbpy_initialize_functions): Add
prototype.
* python/python.c (_initialize_python): Call
gdbpy_initialize_functions.
* valprint.c (value_check_printable): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* value.c: Include "cli/cli-decode.h".
(internal_function): New struct.
(functionlist, internal_fn_type): New static variables.
(lookup_only_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(create_internalvar): Likewise. Initialize new field.
(set_internal_var): Fix typo in comment. Don't allow assignment
to canonical variable.
(value_create_internal_function, value_internal_function_name,
call_internal_function, function_command, function_destroyer,
add_internal_function): New functions.
(_initialize_values): Create `function' placeholder command.
Initialize internal_fn_type.
* value.h (lookup_only_internalvar, create_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(internal_function_fn, add_internal_function, call_internal_function,
value_internal_function_name): Add prototypes.
(struct internalvar) <canonical>: New field.
gdb/doc/
2008-03-05 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Convenience Vars): Document convenience functions.
(Functions In Python): New node.
(Python API): Update.
gdb/testsuite/
2009-03-05 Thiago Jung Bauermann <bauerman@br.ibm.com>
* gdb.python/python-function.exp: New file.
2009-03-21 03:03:56 +00:00
|
|
|
|
/* User function handler. */
|
|
|
|
|
|
* python/python-internal.h (struct language_defn): Declare.
(python_gdbarch, python_language): Likewise.
(ensure_python_env): Add prototype.
(make_cleanup_py_restore_gil): Remove prototype.
* python/python.c: Include "arch-utils.h", "value.h" and "language.h".
(python_gdbarch, python_language): New global variables.
(struct python_env): New data type.
(ensure_python_env, restore_python_env): New functions.
(eval_python_from_control_command): Call ensure_python_env to
install current architecture and language.
(python_command, gdbpy_new_objfile): Likewise.
* python/python-cmd.c: Include "arch-utils.h" and "language.h".
(cmdpy_destroyer, cmdpy_function, cmdpy_completer): Call
ensure_python_env.
* python/python-type.c (clean_up_objfile_types): Likewise.
* python/python-objfile.c: Include "language.h".
(clean_up_objfile): Call ensure_python_env.
* python/python-prettyprint.c (apply_val_pretty_printer): Likewise.
(apply_varobj_pretty_printer): Do not call PyGILState_Ensure.
* varobj.c (varobj_ensure_python_env): New helper function.
(varobj_get_display_hint, update_dynamic_varobj_children,
install_default_visualizer, varobj_set_visualizer, free_variable,
value_get_print_value): Call it.
(value_get_print_value): Add varobj argument instead of pretty
printer argument. Update all callers.
* python/python-utils.c (py_gil_restore, make_cleanup_py_restore_gil):
Remove.
* value.h (internal_function_fn): Add GDBARCH and LANGUAGE argument.
(call_internal_function): Likewise.
* value.c (call_internal_function): Likewise. Pass to handler.
* eval.c (evaluate_subexp_standard): Update call.
* python/python-function.c: Include "language.h".
(fnpy_call): Add GDBARCH and LANGAUAGE arguments and call
make_cleanup_python_env.
* python/python-value.c (builtin_type_pyint, builtin_type_pyfloat,
builtin_type_pylong, builtin_type_pybool, builtin_type_pychar,
valpy_str): Use python_gdbarch and python_language instead of
current_gdbarch and current_language.
* python/python-type.c (typy_lookup_typename): Likewise.
2009-07-02 17:04:23 +00:00
|
|
|
|
typedef struct value *(*internal_function_fn) (struct gdbarch *gdbarch,
|
|
|
|
|
const struct language_defn *language,
|
|
|
|
|
void *cookie,
|
gdb/
2009-03-05 Tom Tromey <tromey@redhat.com>
Add support for convenience functions in Python.
* Makefile.in (SUBDIR_PYTHON_OBS): Add python-function.o.
(SUBDIR_PYTHON_SRCS): Add python-function.c.
(python-function.o): New target.
* eval.c: Include "python/python.h" and <ctype.h>.
(evaluate_subexp_standard): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* gdbtypes.h (type_code): Add TYPE_CODE_INTERNAL_FUNCTION.
* parse.c (write_exp_string): Remove duplicate word in comment.
* python/python-function.c: New file.
* python/python-internal.h (gdbpy_initialize_functions): Add
prototype.
* python/python.c (_initialize_python): Call
gdbpy_initialize_functions.
* valprint.c (value_check_printable): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* value.c: Include "cli/cli-decode.h".
(internal_function): New struct.
(functionlist, internal_fn_type): New static variables.
(lookup_only_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(create_internalvar): Likewise. Initialize new field.
(set_internal_var): Fix typo in comment. Don't allow assignment
to canonical variable.
(value_create_internal_function, value_internal_function_name,
call_internal_function, function_command, function_destroyer,
add_internal_function): New functions.
(_initialize_values): Create `function' placeholder command.
Initialize internal_fn_type.
* value.h (lookup_only_internalvar, create_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(internal_function_fn, add_internal_function, call_internal_function,
value_internal_function_name): Add prototypes.
(struct internalvar) <canonical>: New field.
gdb/doc/
2008-03-05 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Convenience Vars): Document convenience functions.
(Functions In Python): New node.
(Python API): Update.
gdb/testsuite/
2009-03-05 Thiago Jung Bauermann <bauerman@br.ibm.com>
* gdb.python/python-function.exp: New file.
2009-03-21 03:03:56 +00:00
|
|
|
|
int argc,
|
|
|
|
|
struct value **argv);
|
|
|
|
|
|
2019-11-15 16:49:17 -07:00
|
|
|
|
/* Add a new internal function. NAME is the name of the function; DOC
|
|
|
|
|
is a documentation string describing the function. HANDLER is
|
|
|
|
|
called when the function is invoked. COOKIE is an arbitrary
|
|
|
|
|
pointer which is passed to HANDLER and is intended for "user
|
|
|
|
|
data". */
|
|
|
|
|
|
|
|
|
|
extern void add_internal_function (const char *name, const char *doc,
|
|
|
|
|
internal_function_fn handler,
|
|
|
|
|
void *cookie);
|
|
|
|
|
|
|
|
|
|
/* This overload takes an allocated documentation string. */
|
|
|
|
|
|
2019-11-15 16:56:20 -07:00
|
|
|
|
extern void add_internal_function (gdb::unique_xmalloc_ptr<char> &&name,
|
2019-11-15 16:49:17 -07:00
|
|
|
|
gdb::unique_xmalloc_ptr<char> &&doc,
|
|
|
|
|
internal_function_fn handler,
|
|
|
|
|
void *cookie);
|
gdb/
2009-03-05 Tom Tromey <tromey@redhat.com>
Add support for convenience functions in Python.
* Makefile.in (SUBDIR_PYTHON_OBS): Add python-function.o.
(SUBDIR_PYTHON_SRCS): Add python-function.c.
(python-function.o): New target.
* eval.c: Include "python/python.h" and <ctype.h>.
(evaluate_subexp_standard): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* gdbtypes.h (type_code): Add TYPE_CODE_INTERNAL_FUNCTION.
* parse.c (write_exp_string): Remove duplicate word in comment.
* python/python-function.c: New file.
* python/python-internal.h (gdbpy_initialize_functions): Add
prototype.
* python/python.c (_initialize_python): Call
gdbpy_initialize_functions.
* valprint.c (value_check_printable): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* value.c: Include "cli/cli-decode.h".
(internal_function): New struct.
(functionlist, internal_fn_type): New static variables.
(lookup_only_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(create_internalvar): Likewise. Initialize new field.
(set_internal_var): Fix typo in comment. Don't allow assignment
to canonical variable.
(value_create_internal_function, value_internal_function_name,
call_internal_function, function_command, function_destroyer,
add_internal_function): New functions.
(_initialize_values): Create `function' placeholder command.
Initialize internal_fn_type.
* value.h (lookup_only_internalvar, create_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(internal_function_fn, add_internal_function, call_internal_function,
value_internal_function_name): Add prototypes.
(struct internalvar) <canonical>: New field.
gdb/doc/
2008-03-05 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Convenience Vars): Document convenience functions.
(Functions In Python): New node.
(Python API): Update.
gdb/testsuite/
2009-03-05 Thiago Jung Bauermann <bauerman@br.ibm.com>
* gdb.python/python-function.exp: New file.
2009-03-21 03:03:56 +00:00
|
|
|
|
|
* python/python-internal.h (struct language_defn): Declare.
(python_gdbarch, python_language): Likewise.
(ensure_python_env): Add prototype.
(make_cleanup_py_restore_gil): Remove prototype.
* python/python.c: Include "arch-utils.h", "value.h" and "language.h".
(python_gdbarch, python_language): New global variables.
(struct python_env): New data type.
(ensure_python_env, restore_python_env): New functions.
(eval_python_from_control_command): Call ensure_python_env to
install current architecture and language.
(python_command, gdbpy_new_objfile): Likewise.
* python/python-cmd.c: Include "arch-utils.h" and "language.h".
(cmdpy_destroyer, cmdpy_function, cmdpy_completer): Call
ensure_python_env.
* python/python-type.c (clean_up_objfile_types): Likewise.
* python/python-objfile.c: Include "language.h".
(clean_up_objfile): Call ensure_python_env.
* python/python-prettyprint.c (apply_val_pretty_printer): Likewise.
(apply_varobj_pretty_printer): Do not call PyGILState_Ensure.
* varobj.c (varobj_ensure_python_env): New helper function.
(varobj_get_display_hint, update_dynamic_varobj_children,
install_default_visualizer, varobj_set_visualizer, free_variable,
value_get_print_value): Call it.
(value_get_print_value): Add varobj argument instead of pretty
printer argument. Update all callers.
* python/python-utils.c (py_gil_restore, make_cleanup_py_restore_gil):
Remove.
* value.h (internal_function_fn): Add GDBARCH and LANGUAGE argument.
(call_internal_function): Likewise.
* value.c (call_internal_function): Likewise. Pass to handler.
* eval.c (evaluate_subexp_standard): Update call.
* python/python-function.c: Include "language.h".
(fnpy_call): Add GDBARCH and LANGAUAGE arguments and call
make_cleanup_python_env.
* python/python-value.c (builtin_type_pyint, builtin_type_pyfloat,
builtin_type_pylong, builtin_type_pybool, builtin_type_pychar,
valpy_str): Use python_gdbarch and python_language instead of
current_gdbarch and current_language.
* python/python-type.c (typy_lookup_typename): Likewise.
2009-07-02 17:04:23 +00:00
|
|
|
|
struct value *call_internal_function (struct gdbarch *gdbarch,
|
|
|
|
|
const struct language_defn *language,
|
|
|
|
|
struct value *function,
|
gdb/
2009-03-05 Tom Tromey <tromey@redhat.com>
Add support for convenience functions in Python.
* Makefile.in (SUBDIR_PYTHON_OBS): Add python-function.o.
(SUBDIR_PYTHON_SRCS): Add python-function.c.
(python-function.o): New target.
* eval.c: Include "python/python.h" and <ctype.h>.
(evaluate_subexp_standard): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* gdbtypes.h (type_code): Add TYPE_CODE_INTERNAL_FUNCTION.
* parse.c (write_exp_string): Remove duplicate word in comment.
* python/python-function.c: New file.
* python/python-internal.h (gdbpy_initialize_functions): Add
prototype.
* python/python.c (_initialize_python): Call
gdbpy_initialize_functions.
* valprint.c (value_check_printable): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* value.c: Include "cli/cli-decode.h".
(internal_function): New struct.
(functionlist, internal_fn_type): New static variables.
(lookup_only_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(create_internalvar): Likewise. Initialize new field.
(set_internal_var): Fix typo in comment. Don't allow assignment
to canonical variable.
(value_create_internal_function, value_internal_function_name,
call_internal_function, function_command, function_destroyer,
add_internal_function): New functions.
(_initialize_values): Create `function' placeholder command.
Initialize internal_fn_type.
* value.h (lookup_only_internalvar, create_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(internal_function_fn, add_internal_function, call_internal_function,
value_internal_function_name): Add prototypes.
(struct internalvar) <canonical>: New field.
gdb/doc/
2008-03-05 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Convenience Vars): Document convenience functions.
(Functions In Python): New node.
(Python API): Update.
gdb/testsuite/
2009-03-05 Thiago Jung Bauermann <bauerman@br.ibm.com>
* gdb.python/python-function.exp: New file.
2009-03-21 03:03:56 +00:00
|
|
|
|
int argc, struct value **argv);
|
|
|
|
|
|
2020-12-04 08:15:14 -07:00
|
|
|
|
const char *value_internal_function_name (struct value *);
|
gdb/
2009-03-05 Tom Tromey <tromey@redhat.com>
Add support for convenience functions in Python.
* Makefile.in (SUBDIR_PYTHON_OBS): Add python-function.o.
(SUBDIR_PYTHON_SRCS): Add python-function.c.
(python-function.o): New target.
* eval.c: Include "python/python.h" and <ctype.h>.
(evaluate_subexp_standard): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* gdbtypes.h (type_code): Add TYPE_CODE_INTERNAL_FUNCTION.
* parse.c (write_exp_string): Remove duplicate word in comment.
* python/python-function.c: New file.
* python/python-internal.h (gdbpy_initialize_functions): Add
prototype.
* python/python.c (_initialize_python): Call
gdbpy_initialize_functions.
* valprint.c (value_check_printable): Handle values of type
TYPE_CODE_INTERNAL_FUNCTION.
* value.c: Include "cli/cli-decode.h".
(internal_function): New struct.
(functionlist, internal_fn_type): New static variables.
(lookup_only_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(create_internalvar): Likewise. Initialize new field.
(set_internal_var): Fix typo in comment. Don't allow assignment
to canonical variable.
(value_create_internal_function, value_internal_function_name,
call_internal_function, function_command, function_destroyer,
add_internal_function): New functions.
(_initialize_values): Create `function' placeholder command.
Initialize internal_fn_type.
* value.h (lookup_only_internalvar, create_internalvar,
lookup_internalvar): Add const qualifier to name argument.
(internal_function_fn, add_internal_function, call_internal_function,
value_internal_function_name): Add prototypes.
(struct internalvar) <canonical>: New field.
gdb/doc/
2008-03-05 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Convenience Vars): Document convenience functions.
(Functions In Python): New node.
(Python API): Update.
gdb/testsuite/
2009-03-05 Thiago Jung Bauermann <bauerman@br.ibm.com>
* gdb.python/python-function.exp: New file.
2009-03-21 03:03:56 +00:00
|
|
|
|
|
2019-03-29 17:34:54 -04:00
|
|
|
|
/* Destroy the values currently allocated. This is called when GDB is
|
|
|
|
|
exiting (e.g., on quit_force). */
|
|
|
|
|
extern void finalize_values ();
|
|
|
|
|
|
Fix fixed-point binary operation type handling
Testing showed that gdb was not correctly handling some fixed-point
binary operations correctly.
Addition and subtraction worked by casting the result to the type of
left hand operand. So, "fixed+int" had a different type -- and
different value -- from "int+fixed".
Furthermore, for multiplication and division, it does not make sense
to first cast both sides to the fixed-point type. For example, this
can prevent "f * 1" from yielding "f", if 1 is not in the domain of
"f". Instead, this patch changes gdb to use the value. (This is
somewhat different from Ada semantics, as those can yield a "universal
fixed point".)
This includes a new test case. It is only run in "minimal" mode, as
the old-style fixed point works differently, and is obsolete, so I
have no plans to change it.
gdb/ChangeLog
2021-01-06 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_evaluate_subexp) <BINOP_ADD, BINOP_SUB>:
Do not cast result.
* valarith.c (fixed_point_binop): Handle multiplication
and division specially.
* valops.c (value_to_gdb_mpq): New function.
(value_cast_to_fixed_point): Use it.
gdb/testsuite/ChangeLog
2021-01-06 Tom Tromey <tromey@adacore.com>
* gdb.ada/fixed_points/pck.ads (Delta4): New constant.
(FP4_Type): New type.
(FP4_Var): New variable.
* gdb.ada/fixed_points/fixed_points.adb: Update.
* gdb.ada/fixed_points.exp: Add tests for binary operators.
2021-01-06 13:47:48 -07:00
|
|
|
|
/* Convert VALUE to a gdb_mpq. The caller must ensure that VALUE is
|
|
|
|
|
of floating-point, fixed-point, or integer type. */
|
|
|
|
|
extern gdb_mpq value_to_gdb_mpq (struct value *value);
|
|
|
|
|
|
gdb: check max-value-size when reading strings for printf
I noticed that the printf code for strings, printf_c_string and
printf_wide_c_string, don't take max-value-size into account, but do
load a complete string from the inferior into a GDB buffer.
As such it would be possible for an badly behaved inferior to cause
GDB to try and allocate an excessively large buffer, potentially
crashing GDB, or at least causing GDB to swap lots, which isn't
great.
We already have a setting to protect against this sort of thing, the
'max-value-size'. So this commit updates the two function mentioned
above to check the max-value-size and give an error if the
max-value-size is exceeded.
If the max-value-size is exceeded, I chose to continue reading
inferior memory to figure out how long the string actually is, we just
don't store the results. The benefit of this is that when we give the
user an error we can tell the user how big the string actually is,
which would allow them to correctly adjust max-value-size, if that's
what they choose to do.
The default for max-value-size is 64k so there should be no user
visible changes after this commit, unless the user was previously
printing very large strings. If that is the case then the user will
now need to increase max-value-size.
2023-05-31 21:41:48 +01:00
|
|
|
|
/* Return true if LEN (in bytes) exceeds the max-value-size setting,
|
|
|
|
|
otherwise, return false. If the user has disabled (set to unlimited)
|
|
|
|
|
the max-value-size setting then this function will always return false. */
|
|
|
|
|
extern bool exceeds_max_value_size (ULONGEST length);
|
|
|
|
|
|
GDB: Introduce limited array lengths while printing values
This commit introduces the idea of loading only part of an array in
order to print it, what I call "limited length" arrays.
The motivation behind this work is to make it possible to print slices
of very large arrays, where very large means bigger than
`max-value-size'.
Consider this GDB session with the current GDB:
(gdb) set max-value-size 100
(gdb) p large_1d_array
value requires 400 bytes, which is more than max-value-size
(gdb) p -elements 10 -- large_1d_array
value requires 400 bytes, which is more than max-value-size
notice that the request to print 10 elements still fails, even though 10
elements should be less than the max-value-size. With a patched version
of GDB:
(gdb) p -elements 10 -- large_1d_array
$1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9...}
So now the print has succeeded. It also has loaded `max-value-size'
worth of data into value history, so the recorded value can be accessed
consistently:
(gdb) p -elements 10 -- $1
$2 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9...}
(gdb) p $1
$3 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, <unavailable> <repeats 75 times>}
(gdb)
Accesses with other languages work similarly, although for Ada only
C-style [] array element/dimension accesses use history. For both Ada
and Fortran () array element/dimension accesses go straight to the
inferior, bypassing the value history just as with C pointers.
Co-Authored-By: Maciej W. Rozycki <macro@embecosm.com>
2023-02-10 23:49:19 +00:00
|
|
|
|
/* While an instance of this class is live, and array values that are
|
|
|
|
|
created, that are larger than max_value_size, will be restricted in size
|
|
|
|
|
to a particular number of elements. */
|
|
|
|
|
|
|
|
|
|
struct scoped_array_length_limiting
|
|
|
|
|
{
|
|
|
|
|
/* Limit any large array values to only contain ELEMENTS elements. */
|
|
|
|
|
scoped_array_length_limiting (int elements);
|
|
|
|
|
|
|
|
|
|
/* Restore the previous array value limit. */
|
|
|
|
|
~scoped_array_length_limiting ();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
/* Used to hold the previous array value element limit. */
|
|
|
|
|
gdb::optional<int> m_old_value;
|
|
|
|
|
};
|
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
#endif /* !defined (VALUE_H) */
|