2012-04-28 04:47:57 +08:00
|
|
|
|
/* SystemTap probe support for GDB.
|
|
|
|
|
|
2019-01-01 14:01:51 +08:00
|
|
|
|
Copyright (C) 2012-2019 Free Software Foundation, Inc.
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
#include "stap-probe.h"
|
|
|
|
|
#include "probe.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-06 10:29:24 +08:00
|
|
|
|
#include "gdbsupport/vec.h"
|
2012-04-28 04:47:57 +08:00
|
|
|
|
#include "ui-out.h"
|
|
|
|
|
#include "objfiles.h"
|
|
|
|
|
#include "arch-utils.h"
|
|
|
|
|
#include "command.h"
|
|
|
|
|
#include "gdbcmd.h"
|
|
|
|
|
#include "filenames.h"
|
|
|
|
|
#include "value.h"
|
|
|
|
|
#include "ax.h"
|
|
|
|
|
#include "ax-gdb.h"
|
|
|
|
|
#include "complaints.h"
|
|
|
|
|
#include "cli/cli-utils.h"
|
|
|
|
|
#include "linespec.h"
|
|
|
|
|
#include "user-regs.h"
|
|
|
|
|
#include "parser-defs.h"
|
|
|
|
|
#include "language.h"
|
|
|
|
|
#include "elf-bfd.h"
|
|
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
|
|
/* The name of the SystemTap section where we will find information about
|
|
|
|
|
the probes. */
|
|
|
|
|
|
|
|
|
|
#define STAP_BASE_SECTION_NAME ".stapsdt.base"
|
|
|
|
|
|
|
|
|
|
/* Should we display debug information for the probe's argument expression
|
|
|
|
|
parsing? */
|
|
|
|
|
|
2012-08-02 17:36:40 +08:00
|
|
|
|
static unsigned int stap_expression_debug = 0;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* The various possibilities of bitness defined for a probe's argument.
|
|
|
|
|
|
|
|
|
|
The relationship is:
|
|
|
|
|
|
|
|
|
|
- STAP_ARG_BITNESS_UNDEFINED: The user hasn't specified the bitness.
|
2014-05-03 04:50:45 +08:00
|
|
|
|
- STAP_ARG_BITNESS_8BIT_UNSIGNED: argument string starts with `1@'.
|
|
|
|
|
- STAP_ARG_BITNESS_8BIT_SIGNED: argument string starts with `-1@'.
|
|
|
|
|
- STAP_ARG_BITNESS_16BIT_UNSIGNED: argument string starts with `2@'.
|
|
|
|
|
- STAP_ARG_BITNESS_16BIT_SIGNED: argument string starts with `-2@'.
|
2012-04-28 04:47:57 +08:00
|
|
|
|
- STAP_ARG_BITNESS_32BIT_UNSIGNED: argument string starts with `4@'.
|
|
|
|
|
- STAP_ARG_BITNESS_32BIT_SIGNED: argument string starts with `-4@'.
|
|
|
|
|
- STAP_ARG_BITNESS_64BIT_UNSIGNED: argument string starts with `8@'.
|
|
|
|
|
- STAP_ARG_BITNESS_64BIT_SIGNED: argument string starts with `-8@'. */
|
|
|
|
|
|
|
|
|
|
enum stap_arg_bitness
|
|
|
|
|
{
|
|
|
|
|
STAP_ARG_BITNESS_UNDEFINED,
|
2014-05-03 04:50:45 +08:00
|
|
|
|
STAP_ARG_BITNESS_8BIT_UNSIGNED,
|
|
|
|
|
STAP_ARG_BITNESS_8BIT_SIGNED,
|
|
|
|
|
STAP_ARG_BITNESS_16BIT_UNSIGNED,
|
|
|
|
|
STAP_ARG_BITNESS_16BIT_SIGNED,
|
2012-04-28 04:47:57 +08:00
|
|
|
|
STAP_ARG_BITNESS_32BIT_UNSIGNED,
|
|
|
|
|
STAP_ARG_BITNESS_32BIT_SIGNED,
|
|
|
|
|
STAP_ARG_BITNESS_64BIT_UNSIGNED,
|
|
|
|
|
STAP_ARG_BITNESS_64BIT_SIGNED,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* The following structure represents a single argument for the probe. */
|
|
|
|
|
|
|
|
|
|
struct stap_probe_arg
|
|
|
|
|
{
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
/* Constructor for stap_probe_arg. */
|
|
|
|
|
stap_probe_arg (enum stap_arg_bitness bitness_, struct type *atype_,
|
|
|
|
|
expression_up &&aexpr_)
|
|
|
|
|
: bitness (bitness_), atype (atype_), aexpr (std::move (aexpr_))
|
|
|
|
|
{}
|
|
|
|
|
|
2012-04-28 04:47:57 +08:00
|
|
|
|
/* The bitness of this argument. */
|
|
|
|
|
enum stap_arg_bitness bitness;
|
|
|
|
|
|
|
|
|
|
/* The corresponding `struct type *' to the bitness. */
|
|
|
|
|
struct type *atype;
|
|
|
|
|
|
|
|
|
|
/* The argument converted to an internal GDB expression. */
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
expression_up aexpr;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
};
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
/* Class that implements the static probe methods for "stap" probes. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
class stap_static_probe_ops : public static_probe_ops
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
public:
|
|
|
|
|
/* See probe.h. */
|
|
|
|
|
bool is_linespec (const char **linespecp) const override;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
/* See probe.h. */
|
2019-05-01 13:47:54 +08:00
|
|
|
|
void get_probes (std::vector<std::unique_ptr<probe>> *probesp,
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
struct objfile *objfile) const override;
|
|
|
|
|
|
|
|
|
|
/* See probe.h. */
|
|
|
|
|
const char *type_name () const override;
|
|
|
|
|
|
|
|
|
|
/* See probe.h. */
|
|
|
|
|
std::vector<struct info_probe_column> gen_info_probes_table_header
|
|
|
|
|
() const override;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* SystemTap static_probe_ops. */
|
|
|
|
|
|
2018-12-22 00:14:28 +08:00
|
|
|
|
const stap_static_probe_ops stap_static_probe_ops {};
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
|
|
|
|
|
class stap_probe : public probe
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/* Constructor for stap_probe. */
|
|
|
|
|
stap_probe (std::string &&name_, std::string &&provider_, CORE_ADDR address_,
|
|
|
|
|
struct gdbarch *arch_, CORE_ADDR sem_addr, const char *args_text)
|
|
|
|
|
: probe (std::move (name_), std::move (provider_), address_, arch_),
|
|
|
|
|
m_sem_addr (sem_addr),
|
|
|
|
|
m_have_parsed_args (false), m_unparsed_args_text (args_text)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
/* See probe.h. */
|
|
|
|
|
CORE_ADDR get_relocated_address (struct objfile *objfile) override;
|
|
|
|
|
|
|
|
|
|
/* See probe.h. */
|
2019-08-21 22:24:02 +08:00
|
|
|
|
unsigned get_argument_count (struct gdbarch *gdbarch) override;
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
|
|
|
|
|
/* See probe.h. */
|
|
|
|
|
bool can_evaluate_arguments () const override;
|
|
|
|
|
|
|
|
|
|
/* See probe.h. */
|
|
|
|
|
struct value *evaluate_argument (unsigned n,
|
|
|
|
|
struct frame_info *frame) override;
|
|
|
|
|
|
|
|
|
|
/* See probe.h. */
|
|
|
|
|
void compile_to_ax (struct agent_expr *aexpr,
|
|
|
|
|
struct axs_value *axs_value,
|
|
|
|
|
unsigned n) override;
|
|
|
|
|
|
|
|
|
|
/* See probe.h. */
|
|
|
|
|
void set_semaphore (struct objfile *objfile,
|
|
|
|
|
struct gdbarch *gdbarch) override;
|
|
|
|
|
|
|
|
|
|
/* See probe.h. */
|
|
|
|
|
void clear_semaphore (struct objfile *objfile,
|
|
|
|
|
struct gdbarch *gdbarch) override;
|
|
|
|
|
|
|
|
|
|
/* See probe.h. */
|
|
|
|
|
const static_probe_ops *get_static_ops () const override;
|
|
|
|
|
|
|
|
|
|
/* See probe.h. */
|
|
|
|
|
std::vector<const char *> gen_info_probes_table_values () const override;
|
|
|
|
|
|
|
|
|
|
/* Return argument N of probe.
|
|
|
|
|
|
|
|
|
|
If the probe's arguments have not been parsed yet, parse them. If
|
|
|
|
|
there are no arguments, throw an exception (error). Otherwise,
|
|
|
|
|
return the requested argument. */
|
|
|
|
|
struct stap_probe_arg *get_arg_by_number (unsigned n,
|
|
|
|
|
struct gdbarch *gdbarch)
|
|
|
|
|
{
|
|
|
|
|
if (!m_have_parsed_args)
|
|
|
|
|
this->parse_arguments (gdbarch);
|
|
|
|
|
|
|
|
|
|
gdb_assert (m_have_parsed_args);
|
|
|
|
|
if (m_parsed_args.empty ())
|
|
|
|
|
internal_error (__FILE__, __LINE__,
|
|
|
|
|
_("Probe '%s' apparently does not have arguments, but \n"
|
|
|
|
|
"GDB is requesting its argument number %u anyway. "
|
|
|
|
|
"This should not happen. Please report this bug."),
|
|
|
|
|
this->get_name ().c_str (), n);
|
|
|
|
|
|
|
|
|
|
if (n > m_parsed_args.size ())
|
|
|
|
|
internal_error (__FILE__, __LINE__,
|
|
|
|
|
_("Probe '%s' has %d arguments, but GDB is requesting\n"
|
|
|
|
|
"argument %u. This should not happen. Please\n"
|
|
|
|
|
"report this bug."),
|
|
|
|
|
this->get_name ().c_str (),
|
|
|
|
|
(int) m_parsed_args.size (), n);
|
|
|
|
|
|
|
|
|
|
return &m_parsed_args[n];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Function which parses an argument string from the probe,
|
|
|
|
|
correctly splitting the arguments and storing their information
|
|
|
|
|
in properly ways.
|
|
|
|
|
|
|
|
|
|
Consider the following argument string (x86 syntax):
|
|
|
|
|
|
|
|
|
|
`4@%eax 4@$10'
|
|
|
|
|
|
|
|
|
|
We have two arguments, `%eax' and `$10', both with 32-bit
|
|
|
|
|
unsigned bitness. This function basically handles them, properly
|
|
|
|
|
filling some structures with this information. */
|
|
|
|
|
void parse_arguments (struct gdbarch *gdbarch);
|
|
|
|
|
|
|
|
|
|
private:
|
2012-04-28 04:47:57 +08:00
|
|
|
|
/* If the probe has a semaphore associated, then this is the value of
|
change probes to be program-space-independent
This changes the probes to be independent of the program space.
After this, when a probe's address is needed, it is determined by
applying offsets at the point of use.
This introduces a bound_probe object, similar to bound minimal
symbols. Objects of this type are used when it's necessary to pass a
probe and its corresponding objfile.
This removes the backlink from probe to objfile, which was primarily
used to fetch the architecture to use.
This adds a get_probe_address function which calls a probe method to
compute the probe's relocated address. Similarly, it adds an objfile
parameter to the semaphore methods so they can do the relocation
properly as well.
2014-03-03 Tom Tromey <tromey@redhat.com>
* break-catch-throw.c (fetch_probe_arguments): Use bound probes.
* breakpoint.c (create_longjmp_master_breakpoint): Use
get_probe_address.
(add_location_to_breakpoint, bkpt_probe_insert_location)
(bkpt_probe_remove_location): Update.
* breakpoint.h (struct bp_location) <probe>: Now a bound_probe.
* elfread.c (elf_symfile_relocate_probe): Remove.
(elf_probe_fns): Update.
(insert_exception_resume_breakpoint): Change type of "probe"
parameter to bound_probe.
(check_exception_resume): Update.
* objfiles.c (objfile_relocate1): Don't relocate probes.
* probe.c (bound_probe_s): New typedef.
(parse_probes): Use get_probe_address. Set sal's objfile.
(find_probe_by_pc): Return a bound_probe.
(collect_probes): Return a VEC(bound_probe_s).
(compare_probes): Update.
(gen_ui_out_table_header_info): Change type of "probes"
parameter. Update.
(info_probes_for_ops): Update.
(get_probe_address): New function.
(probe_safe_evaluate_at_pc): Update.
* probe.h (struct probe_ops) <get_probe_address>: New field.
<set_semaphore, clear_semaphore>: Add objfile parameter.
(struct probe) <objfile>: Remove field.
<arch>: New field.
<address>: Update comment.
(struct bound_probe): New.
(find_probe_by_pc): Return a bound_probe.
(get_probe_address): Declare.
* solib-svr4.c (struct probe_and_action) <address>: New field.
(hash_probe_and_action, equal_probe_and_action): Update.
(register_solib_event_probe): Add address parameter.
(solib_event_probe_at): Update.
(svr4_create_probe_breakpoints): Add objfile parameter. Use
get_probe_address.
* stap-probe.c (struct stap_probe) <sem_addr>: Update comment.
(stap_get_probe_address): New function.
(stap_can_evaluate_probe_arguments, compute_probe_arg)
(compile_probe_arg): Update.
(stap_set_semaphore, stap_clear_semaphore): Compute semaphore's
address.
(handle_stap_probe): Don't relocate the probe.
(stap_relocate): Remove.
(stap_gen_info_probes_table_values): Update.
(stap_probe_ops): Remove stap_relocate.
* symfile-debug.c (debug_sym_relocate_probe): Remove.
(debug_sym_probe_fns): Update.
* symfile.h (struct sym_probe_fns) <sym_relocate_probe>: Remove.
* symtab.c (init_sal): Use memset.
* symtab.h (struct symtab_and_line) <objfile>: New field.
* tracepoint.c (start_tracing, stop_tracing): Update.
2013-12-03 04:58:59 +08:00
|
|
|
|
it, relative to SECT_OFF_DATA. */
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
CORE_ADDR m_sem_addr;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
/* True if the arguments have been parsed. */
|
|
|
|
|
bool m_have_parsed_args;
|
2013-12-24 06:48:08 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
/* The text version of the probe's arguments, unparsed. */
|
|
|
|
|
const char *m_unparsed_args_text;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
/* Information about each argument. This is an array of `stap_probe_arg',
|
|
|
|
|
with each entry representing one argument. This is only valid if
|
|
|
|
|
M_ARGS_PARSED is true. */
|
|
|
|
|
std::vector<struct stap_probe_arg> m_parsed_args;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* When parsing the arguments, we have to establish different precedences
|
|
|
|
|
for the various kinds of asm operators. This enumeration represents those
|
|
|
|
|
precedences.
|
|
|
|
|
|
|
|
|
|
This logic behind this is available at
|
|
|
|
|
<http://sourceware.org/binutils/docs/as/Infix-Ops.html#Infix-Ops>, or using
|
|
|
|
|
the command "info '(as)Infix Ops'". */
|
|
|
|
|
|
|
|
|
|
enum stap_operand_prec
|
|
|
|
|
{
|
|
|
|
|
/* Lowest precedence, used for non-recognized operands or for the beginning
|
|
|
|
|
of the parsing process. */
|
|
|
|
|
STAP_OPERAND_PREC_NONE = 0,
|
|
|
|
|
|
|
|
|
|
/* Precedence of logical OR. */
|
|
|
|
|
STAP_OPERAND_PREC_LOGICAL_OR,
|
|
|
|
|
|
|
|
|
|
/* Precedence of logical AND. */
|
|
|
|
|
STAP_OPERAND_PREC_LOGICAL_AND,
|
|
|
|
|
|
|
|
|
|
/* Precedence of additive (plus, minus) and comparative (equal, less,
|
|
|
|
|
greater-than, etc) operands. */
|
|
|
|
|
STAP_OPERAND_PREC_ADD_CMP,
|
|
|
|
|
|
|
|
|
|
/* Precedence of bitwise operands (bitwise OR, XOR, bitwise AND,
|
|
|
|
|
logical NOT). */
|
|
|
|
|
STAP_OPERAND_PREC_BITWISE,
|
|
|
|
|
|
|
|
|
|
/* Precedence of multiplicative operands (multiplication, division,
|
|
|
|
|
remainder, left shift and right shift). */
|
|
|
|
|
STAP_OPERAND_PREC_MUL
|
|
|
|
|
};
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
static void stap_parse_argument_1 (struct stap_parse_info *p, bool has_lhs,
|
2012-04-28 04:47:57 +08:00
|
|
|
|
enum stap_operand_prec prec);
|
|
|
|
|
|
|
|
|
|
static void stap_parse_argument_conditionally (struct stap_parse_info *p);
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
/* Returns true if *S is an operator, false otherwise. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
static bool stap_is_operator (const char *op);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
show_stapexpressiondebug (struct ui_file *file, int from_tty,
|
|
|
|
|
struct cmd_list_element *c, const char *value)
|
|
|
|
|
{
|
|
|
|
|
fprintf_filtered (file, _("SystemTap Probe expression debugging is %s.\n"),
|
|
|
|
|
value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns the operator precedence level of OP, or STAP_OPERAND_PREC_NONE
|
|
|
|
|
if the operator code was not recognized. */
|
|
|
|
|
|
|
|
|
|
static enum stap_operand_prec
|
|
|
|
|
stap_get_operator_prec (enum exp_opcode op)
|
|
|
|
|
{
|
|
|
|
|
switch (op)
|
|
|
|
|
{
|
|
|
|
|
case BINOP_LOGICAL_OR:
|
|
|
|
|
return STAP_OPERAND_PREC_LOGICAL_OR;
|
|
|
|
|
|
|
|
|
|
case BINOP_LOGICAL_AND:
|
|
|
|
|
return STAP_OPERAND_PREC_LOGICAL_AND;
|
|
|
|
|
|
|
|
|
|
case BINOP_ADD:
|
|
|
|
|
case BINOP_SUB:
|
|
|
|
|
case BINOP_EQUAL:
|
|
|
|
|
case BINOP_NOTEQUAL:
|
|
|
|
|
case BINOP_LESS:
|
|
|
|
|
case BINOP_LEQ:
|
|
|
|
|
case BINOP_GTR:
|
|
|
|
|
case BINOP_GEQ:
|
|
|
|
|
return STAP_OPERAND_PREC_ADD_CMP;
|
|
|
|
|
|
|
|
|
|
case BINOP_BITWISE_IOR:
|
|
|
|
|
case BINOP_BITWISE_AND:
|
|
|
|
|
case BINOP_BITWISE_XOR:
|
|
|
|
|
case UNOP_LOGICAL_NOT:
|
|
|
|
|
return STAP_OPERAND_PREC_BITWISE;
|
|
|
|
|
|
|
|
|
|
case BINOP_MUL:
|
|
|
|
|
case BINOP_DIV:
|
|
|
|
|
case BINOP_REM:
|
|
|
|
|
case BINOP_LSH:
|
|
|
|
|
case BINOP_RSH:
|
|
|
|
|
return STAP_OPERAND_PREC_MUL;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return STAP_OPERAND_PREC_NONE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 04:11:20 +08:00
|
|
|
|
/* Given S, read the operator in it. Return the EXP_OPCODE which
|
|
|
|
|
represents the operator detected, or throw an error if no operator
|
|
|
|
|
was found. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
2012-05-04 04:04:06 +08:00
|
|
|
|
static enum exp_opcode
|
|
|
|
|
stap_get_opcode (const char **s)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
const char c = **s;
|
2012-05-04 04:04:06 +08:00
|
|
|
|
enum exp_opcode op;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
*s += 1;
|
|
|
|
|
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case '*':
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_MUL;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '/':
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_DIV;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '%':
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_REM;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '<':
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_LESS;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
if (**s == '<')
|
|
|
|
|
{
|
|
|
|
|
*s += 1;
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_LSH;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
else if (**s == '=')
|
|
|
|
|
{
|
|
|
|
|
*s += 1;
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_LEQ;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
else if (**s == '>')
|
|
|
|
|
{
|
|
|
|
|
*s += 1;
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_NOTEQUAL;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '>':
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_GTR;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
if (**s == '>')
|
|
|
|
|
{
|
|
|
|
|
*s += 1;
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_RSH;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
else if (**s == '=')
|
|
|
|
|
{
|
|
|
|
|
*s += 1;
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_GEQ;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '|':
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_BITWISE_IOR;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
if (**s == '|')
|
|
|
|
|
{
|
|
|
|
|
*s += 1;
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_LOGICAL_OR;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '&':
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_BITWISE_AND;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
if (**s == '&')
|
|
|
|
|
{
|
|
|
|
|
*s += 1;
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_LOGICAL_AND;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '^':
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_BITWISE_XOR;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '!':
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = UNOP_LOGICAL_NOT;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '+':
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_ADD;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '-':
|
2012-05-04 04:04:06 +08:00
|
|
|
|
op = BINOP_SUB;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '=':
|
2012-05-04 04:04:06 +08:00
|
|
|
|
gdb_assert (**s == '=');
|
|
|
|
|
op = BINOP_EQUAL;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
Improve error reporting when handling SystemTap SDT probes
This patch improves the error reporting when handling SystemTap SDT
probes. "Handling", in this case, mostly means "parsing".
On gdb/probe.h, only trivial changes on functions' comments in order
to explicitly mention that some of them can throw exceptions. This is
just to make the API a bit more clear.
On gdb/stap-probe.c, I have s/internal_error/error/ on two functions
that are responsible for parsing specific bits of the probes'
arguments: stap_get_opcode and stap_get_expected_argument_type. It is
not correct to call internal_error on such situations because it is
not really GDB's fault if the probes have malformed arguments. I also
improved the error reported on stap_get_expected_argument_type by also
including the probe name on it.
Aside from that, and perhaps most importantly, I added a check on
stap_get_arg to make sure that we don't try to extract an argument
from a probe that has no arguments. This check issues an
internal_error, because it really means that GDB is doing something it
shouldn't.
Although it can be considered almost trivial, and despite the fact
that I am the maintainer for this part of the code, I am posting this
patch for review. I will wait a few days, and if nobody has anything
to say, I will go ahead and push it.
gdb/ChangeLog:
2015-09-01 Sergio Durigan Junior <sergiodj@redhat.com>
* probe.h (struct probe_ops) <get_probe_argument_count,
evaluate_probe_argument, enable_probe, disable_probe>: Mention in
the comment that the function can throw an exception.
(get_probe_argument_count): Likewise.
(evaluate_probe_argument): Likewise.
* stap-probe.c (stap_get_opcode): Call error instead of
internal_error.
(stap_get_expected_argument_type): Likewise. Add argument
'probe'. Improve error message by mentioning the probe's name.
(stap_parse_probe_arguments): Adjust call to
stap_get_expected_argument_type.
(stap_get_arg): Add comment. Assert that 'probe->args_parsed' is
not zero. Call internal_error if GDB requests an argument but the
probe has no arguments.
2015-08-22 06:13:46 +08:00
|
|
|
|
error (_("Invalid opcode in expression `%s' for SystemTap"
|
|
|
|
|
"probe"), *s);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2012-05-04 04:04:06 +08:00
|
|
|
|
return op;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Given the bitness of the argument, represented by B, return the
|
2019-05-17 04:11:20 +08:00
|
|
|
|
corresponding `struct type *', or throw an error if B is
|
|
|
|
|
unknown. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
static struct type *
|
|
|
|
|
stap_get_expected_argument_type (struct gdbarch *gdbarch,
|
Improve error reporting when handling SystemTap SDT probes
This patch improves the error reporting when handling SystemTap SDT
probes. "Handling", in this case, mostly means "parsing".
On gdb/probe.h, only trivial changes on functions' comments in order
to explicitly mention that some of them can throw exceptions. This is
just to make the API a bit more clear.
On gdb/stap-probe.c, I have s/internal_error/error/ on two functions
that are responsible for parsing specific bits of the probes'
arguments: stap_get_opcode and stap_get_expected_argument_type. It is
not correct to call internal_error on such situations because it is
not really GDB's fault if the probes have malformed arguments. I also
improved the error reported on stap_get_expected_argument_type by also
including the probe name on it.
Aside from that, and perhaps most importantly, I added a check on
stap_get_arg to make sure that we don't try to extract an argument
from a probe that has no arguments. This check issues an
internal_error, because it really means that GDB is doing something it
shouldn't.
Although it can be considered almost trivial, and despite the fact
that I am the maintainer for this part of the code, I am posting this
patch for review. I will wait a few days, and if nobody has anything
to say, I will go ahead and push it.
gdb/ChangeLog:
2015-09-01 Sergio Durigan Junior <sergiodj@redhat.com>
* probe.h (struct probe_ops) <get_probe_argument_count,
evaluate_probe_argument, enable_probe, disable_probe>: Mention in
the comment that the function can throw an exception.
(get_probe_argument_count): Likewise.
(evaluate_probe_argument): Likewise.
* stap-probe.c (stap_get_opcode): Call error instead of
internal_error.
(stap_get_expected_argument_type): Likewise. Add argument
'probe'. Improve error message by mentioning the probe's name.
(stap_parse_probe_arguments): Adjust call to
stap_get_expected_argument_type.
(stap_get_arg): Add comment. Assert that 'probe->args_parsed' is
not zero. Call internal_error if GDB requests an argument but the
probe has no arguments.
2015-08-22 06:13:46 +08:00
|
|
|
|
enum stap_arg_bitness b,
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
const char *probe_name)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
switch (b)
|
|
|
|
|
{
|
|
|
|
|
case STAP_ARG_BITNESS_UNDEFINED:
|
|
|
|
|
if (gdbarch_addr_bit (gdbarch) == 32)
|
|
|
|
|
return builtin_type (gdbarch)->builtin_uint32;
|
|
|
|
|
else
|
|
|
|
|
return builtin_type (gdbarch)->builtin_uint64;
|
|
|
|
|
|
2014-05-03 04:50:45 +08:00
|
|
|
|
case STAP_ARG_BITNESS_8BIT_UNSIGNED:
|
|
|
|
|
return builtin_type (gdbarch)->builtin_uint8;
|
|
|
|
|
|
|
|
|
|
case STAP_ARG_BITNESS_8BIT_SIGNED:
|
|
|
|
|
return builtin_type (gdbarch)->builtin_int8;
|
|
|
|
|
|
|
|
|
|
case STAP_ARG_BITNESS_16BIT_UNSIGNED:
|
|
|
|
|
return builtin_type (gdbarch)->builtin_uint16;
|
|
|
|
|
|
|
|
|
|
case STAP_ARG_BITNESS_16BIT_SIGNED:
|
|
|
|
|
return builtin_type (gdbarch)->builtin_int16;
|
|
|
|
|
|
2012-04-28 04:47:57 +08:00
|
|
|
|
case STAP_ARG_BITNESS_32BIT_SIGNED:
|
|
|
|
|
return builtin_type (gdbarch)->builtin_int32;
|
|
|
|
|
|
|
|
|
|
case STAP_ARG_BITNESS_32BIT_UNSIGNED:
|
|
|
|
|
return builtin_type (gdbarch)->builtin_uint32;
|
|
|
|
|
|
|
|
|
|
case STAP_ARG_BITNESS_64BIT_SIGNED:
|
|
|
|
|
return builtin_type (gdbarch)->builtin_int64;
|
|
|
|
|
|
|
|
|
|
case STAP_ARG_BITNESS_64BIT_UNSIGNED:
|
|
|
|
|
return builtin_type (gdbarch)->builtin_uint64;
|
|
|
|
|
|
|
|
|
|
default:
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
error (_("Undefined bitness for probe '%s'."), probe_name);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
/* Helper function to check for a generic list of prefixes. GDBARCH
|
|
|
|
|
is the current gdbarch being used. S is the expression being
|
|
|
|
|
analyzed. If R is not NULL, it will be used to return the found
|
|
|
|
|
prefix. PREFIXES is the list of expected prefixes.
|
|
|
|
|
|
|
|
|
|
This function does a case-insensitive match.
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
Return true if any prefix has been found, false otherwise. */
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
static bool
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
stap_is_generic_prefix (struct gdbarch *gdbarch, const char *s,
|
|
|
|
|
const char **r, const char *const *prefixes)
|
|
|
|
|
{
|
|
|
|
|
const char *const *p;
|
|
|
|
|
|
|
|
|
|
if (prefixes == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (r != NULL)
|
|
|
|
|
*r = "";
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
return true;
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (p = prefixes; *p != NULL; ++p)
|
2013-12-24 06:48:08 +08:00
|
|
|
|
if (strncasecmp (s, *p, strlen (*p)) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (r != NULL)
|
|
|
|
|
*r = *p;
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
return true;
|
2013-12-24 06:48:08 +08:00
|
|
|
|
}
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
return false;
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
/* Return true if S points to a register prefix, false otherwise. For
|
|
|
|
|
a description of the arguments, look at stap_is_generic_prefix. */
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
static bool
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
stap_is_register_prefix (struct gdbarch *gdbarch, const char *s,
|
|
|
|
|
const char **r)
|
|
|
|
|
{
|
|
|
|
|
const char *const *t = gdbarch_stap_register_prefixes (gdbarch);
|
|
|
|
|
|
|
|
|
|
return stap_is_generic_prefix (gdbarch, s, r, t);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
/* Return true if S points to a register indirection prefix, false
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
otherwise. For a description of the arguments, look at
|
|
|
|
|
stap_is_generic_prefix. */
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
static bool
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
stap_is_register_indirection_prefix (struct gdbarch *gdbarch, const char *s,
|
|
|
|
|
const char **r)
|
|
|
|
|
{
|
|
|
|
|
const char *const *t = gdbarch_stap_register_indirection_prefixes (gdbarch);
|
|
|
|
|
|
|
|
|
|
return stap_is_generic_prefix (gdbarch, s, r, t);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
/* Return true if S points to an integer prefix, false otherwise. For
|
|
|
|
|
a description of the arguments, look at stap_is_generic_prefix.
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
|
|
|
|
|
This function takes care of analyzing whether we are dealing with
|
|
|
|
|
an expected integer prefix, or, if there is no integer prefix to be
|
|
|
|
|
expected, whether we are dealing with a digit. It does a
|
|
|
|
|
case-insensitive match. */
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
static bool
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
stap_is_integer_prefix (struct gdbarch *gdbarch, const char *s,
|
|
|
|
|
const char **r)
|
|
|
|
|
{
|
|
|
|
|
const char *const *t = gdbarch_stap_integer_prefixes (gdbarch);
|
|
|
|
|
const char *const *p;
|
|
|
|
|
|
|
|
|
|
if (t == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* A NULL value here means that integers do not have a prefix.
|
|
|
|
|
We just check for a digit then. */
|
|
|
|
|
if (r != NULL)
|
|
|
|
|
*r = "";
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
return isdigit (*s) > 0;
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (p = t; *p != NULL; ++p)
|
|
|
|
|
{
|
|
|
|
|
size_t len = strlen (*p);
|
|
|
|
|
|
|
|
|
|
if ((len == 0 && isdigit (*s))
|
|
|
|
|
|| (len > 0 && strncasecmp (s, *p, len) == 0))
|
|
|
|
|
{
|
|
|
|
|
/* Integers may or may not have a prefix. The "len == 0"
|
|
|
|
|
check covers the case when integers do not have a prefix
|
|
|
|
|
(therefore, we just check if we have a digit). The call
|
|
|
|
|
to "strncasecmp" covers the case when they have a
|
|
|
|
|
prefix. */
|
|
|
|
|
if (r != NULL)
|
|
|
|
|
*r = *p;
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
return true;
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
return false;
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function to check for a generic list of suffixes. If we are
|
|
|
|
|
not expecting any suffixes, then it just returns 1. If we are
|
2019-05-17 03:58:55 +08:00
|
|
|
|
expecting at least one suffix, then it returns true if a suffix has
|
|
|
|
|
been found, false otherwise. GDBARCH is the current gdbarch being
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
used. S is the expression being analyzed. If R is not NULL, it
|
|
|
|
|
will be used to return the found suffix. SUFFIXES is the list of
|
|
|
|
|
expected suffixes. This function does a case-insensitive
|
|
|
|
|
match. */
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
static bool
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
stap_generic_check_suffix (struct gdbarch *gdbarch, const char *s,
|
|
|
|
|
const char **r, const char *const *suffixes)
|
|
|
|
|
{
|
|
|
|
|
const char *const *p;
|
2019-05-17 03:58:55 +08:00
|
|
|
|
bool found = false;
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
|
|
|
|
|
if (suffixes == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (r != NULL)
|
|
|
|
|
*r = "";
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
return true;
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (p = suffixes; *p != NULL; ++p)
|
|
|
|
|
if (strncasecmp (s, *p, strlen (*p)) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (r != NULL)
|
|
|
|
|
*r = *p;
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
found = true;
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
/* Return true if S points to an integer suffix, false otherwise. For
|
|
|
|
|
a description of the arguments, look at
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
stap_generic_check_suffix. */
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
static bool
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
stap_check_integer_suffix (struct gdbarch *gdbarch, const char *s,
|
|
|
|
|
const char **r)
|
|
|
|
|
{
|
|
|
|
|
const char *const *p = gdbarch_stap_integer_suffixes (gdbarch);
|
|
|
|
|
|
|
|
|
|
return stap_generic_check_suffix (gdbarch, s, r, p);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
/* Return true if S points to a register suffix, false otherwise. For
|
|
|
|
|
a description of the arguments, look at
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
stap_generic_check_suffix. */
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
static bool
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
stap_check_register_suffix (struct gdbarch *gdbarch, const char *s,
|
|
|
|
|
const char **r)
|
|
|
|
|
{
|
|
|
|
|
const char *const *p = gdbarch_stap_register_suffixes (gdbarch);
|
|
|
|
|
|
|
|
|
|
return stap_generic_check_suffix (gdbarch, s, r, p);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
/* Return true if S points to a register indirection suffix, false
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
otherwise. For a description of the arguments, look at
|
|
|
|
|
stap_generic_check_suffix. */
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
static bool
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
stap_check_register_indirection_suffix (struct gdbarch *gdbarch, const char *s,
|
|
|
|
|
const char **r)
|
|
|
|
|
{
|
|
|
|
|
const char *const *p = gdbarch_stap_register_indirection_suffixes (gdbarch);
|
|
|
|
|
|
|
|
|
|
return stap_generic_check_suffix (gdbarch, s, r, p);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-28 04:47:57 +08:00
|
|
|
|
/* Function responsible for parsing a register operand according to
|
|
|
|
|
SystemTap parlance. Assuming:
|
|
|
|
|
|
|
|
|
|
RP = register prefix
|
|
|
|
|
RS = register suffix
|
|
|
|
|
RIP = register indirection prefix
|
|
|
|
|
RIS = register indirection suffix
|
|
|
|
|
|
|
|
|
|
Then a register operand can be:
|
|
|
|
|
|
|
|
|
|
[RIP] [RP] REGISTER [RS] [RIS]
|
|
|
|
|
|
|
|
|
|
This function takes care of a register's indirection, displacement and
|
|
|
|
|
direct access. It also takes into consideration the fact that some
|
|
|
|
|
registers are named differently inside and outside GDB, e.g., PPC's
|
|
|
|
|
general-purpose registers are represented by integers in the assembly
|
|
|
|
|
language (e.g., `15' is the 15th general-purpose register), but inside
|
|
|
|
|
GDB they have a prefix (the letter `r') appended. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
stap_parse_register_operand (struct stap_parse_info *p)
|
|
|
|
|
{
|
|
|
|
|
/* Simple flag to indicate whether we have seen a minus signal before
|
|
|
|
|
certain number. */
|
2019-05-17 03:58:55 +08:00
|
|
|
|
bool got_minus = false;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
/* Flags to indicate whether this register access is being displaced and/or
|
|
|
|
|
indirected. */
|
2019-05-17 03:58:55 +08:00
|
|
|
|
bool disp_p = false;
|
|
|
|
|
bool indirect_p = false;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
struct gdbarch *gdbarch = p->gdbarch;
|
|
|
|
|
/* Needed to generate the register name as a part of an expression. */
|
|
|
|
|
struct stoken str;
|
|
|
|
|
/* Variables used to extract the register name from the probe's
|
|
|
|
|
argument. */
|
|
|
|
|
const char *start;
|
|
|
|
|
const char *gdb_reg_prefix = gdbarch_stap_gdb_register_prefix (gdbarch);
|
|
|
|
|
const char *gdb_reg_suffix = gdbarch_stap_gdb_register_suffix (gdbarch);
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
const char *reg_prefix;
|
|
|
|
|
const char *reg_ind_prefix;
|
|
|
|
|
const char *reg_suffix;
|
|
|
|
|
const char *reg_ind_suffix;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* Checking for a displacement argument. */
|
|
|
|
|
if (*p->arg == '+')
|
|
|
|
|
{
|
|
|
|
|
/* If it's a plus sign, we don't need to do anything, just advance the
|
|
|
|
|
pointer. */
|
|
|
|
|
++p->arg;
|
|
|
|
|
}
|
2019-05-17 04:17:30 +08:00
|
|
|
|
else if (*p->arg == '-')
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
2019-05-17 03:58:55 +08:00
|
|
|
|
got_minus = true;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
++p->arg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isdigit (*p->arg))
|
|
|
|
|
{
|
|
|
|
|
/* The value of the displacement. */
|
|
|
|
|
long displacement;
|
2013-03-14 00:45:11 +08:00
|
|
|
|
char *endp;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
disp_p = true;
|
2013-03-14 00:45:11 +08:00
|
|
|
|
displacement = strtol (p->arg, &endp, 10);
|
|
|
|
|
p->arg = endp;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* Generating the expression for the displacement. */
|
Remove `expout*' globals from parser-defs.h
This commit removes the "expout*" globals from our parser code, turning
them into a structure that is passed when an expression needs to be
evaluated. This is the initial step to make our parser less
"globalized".
This is mostly a mechanical patch, which creates a structure containing
the "expout*" globals and then modify all the functions that handle them
in order to take the structure as argument. It is big, and has been
reviewed at least 4 times, so I think everything is covered.
Below you can see the message links from the discussions:
- First attempt:
<https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html>
Message-ID: <m3k44s7qej.fsf@gmail.com>
- Second attempt:
<https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html>
Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>
- Third attempt:
<https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html>
Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com>
- Fourth (last) attempt:
<https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html>
Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com>
gdb/
2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com>
Remove some globals from our parser.
* language.c (unk_lang_parser): Add "struct parser_state"
argument.
* language.h (struct language_defn) <la_parser>: Likewise.
* parse.c (expout, expout_size, expout_ptr): Remove variables.
(initialize_expout): Add "struct parser_state" argument.
Rewrite function to use the parser state.
(reallocate_expout, write_exp_elt, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
write_dollar_variable): Likewise.
(parse_exp_in_context_1): Use parser state.
(insert_type_address_space): Add "struct parser_state" argument.
Use parser state.
(increase_expout_size): New function.
* parser-defs.h: Forward declare "struct language_defn" and
"struct parser_state".
(expout, expout_size, expout_ptr): Remove extern declarations.
(parse_gdbarch, parse_language): Rewrite macro declarations to
accept the parser state.
(struct parser_state): New struct.
(initialize_expout, reallocate_expout, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
write_exp_msymbol, write_dollar_variable,
mark_struct_expression, insert_type_address_space): Add "struct
parser_state" argument.
(increase_expout_size): New function.
* utils.c (do_clear_parser_state): New function.
(make_cleanup_clear_parser_state): Likewise.
* utils.h (make_cleanup_clear_parser_state): New function
prototype.
* aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
Update calls to write_exp* in order to pass the parser state.
* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
* i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
(i386_stap_parse_special_token_three_arg_disp): Likewise.
* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
* stap-probe.c (stap_parse_register_operand): Likewise.
(stap_parse_single_operand): Likewise.
(stap_parse_argument_1): Likewise.
(stap_parse_argument): Use parser state.
* stap-probe.h: Include "parser-defs.h".
(struct stap_parse_info) <pstate>: New field.
* c-exp.y (parse_type): Rewrite to use parser state.
(yyparse): Redefine to c_parse_internal.
(pstate): New global variable.
(parse_number): Add "struct parser_state" argument.
(write_destructor_name): Likewise.
(type_exp): Update calls to write_exp* and similars in order to
use parser state.
(exp1, exp, variable, qualified_name, space_identifier,
typename, typebase): Likewise.
(write_destructor_name, parse_number, lex_one_token,
classify_name, classify_inner_name, c_parse): Add "struct
parser_state" argument. Update function to use parser state.
* c-lang.h: Forward declare "struct parser_state".
(c_parse): Add "struct parser_state" argument.
* ada-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to ada_parse_internal.
(pstate): New variable.
(write_int, write_object_renaming, write_var_or_type,
write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
type_int, type_long, type_long_long, type_float, type_double,
type_long_double, type_char, type_boolean, type_system_address):
Add "struct parser_state" argument.
(exp1, primary, simple_exp, relation, and_exp, and_then_exp,
or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
var_or_type, aggregate, aggregate_component_list,
positional_list, others, component_group,
component_associations): Update calls to write_exp* and similar
functions in order to use parser state.
(ada_parse, write_var_from_sym, write_int,
write_exp_op_with_string, write_object_renaming,
find_primitive_type, write_selectors, write_ambiguous_var,
write_var_or_type, write_name_assoc, type_int, type_long,
type_long_long, type_float, type_double, type_long_double,
type_char, type_boolean, type_system_address): Add "struct
parser_state" argument. Adjust function to use parser state.
* ada-lang.c (parse): Likewise.
* ada-lang.h: Forward declare "struct parser_state".
(ada_parse): Add "struct parser_state" argument.
* ada-lex.l (processInt, processReal): Likewise. Adjust all
calls to both functions.
* f-exp.y (parse_type, parse_f_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to f_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp, subrange, typebase): Update calls to write_exp*
and similars in order to use parser state.
(parse_number): Adjust code to use parser state.
(yylex): Likewise.
(f_parse): New function.
* f-lang.h: Forward declare "struct parser_state".
(f_parse): Add "struct parser_state" argument.
* jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro for java_parse_internal.
(pstate): New variable.
(push_expression_name, push_expression_name, insert_exp): Add
"struct parser_state" argument.
(type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
PostIncrementExpression, PostDecrementExpression,
UnaryExpression, PreIncrementExpression, PreDecrementExpression,
UnaryExpressionNotPlusMinus, CastExpression,
MultiplicativeExpression, AdditiveExpression, ShiftExpression,
RelationalExpression, EqualityExpression, AndExpression,
ExclusiveOrExpression, InclusiveOrExpression,
ConditionalAndExpression, ConditionalOrExpression,
ConditionalExpression, Assignment, LeftHandSide): Update
calls to write_exp* and similars in order to use parser state.
(parse_number): Ajust code to use parser state.
(yylex): Likewise.
(java_parse): New function.
(push_variable): Add "struct parser_state" argument. Adjust
code to user parser state.
(push_fieldnames, push_qualified_expression_name,
push_expression_name, insert_exp): Likewise.
* jv-lang.h: Forward declare "struct parser_state".
(java_parse): Add "struct parser_state" argument.
* m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to m2_parse_internal.
(pstate): New variable.
(type_exp, exp, fblock, variable, type): Update calls to
write_exp* and similars to use parser state.
(yylex): Likewise.
(m2_parse): New function.
* m2-lang.h: Forward declare "struct parser_state".
(m2_parse): Add "struct parser_state" argument.
* objc-lang.c (end_msglist): Add "struct parser_state" argument.
* objc-lang.h: Forward declare "struct parser_state".
(end_msglist): Add "struct parser_state" argument.
* p-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to pascal_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, qualified_name, variable): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, yylex): Adjust code to use parser state.
(pascal_parse): New function.
* p-lang.h: Forward declare "struct parser_state".
(pascal_parse): Add "struct parser_state" argument.
* go-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to go_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, variable, type): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, lex_one_token, classify_name, yylex): Adjust code
to use parser state.
(go_parse): Likewise.
* go-lang.h: Forward declare "struct parser_state".
(go_parse): Add "struct parser_state" argument.
2014-03-28 06:10:40 +08:00
|
|
|
|
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
|
|
|
|
write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long);
|
|
|
|
|
write_exp_elt_longcst (&p->pstate, displacement);
|
|
|
|
|
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
if (got_minus)
|
Remove `expout*' globals from parser-defs.h
This commit removes the "expout*" globals from our parser code, turning
them into a structure that is passed when an expression needs to be
evaluated. This is the initial step to make our parser less
"globalized".
This is mostly a mechanical patch, which creates a structure containing
the "expout*" globals and then modify all the functions that handle them
in order to take the structure as argument. It is big, and has been
reviewed at least 4 times, so I think everything is covered.
Below you can see the message links from the discussions:
- First attempt:
<https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html>
Message-ID: <m3k44s7qej.fsf@gmail.com>
- Second attempt:
<https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html>
Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>
- Third attempt:
<https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html>
Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com>
- Fourth (last) attempt:
<https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html>
Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com>
gdb/
2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com>
Remove some globals from our parser.
* language.c (unk_lang_parser): Add "struct parser_state"
argument.
* language.h (struct language_defn) <la_parser>: Likewise.
* parse.c (expout, expout_size, expout_ptr): Remove variables.
(initialize_expout): Add "struct parser_state" argument.
Rewrite function to use the parser state.
(reallocate_expout, write_exp_elt, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
write_dollar_variable): Likewise.
(parse_exp_in_context_1): Use parser state.
(insert_type_address_space): Add "struct parser_state" argument.
Use parser state.
(increase_expout_size): New function.
* parser-defs.h: Forward declare "struct language_defn" and
"struct parser_state".
(expout, expout_size, expout_ptr): Remove extern declarations.
(parse_gdbarch, parse_language): Rewrite macro declarations to
accept the parser state.
(struct parser_state): New struct.
(initialize_expout, reallocate_expout, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
write_exp_msymbol, write_dollar_variable,
mark_struct_expression, insert_type_address_space): Add "struct
parser_state" argument.
(increase_expout_size): New function.
* utils.c (do_clear_parser_state): New function.
(make_cleanup_clear_parser_state): Likewise.
* utils.h (make_cleanup_clear_parser_state): New function
prototype.
* aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
Update calls to write_exp* in order to pass the parser state.
* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
* i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
(i386_stap_parse_special_token_three_arg_disp): Likewise.
* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
* stap-probe.c (stap_parse_register_operand): Likewise.
(stap_parse_single_operand): Likewise.
(stap_parse_argument_1): Likewise.
(stap_parse_argument): Use parser state.
* stap-probe.h: Include "parser-defs.h".
(struct stap_parse_info) <pstate>: New field.
* c-exp.y (parse_type): Rewrite to use parser state.
(yyparse): Redefine to c_parse_internal.
(pstate): New global variable.
(parse_number): Add "struct parser_state" argument.
(write_destructor_name): Likewise.
(type_exp): Update calls to write_exp* and similars in order to
use parser state.
(exp1, exp, variable, qualified_name, space_identifier,
typename, typebase): Likewise.
(write_destructor_name, parse_number, lex_one_token,
classify_name, classify_inner_name, c_parse): Add "struct
parser_state" argument. Update function to use parser state.
* c-lang.h: Forward declare "struct parser_state".
(c_parse): Add "struct parser_state" argument.
* ada-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to ada_parse_internal.
(pstate): New variable.
(write_int, write_object_renaming, write_var_or_type,
write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
type_int, type_long, type_long_long, type_float, type_double,
type_long_double, type_char, type_boolean, type_system_address):
Add "struct parser_state" argument.
(exp1, primary, simple_exp, relation, and_exp, and_then_exp,
or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
var_or_type, aggregate, aggregate_component_list,
positional_list, others, component_group,
component_associations): Update calls to write_exp* and similar
functions in order to use parser state.
(ada_parse, write_var_from_sym, write_int,
write_exp_op_with_string, write_object_renaming,
find_primitive_type, write_selectors, write_ambiguous_var,
write_var_or_type, write_name_assoc, type_int, type_long,
type_long_long, type_float, type_double, type_long_double,
type_char, type_boolean, type_system_address): Add "struct
parser_state" argument. Adjust function to use parser state.
* ada-lang.c (parse): Likewise.
* ada-lang.h: Forward declare "struct parser_state".
(ada_parse): Add "struct parser_state" argument.
* ada-lex.l (processInt, processReal): Likewise. Adjust all
calls to both functions.
* f-exp.y (parse_type, parse_f_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to f_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp, subrange, typebase): Update calls to write_exp*
and similars in order to use parser state.
(parse_number): Adjust code to use parser state.
(yylex): Likewise.
(f_parse): New function.
* f-lang.h: Forward declare "struct parser_state".
(f_parse): Add "struct parser_state" argument.
* jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro for java_parse_internal.
(pstate): New variable.
(push_expression_name, push_expression_name, insert_exp): Add
"struct parser_state" argument.
(type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
PostIncrementExpression, PostDecrementExpression,
UnaryExpression, PreIncrementExpression, PreDecrementExpression,
UnaryExpressionNotPlusMinus, CastExpression,
MultiplicativeExpression, AdditiveExpression, ShiftExpression,
RelationalExpression, EqualityExpression, AndExpression,
ExclusiveOrExpression, InclusiveOrExpression,
ConditionalAndExpression, ConditionalOrExpression,
ConditionalExpression, Assignment, LeftHandSide): Update
calls to write_exp* and similars in order to use parser state.
(parse_number): Ajust code to use parser state.
(yylex): Likewise.
(java_parse): New function.
(push_variable): Add "struct parser_state" argument. Adjust
code to user parser state.
(push_fieldnames, push_qualified_expression_name,
push_expression_name, insert_exp): Likewise.
* jv-lang.h: Forward declare "struct parser_state".
(java_parse): Add "struct parser_state" argument.
* m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to m2_parse_internal.
(pstate): New variable.
(type_exp, exp, fblock, variable, type): Update calls to
write_exp* and similars to use parser state.
(yylex): Likewise.
(m2_parse): New function.
* m2-lang.h: Forward declare "struct parser_state".
(m2_parse): Add "struct parser_state" argument.
* objc-lang.c (end_msglist): Add "struct parser_state" argument.
* objc-lang.h: Forward declare "struct parser_state".
(end_msglist): Add "struct parser_state" argument.
* p-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to pascal_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, qualified_name, variable): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, yylex): Adjust code to use parser state.
(pascal_parse): New function.
* p-lang.h: Forward declare "struct parser_state".
(pascal_parse): Add "struct parser_state" argument.
* go-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to go_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, variable, type): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, lex_one_token, classify_name, yylex): Adjust code
to use parser state.
(go_parse): Likewise.
* go-lang.h: Forward declare "struct parser_state".
(go_parse): Add "struct parser_state" argument.
2014-03-28 06:10:40 +08:00
|
|
|
|
write_exp_elt_opcode (&p->pstate, UNOP_NEG);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Getting rid of register indirection prefix. */
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
if (stap_is_register_indirection_prefix (gdbarch, p->arg, ®_ind_prefix))
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
2019-05-17 03:58:55 +08:00
|
|
|
|
indirect_p = true;
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
p->arg += strlen (reg_ind_prefix);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (disp_p && !indirect_p)
|
|
|
|
|
error (_("Invalid register displacement syntax on expression `%s'."),
|
|
|
|
|
p->saved_arg);
|
|
|
|
|
|
|
|
|
|
/* Getting rid of register prefix. */
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
if (stap_is_register_prefix (gdbarch, p->arg, ®_prefix))
|
|
|
|
|
p->arg += strlen (reg_prefix);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* Now we should have only the register name. Let's extract it and get
|
|
|
|
|
the associated number. */
|
|
|
|
|
start = p->arg;
|
|
|
|
|
|
|
|
|
|
/* We assume the register name is composed by letters and numbers. */
|
|
|
|
|
while (isalnum (*p->arg))
|
|
|
|
|
++p->arg;
|
|
|
|
|
|
2019-05-17 04:23:24 +08:00
|
|
|
|
std::string regname (start, p->arg - start);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* We only add the GDB's register prefix/suffix if we are dealing with
|
|
|
|
|
a numeric register. */
|
2019-05-17 04:23:24 +08:00
|
|
|
|
if (isdigit (*start))
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
2019-05-17 04:23:24 +08:00
|
|
|
|
if (gdb_reg_prefix != NULL)
|
|
|
|
|
regname = gdb_reg_prefix + regname;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
2019-05-17 04:23:24 +08:00
|
|
|
|
if (gdb_reg_suffix != NULL)
|
|
|
|
|
regname += gdb_reg_suffix;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
Adjust i386 registers on SystemTap probes' arguments (PR breakpoints/24541)
This bug has been reported on PR breakpoints/24541, but it is possible
to reproduce it easily by running:
make check-gdb TESTS=gdb.base/stap-probe.exp RUNTESTFLAGS='--target_board unix/-m32'
The underlying cause is kind of complex, and involves decisions made
by GCC and the sys/sdt.h header file about how to represent a probe
argument that lives in a register in 32-bit programs. I'll use
Andrew's example on the bug to illustrate the problem.
libstdc++ has a probe named "throw" with two arguments. On i386, the
probe is:
stapsdt 0x00000028 NT_STAPSDT (SystemTap probe descriptors)
Provider: libstdcxx
Name: throw
Location: 0x00072c96, Base: 0x00133d64, Semaphore: 0x00000000
Arguments: 4@%si 4@%di
I.e., the first argument is an unsigned 32-bit value (represented by
the "4@") that lives on %si, and the second argument is an unsigned
32-bit value that lives on %di. Note the discrepancy between the
argument size reported by the probe (32-bit) and the register size
being used to store the value (16-bit).
However, if you take a look at the disassemble of a program that uses
this probe, you will see:
00072c80 <__cxa_throw@@CXXABI_1.3>:
72c80: 57 push %edi
72c81: 56 push %esi
72c82: 53 push %ebx
72c83: 8b 74 24 10 mov 0x10(%esp),%esi
72c87: e8 74 bf ff ff call 6ec00 <__cxa_finalize@plt+0x980>
72c8c: 81 c3 74 e3 10 00 add $0x10e374,%ebx
72c92: 8b 7c 24 14 mov 0x14(%esp),%edi
72c96: 90 nop <----------------- PROBE IS HERE
72c97: e8 d4 a2 ff ff call 6cf70 <__cxa_get_globals@plt>
72c9c: 83 40 04 01 addl $0x1,0x4(%eax)
72ca0: 83 ec 04 sub $0x4,%esp
72ca3: ff 74 24 1c pushl 0x1c(%esp)
72ca7: 57 push %edi
72ca8: 56 push %esi
72ca9: e8 62 a3 ff ff call 6d010 <__cxa_init_primary_exception@plt>
72cae: 8d 70 40 lea 0x40(%eax),%esi
72cb1: c7 00 01 00 00 00 movl $0x1,(%eax)
72cb7: 89 34 24 mov %esi,(%esp)
72cba: e8 61 96 ff ff call 6c320 <_Unwind_RaiseException@plt>
72cbf: 89 34 24 mov %esi,(%esp)
72cc2: e8 c9 84 ff ff call 6b190 <__cxa_begin_catch@plt>
72cc7: e8 d4 b3 ff ff call 6e0a0 <_ZSt9terminatev@plt>
72ccc: 66 90 xchg %ax,%ax
72cce: 66 90 xchg %ax,%ax
Note how the program is actually using %edi, and not %di, to store the
second argument. This is the problem here.
GDB will basically read the probe argument, then read the contents of
%di, and then cast this value to uint32_t, which causes the wrong
value to be obtained. In the gdb.base/stap-probe.exp case, this makes
GDB read the wrong memory location, and not be able to display a test
string. In Andrew's example, this causes GDB to actually stop at a
"catch throw" when it should actually have *not* stopped.
After some discussion with Frank Eigler and Jakub Jelinek, it was
decided that this bug should be fixed on the client side (i.e., the
program that actually reads the probes), and this is why I'm proposing
this patch.
The idea is simple: we will have a gdbarch method, which, for now, is
only used by i386. The generic code that deals with register operands
on gdb/stap-probe.c will call this method if it exists, passing the
current parse information, the register name and its number.
The i386 method will then verify if the register size is greater or
equal than the size reported by the stap probe (the "4@" part). If it
is, we're fine. Otherwise, it will check if we're dealing with any of
the "extendable" registers (like ax, bx, si, di, sp, etc.). If we
are, it will change the register name to include the "e" prefix.
I have tested the patch here in many scenarios, and it fixes Andrew's
bug and also the regressions I mentioned before, on
gdb.base/stap-probe.exp. No regressions where found on other tests.
Comments?
gdb/ChangeLog:
2019-06-27 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/24541
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh: Add 'stap_adjust_register'.
* i386-tdep.c: Include '<unordered_set>'.
(i386_stap_adjust_register): New function.
(i386_elf_init_abi): Register 'i386_stap_adjust_register'.
* stap-probe.c (stap_parse_register_operand): Call
'gdbarch_stap_adjust_register'.
2019-06-27 05:34:50 +08:00
|
|
|
|
int regnum = user_reg_map_name_to_regnum (gdbarch, regname.c_str (),
|
|
|
|
|
regname.size ());
|
|
|
|
|
|
2012-04-28 04:47:57 +08:00
|
|
|
|
/* Is this a valid register name? */
|
Adjust i386 registers on SystemTap probes' arguments (PR breakpoints/24541)
This bug has been reported on PR breakpoints/24541, but it is possible
to reproduce it easily by running:
make check-gdb TESTS=gdb.base/stap-probe.exp RUNTESTFLAGS='--target_board unix/-m32'
The underlying cause is kind of complex, and involves decisions made
by GCC and the sys/sdt.h header file about how to represent a probe
argument that lives in a register in 32-bit programs. I'll use
Andrew's example on the bug to illustrate the problem.
libstdc++ has a probe named "throw" with two arguments. On i386, the
probe is:
stapsdt 0x00000028 NT_STAPSDT (SystemTap probe descriptors)
Provider: libstdcxx
Name: throw
Location: 0x00072c96, Base: 0x00133d64, Semaphore: 0x00000000
Arguments: 4@%si 4@%di
I.e., the first argument is an unsigned 32-bit value (represented by
the "4@") that lives on %si, and the second argument is an unsigned
32-bit value that lives on %di. Note the discrepancy between the
argument size reported by the probe (32-bit) and the register size
being used to store the value (16-bit).
However, if you take a look at the disassemble of a program that uses
this probe, you will see:
00072c80 <__cxa_throw@@CXXABI_1.3>:
72c80: 57 push %edi
72c81: 56 push %esi
72c82: 53 push %ebx
72c83: 8b 74 24 10 mov 0x10(%esp),%esi
72c87: e8 74 bf ff ff call 6ec00 <__cxa_finalize@plt+0x980>
72c8c: 81 c3 74 e3 10 00 add $0x10e374,%ebx
72c92: 8b 7c 24 14 mov 0x14(%esp),%edi
72c96: 90 nop <----------------- PROBE IS HERE
72c97: e8 d4 a2 ff ff call 6cf70 <__cxa_get_globals@plt>
72c9c: 83 40 04 01 addl $0x1,0x4(%eax)
72ca0: 83 ec 04 sub $0x4,%esp
72ca3: ff 74 24 1c pushl 0x1c(%esp)
72ca7: 57 push %edi
72ca8: 56 push %esi
72ca9: e8 62 a3 ff ff call 6d010 <__cxa_init_primary_exception@plt>
72cae: 8d 70 40 lea 0x40(%eax),%esi
72cb1: c7 00 01 00 00 00 movl $0x1,(%eax)
72cb7: 89 34 24 mov %esi,(%esp)
72cba: e8 61 96 ff ff call 6c320 <_Unwind_RaiseException@plt>
72cbf: 89 34 24 mov %esi,(%esp)
72cc2: e8 c9 84 ff ff call 6b190 <__cxa_begin_catch@plt>
72cc7: e8 d4 b3 ff ff call 6e0a0 <_ZSt9terminatev@plt>
72ccc: 66 90 xchg %ax,%ax
72cce: 66 90 xchg %ax,%ax
Note how the program is actually using %edi, and not %di, to store the
second argument. This is the problem here.
GDB will basically read the probe argument, then read the contents of
%di, and then cast this value to uint32_t, which causes the wrong
value to be obtained. In the gdb.base/stap-probe.exp case, this makes
GDB read the wrong memory location, and not be able to display a test
string. In Andrew's example, this causes GDB to actually stop at a
"catch throw" when it should actually have *not* stopped.
After some discussion with Frank Eigler and Jakub Jelinek, it was
decided that this bug should be fixed on the client side (i.e., the
program that actually reads the probes), and this is why I'm proposing
this patch.
The idea is simple: we will have a gdbarch method, which, for now, is
only used by i386. The generic code that deals with register operands
on gdb/stap-probe.c will call this method if it exists, passing the
current parse information, the register name and its number.
The i386 method will then verify if the register size is greater or
equal than the size reported by the stap probe (the "4@" part). If it
is, we're fine. Otherwise, it will check if we're dealing with any of
the "extendable" registers (like ax, bx, si, di, sp, etc.). If we
are, it will change the register name to include the "e" prefix.
I have tested the patch here in many scenarios, and it fixes Andrew's
bug and also the regressions I mentioned before, on
gdb.base/stap-probe.exp. No regressions where found on other tests.
Comments?
gdb/ChangeLog:
2019-06-27 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/24541
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh: Add 'stap_adjust_register'.
* i386-tdep.c: Include '<unordered_set>'.
(i386_stap_adjust_register): New function.
(i386_elf_init_abi): Register 'i386_stap_adjust_register'.
* stap-probe.c (stap_parse_register_operand): Call
'gdbarch_stap_adjust_register'.
2019-06-27 05:34:50 +08:00
|
|
|
|
if (regnum == -1)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
error (_("Invalid register name `%s' on expression `%s'."),
|
2019-05-17 04:23:24 +08:00
|
|
|
|
regname.c_str (), p->saved_arg);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Adjust i386 registers on SystemTap probes' arguments (PR breakpoints/24541)
This bug has been reported on PR breakpoints/24541, but it is possible
to reproduce it easily by running:
make check-gdb TESTS=gdb.base/stap-probe.exp RUNTESTFLAGS='--target_board unix/-m32'
The underlying cause is kind of complex, and involves decisions made
by GCC and the sys/sdt.h header file about how to represent a probe
argument that lives in a register in 32-bit programs. I'll use
Andrew's example on the bug to illustrate the problem.
libstdc++ has a probe named "throw" with two arguments. On i386, the
probe is:
stapsdt 0x00000028 NT_STAPSDT (SystemTap probe descriptors)
Provider: libstdcxx
Name: throw
Location: 0x00072c96, Base: 0x00133d64, Semaphore: 0x00000000
Arguments: 4@%si 4@%di
I.e., the first argument is an unsigned 32-bit value (represented by
the "4@") that lives on %si, and the second argument is an unsigned
32-bit value that lives on %di. Note the discrepancy between the
argument size reported by the probe (32-bit) and the register size
being used to store the value (16-bit).
However, if you take a look at the disassemble of a program that uses
this probe, you will see:
00072c80 <__cxa_throw@@CXXABI_1.3>:
72c80: 57 push %edi
72c81: 56 push %esi
72c82: 53 push %ebx
72c83: 8b 74 24 10 mov 0x10(%esp),%esi
72c87: e8 74 bf ff ff call 6ec00 <__cxa_finalize@plt+0x980>
72c8c: 81 c3 74 e3 10 00 add $0x10e374,%ebx
72c92: 8b 7c 24 14 mov 0x14(%esp),%edi
72c96: 90 nop <----------------- PROBE IS HERE
72c97: e8 d4 a2 ff ff call 6cf70 <__cxa_get_globals@plt>
72c9c: 83 40 04 01 addl $0x1,0x4(%eax)
72ca0: 83 ec 04 sub $0x4,%esp
72ca3: ff 74 24 1c pushl 0x1c(%esp)
72ca7: 57 push %edi
72ca8: 56 push %esi
72ca9: e8 62 a3 ff ff call 6d010 <__cxa_init_primary_exception@plt>
72cae: 8d 70 40 lea 0x40(%eax),%esi
72cb1: c7 00 01 00 00 00 movl $0x1,(%eax)
72cb7: 89 34 24 mov %esi,(%esp)
72cba: e8 61 96 ff ff call 6c320 <_Unwind_RaiseException@plt>
72cbf: 89 34 24 mov %esi,(%esp)
72cc2: e8 c9 84 ff ff call 6b190 <__cxa_begin_catch@plt>
72cc7: e8 d4 b3 ff ff call 6e0a0 <_ZSt9terminatev@plt>
72ccc: 66 90 xchg %ax,%ax
72cce: 66 90 xchg %ax,%ax
Note how the program is actually using %edi, and not %di, to store the
second argument. This is the problem here.
GDB will basically read the probe argument, then read the contents of
%di, and then cast this value to uint32_t, which causes the wrong
value to be obtained. In the gdb.base/stap-probe.exp case, this makes
GDB read the wrong memory location, and not be able to display a test
string. In Andrew's example, this causes GDB to actually stop at a
"catch throw" when it should actually have *not* stopped.
After some discussion with Frank Eigler and Jakub Jelinek, it was
decided that this bug should be fixed on the client side (i.e., the
program that actually reads the probes), and this is why I'm proposing
this patch.
The idea is simple: we will have a gdbarch method, which, for now, is
only used by i386. The generic code that deals with register operands
on gdb/stap-probe.c will call this method if it exists, passing the
current parse information, the register name and its number.
The i386 method will then verify if the register size is greater or
equal than the size reported by the stap probe (the "4@" part). If it
is, we're fine. Otherwise, it will check if we're dealing with any of
the "extendable" registers (like ax, bx, si, di, sp, etc.). If we
are, it will change the register name to include the "e" prefix.
I have tested the patch here in many scenarios, and it fixes Andrew's
bug and also the regressions I mentioned before, on
gdb.base/stap-probe.exp. No regressions where found on other tests.
Comments?
gdb/ChangeLog:
2019-06-27 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/24541
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh: Add 'stap_adjust_register'.
* i386-tdep.c: Include '<unordered_set>'.
(i386_stap_adjust_register): New function.
(i386_elf_init_abi): Register 'i386_stap_adjust_register'.
* stap-probe.c (stap_parse_register_operand): Call
'gdbarch_stap_adjust_register'.
2019-06-27 05:34:50 +08:00
|
|
|
|
/* Check if there's any special treatment that the arch-specific
|
|
|
|
|
code would like to perform on the register name. */
|
|
|
|
|
if (gdbarch_stap_adjust_register_p (gdbarch))
|
|
|
|
|
{
|
2019-07-02 19:06:06 +08:00
|
|
|
|
std::string newregname
|
|
|
|
|
= gdbarch_stap_adjust_register (gdbarch, p, regname, regnum);
|
Adjust i386 registers on SystemTap probes' arguments (PR breakpoints/24541)
This bug has been reported on PR breakpoints/24541, but it is possible
to reproduce it easily by running:
make check-gdb TESTS=gdb.base/stap-probe.exp RUNTESTFLAGS='--target_board unix/-m32'
The underlying cause is kind of complex, and involves decisions made
by GCC and the sys/sdt.h header file about how to represent a probe
argument that lives in a register in 32-bit programs. I'll use
Andrew's example on the bug to illustrate the problem.
libstdc++ has a probe named "throw" with two arguments. On i386, the
probe is:
stapsdt 0x00000028 NT_STAPSDT (SystemTap probe descriptors)
Provider: libstdcxx
Name: throw
Location: 0x00072c96, Base: 0x00133d64, Semaphore: 0x00000000
Arguments: 4@%si 4@%di
I.e., the first argument is an unsigned 32-bit value (represented by
the "4@") that lives on %si, and the second argument is an unsigned
32-bit value that lives on %di. Note the discrepancy between the
argument size reported by the probe (32-bit) and the register size
being used to store the value (16-bit).
However, if you take a look at the disassemble of a program that uses
this probe, you will see:
00072c80 <__cxa_throw@@CXXABI_1.3>:
72c80: 57 push %edi
72c81: 56 push %esi
72c82: 53 push %ebx
72c83: 8b 74 24 10 mov 0x10(%esp),%esi
72c87: e8 74 bf ff ff call 6ec00 <__cxa_finalize@plt+0x980>
72c8c: 81 c3 74 e3 10 00 add $0x10e374,%ebx
72c92: 8b 7c 24 14 mov 0x14(%esp),%edi
72c96: 90 nop <----------------- PROBE IS HERE
72c97: e8 d4 a2 ff ff call 6cf70 <__cxa_get_globals@plt>
72c9c: 83 40 04 01 addl $0x1,0x4(%eax)
72ca0: 83 ec 04 sub $0x4,%esp
72ca3: ff 74 24 1c pushl 0x1c(%esp)
72ca7: 57 push %edi
72ca8: 56 push %esi
72ca9: e8 62 a3 ff ff call 6d010 <__cxa_init_primary_exception@plt>
72cae: 8d 70 40 lea 0x40(%eax),%esi
72cb1: c7 00 01 00 00 00 movl $0x1,(%eax)
72cb7: 89 34 24 mov %esi,(%esp)
72cba: e8 61 96 ff ff call 6c320 <_Unwind_RaiseException@plt>
72cbf: 89 34 24 mov %esi,(%esp)
72cc2: e8 c9 84 ff ff call 6b190 <__cxa_begin_catch@plt>
72cc7: e8 d4 b3 ff ff call 6e0a0 <_ZSt9terminatev@plt>
72ccc: 66 90 xchg %ax,%ax
72cce: 66 90 xchg %ax,%ax
Note how the program is actually using %edi, and not %di, to store the
second argument. This is the problem here.
GDB will basically read the probe argument, then read the contents of
%di, and then cast this value to uint32_t, which causes the wrong
value to be obtained. In the gdb.base/stap-probe.exp case, this makes
GDB read the wrong memory location, and not be able to display a test
string. In Andrew's example, this causes GDB to actually stop at a
"catch throw" when it should actually have *not* stopped.
After some discussion with Frank Eigler and Jakub Jelinek, it was
decided that this bug should be fixed on the client side (i.e., the
program that actually reads the probes), and this is why I'm proposing
this patch.
The idea is simple: we will have a gdbarch method, which, for now, is
only used by i386. The generic code that deals with register operands
on gdb/stap-probe.c will call this method if it exists, passing the
current parse information, the register name and its number.
The i386 method will then verify if the register size is greater or
equal than the size reported by the stap probe (the "4@" part). If it
is, we're fine. Otherwise, it will check if we're dealing with any of
the "extendable" registers (like ax, bx, si, di, sp, etc.). If we
are, it will change the register name to include the "e" prefix.
I have tested the patch here in many scenarios, and it fixes Andrew's
bug and also the regressions I mentioned before, on
gdb.base/stap-probe.exp. No regressions where found on other tests.
Comments?
gdb/ChangeLog:
2019-06-27 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/24541
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh: Add 'stap_adjust_register'.
* i386-tdep.c: Include '<unordered_set>'.
(i386_stap_adjust_register): New function.
(i386_elf_init_abi): Register 'i386_stap_adjust_register'.
* stap-probe.c (stap_parse_register_operand): Call
'gdbarch_stap_adjust_register'.
2019-06-27 05:34:50 +08:00
|
|
|
|
|
2019-07-02 19:06:06 +08:00
|
|
|
|
if (regname != newregname)
|
Adjust i386 registers on SystemTap probes' arguments (PR breakpoints/24541)
This bug has been reported on PR breakpoints/24541, but it is possible
to reproduce it easily by running:
make check-gdb TESTS=gdb.base/stap-probe.exp RUNTESTFLAGS='--target_board unix/-m32'
The underlying cause is kind of complex, and involves decisions made
by GCC and the sys/sdt.h header file about how to represent a probe
argument that lives in a register in 32-bit programs. I'll use
Andrew's example on the bug to illustrate the problem.
libstdc++ has a probe named "throw" with two arguments. On i386, the
probe is:
stapsdt 0x00000028 NT_STAPSDT (SystemTap probe descriptors)
Provider: libstdcxx
Name: throw
Location: 0x00072c96, Base: 0x00133d64, Semaphore: 0x00000000
Arguments: 4@%si 4@%di
I.e., the first argument is an unsigned 32-bit value (represented by
the "4@") that lives on %si, and the second argument is an unsigned
32-bit value that lives on %di. Note the discrepancy between the
argument size reported by the probe (32-bit) and the register size
being used to store the value (16-bit).
However, if you take a look at the disassemble of a program that uses
this probe, you will see:
00072c80 <__cxa_throw@@CXXABI_1.3>:
72c80: 57 push %edi
72c81: 56 push %esi
72c82: 53 push %ebx
72c83: 8b 74 24 10 mov 0x10(%esp),%esi
72c87: e8 74 bf ff ff call 6ec00 <__cxa_finalize@plt+0x980>
72c8c: 81 c3 74 e3 10 00 add $0x10e374,%ebx
72c92: 8b 7c 24 14 mov 0x14(%esp),%edi
72c96: 90 nop <----------------- PROBE IS HERE
72c97: e8 d4 a2 ff ff call 6cf70 <__cxa_get_globals@plt>
72c9c: 83 40 04 01 addl $0x1,0x4(%eax)
72ca0: 83 ec 04 sub $0x4,%esp
72ca3: ff 74 24 1c pushl 0x1c(%esp)
72ca7: 57 push %edi
72ca8: 56 push %esi
72ca9: e8 62 a3 ff ff call 6d010 <__cxa_init_primary_exception@plt>
72cae: 8d 70 40 lea 0x40(%eax),%esi
72cb1: c7 00 01 00 00 00 movl $0x1,(%eax)
72cb7: 89 34 24 mov %esi,(%esp)
72cba: e8 61 96 ff ff call 6c320 <_Unwind_RaiseException@plt>
72cbf: 89 34 24 mov %esi,(%esp)
72cc2: e8 c9 84 ff ff call 6b190 <__cxa_begin_catch@plt>
72cc7: e8 d4 b3 ff ff call 6e0a0 <_ZSt9terminatev@plt>
72ccc: 66 90 xchg %ax,%ax
72cce: 66 90 xchg %ax,%ax
Note how the program is actually using %edi, and not %di, to store the
second argument. This is the problem here.
GDB will basically read the probe argument, then read the contents of
%di, and then cast this value to uint32_t, which causes the wrong
value to be obtained. In the gdb.base/stap-probe.exp case, this makes
GDB read the wrong memory location, and not be able to display a test
string. In Andrew's example, this causes GDB to actually stop at a
"catch throw" when it should actually have *not* stopped.
After some discussion with Frank Eigler and Jakub Jelinek, it was
decided that this bug should be fixed on the client side (i.e., the
program that actually reads the probes), and this is why I'm proposing
this patch.
The idea is simple: we will have a gdbarch method, which, for now, is
only used by i386. The generic code that deals with register operands
on gdb/stap-probe.c will call this method if it exists, passing the
current parse information, the register name and its number.
The i386 method will then verify if the register size is greater or
equal than the size reported by the stap probe (the "4@" part). If it
is, we're fine. Otherwise, it will check if we're dealing with any of
the "extendable" registers (like ax, bx, si, di, sp, etc.). If we
are, it will change the register name to include the "e" prefix.
I have tested the patch here in many scenarios, and it fixes Andrew's
bug and also the regressions I mentioned before, on
gdb.base/stap-probe.exp. No regressions where found on other tests.
Comments?
gdb/ChangeLog:
2019-06-27 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/24541
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh: Add 'stap_adjust_register'.
* i386-tdep.c: Include '<unordered_set>'.
(i386_stap_adjust_register): New function.
(i386_elf_init_abi): Register 'i386_stap_adjust_register'.
* stap-probe.c (stap_parse_register_operand): Call
'gdbarch_stap_adjust_register'.
2019-06-27 05:34:50 +08:00
|
|
|
|
{
|
|
|
|
|
/* This is just a check we perform to make sure that the
|
|
|
|
|
arch-dependent code has provided us with a valid
|
|
|
|
|
register name. */
|
2019-07-02 19:06:06 +08:00
|
|
|
|
regnum = user_reg_map_name_to_regnum (gdbarch, newregname.c_str (),
|
|
|
|
|
newregname.size ());
|
Adjust i386 registers on SystemTap probes' arguments (PR breakpoints/24541)
This bug has been reported on PR breakpoints/24541, but it is possible
to reproduce it easily by running:
make check-gdb TESTS=gdb.base/stap-probe.exp RUNTESTFLAGS='--target_board unix/-m32'
The underlying cause is kind of complex, and involves decisions made
by GCC and the sys/sdt.h header file about how to represent a probe
argument that lives in a register in 32-bit programs. I'll use
Andrew's example on the bug to illustrate the problem.
libstdc++ has a probe named "throw" with two arguments. On i386, the
probe is:
stapsdt 0x00000028 NT_STAPSDT (SystemTap probe descriptors)
Provider: libstdcxx
Name: throw
Location: 0x00072c96, Base: 0x00133d64, Semaphore: 0x00000000
Arguments: 4@%si 4@%di
I.e., the first argument is an unsigned 32-bit value (represented by
the "4@") that lives on %si, and the second argument is an unsigned
32-bit value that lives on %di. Note the discrepancy between the
argument size reported by the probe (32-bit) and the register size
being used to store the value (16-bit).
However, if you take a look at the disassemble of a program that uses
this probe, you will see:
00072c80 <__cxa_throw@@CXXABI_1.3>:
72c80: 57 push %edi
72c81: 56 push %esi
72c82: 53 push %ebx
72c83: 8b 74 24 10 mov 0x10(%esp),%esi
72c87: e8 74 bf ff ff call 6ec00 <__cxa_finalize@plt+0x980>
72c8c: 81 c3 74 e3 10 00 add $0x10e374,%ebx
72c92: 8b 7c 24 14 mov 0x14(%esp),%edi
72c96: 90 nop <----------------- PROBE IS HERE
72c97: e8 d4 a2 ff ff call 6cf70 <__cxa_get_globals@plt>
72c9c: 83 40 04 01 addl $0x1,0x4(%eax)
72ca0: 83 ec 04 sub $0x4,%esp
72ca3: ff 74 24 1c pushl 0x1c(%esp)
72ca7: 57 push %edi
72ca8: 56 push %esi
72ca9: e8 62 a3 ff ff call 6d010 <__cxa_init_primary_exception@plt>
72cae: 8d 70 40 lea 0x40(%eax),%esi
72cb1: c7 00 01 00 00 00 movl $0x1,(%eax)
72cb7: 89 34 24 mov %esi,(%esp)
72cba: e8 61 96 ff ff call 6c320 <_Unwind_RaiseException@plt>
72cbf: 89 34 24 mov %esi,(%esp)
72cc2: e8 c9 84 ff ff call 6b190 <__cxa_begin_catch@plt>
72cc7: e8 d4 b3 ff ff call 6e0a0 <_ZSt9terminatev@plt>
72ccc: 66 90 xchg %ax,%ax
72cce: 66 90 xchg %ax,%ax
Note how the program is actually using %edi, and not %di, to store the
second argument. This is the problem here.
GDB will basically read the probe argument, then read the contents of
%di, and then cast this value to uint32_t, which causes the wrong
value to be obtained. In the gdb.base/stap-probe.exp case, this makes
GDB read the wrong memory location, and not be able to display a test
string. In Andrew's example, this causes GDB to actually stop at a
"catch throw" when it should actually have *not* stopped.
After some discussion with Frank Eigler and Jakub Jelinek, it was
decided that this bug should be fixed on the client side (i.e., the
program that actually reads the probes), and this is why I'm proposing
this patch.
The idea is simple: we will have a gdbarch method, which, for now, is
only used by i386. The generic code that deals with register operands
on gdb/stap-probe.c will call this method if it exists, passing the
current parse information, the register name and its number.
The i386 method will then verify if the register size is greater or
equal than the size reported by the stap probe (the "4@" part). If it
is, we're fine. Otherwise, it will check if we're dealing with any of
the "extendable" registers (like ax, bx, si, di, sp, etc.). If we
are, it will change the register name to include the "e" prefix.
I have tested the patch here in many scenarios, and it fixes Andrew's
bug and also the regressions I mentioned before, on
gdb.base/stap-probe.exp. No regressions where found on other tests.
Comments?
gdb/ChangeLog:
2019-06-27 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/24541
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh: Add 'stap_adjust_register'.
* i386-tdep.c: Include '<unordered_set>'.
(i386_stap_adjust_register): New function.
(i386_elf_init_abi): Register 'i386_stap_adjust_register'.
* stap-probe.c (stap_parse_register_operand): Call
'gdbarch_stap_adjust_register'.
2019-06-27 05:34:50 +08:00
|
|
|
|
|
|
|
|
|
if (regnum == -1)
|
|
|
|
|
internal_error (__FILE__, __LINE__,
|
|
|
|
|
_("Invalid register name '%s' after replacing it"
|
|
|
|
|
" (previous name was '%s')"),
|
2019-07-02 19:06:06 +08:00
|
|
|
|
newregname.c_str (), regname.c_str ());
|
|
|
|
|
|
|
|
|
|
regname = newregname;
|
Adjust i386 registers on SystemTap probes' arguments (PR breakpoints/24541)
This bug has been reported on PR breakpoints/24541, but it is possible
to reproduce it easily by running:
make check-gdb TESTS=gdb.base/stap-probe.exp RUNTESTFLAGS='--target_board unix/-m32'
The underlying cause is kind of complex, and involves decisions made
by GCC and the sys/sdt.h header file about how to represent a probe
argument that lives in a register in 32-bit programs. I'll use
Andrew's example on the bug to illustrate the problem.
libstdc++ has a probe named "throw" with two arguments. On i386, the
probe is:
stapsdt 0x00000028 NT_STAPSDT (SystemTap probe descriptors)
Provider: libstdcxx
Name: throw
Location: 0x00072c96, Base: 0x00133d64, Semaphore: 0x00000000
Arguments: 4@%si 4@%di
I.e., the first argument is an unsigned 32-bit value (represented by
the "4@") that lives on %si, and the second argument is an unsigned
32-bit value that lives on %di. Note the discrepancy between the
argument size reported by the probe (32-bit) and the register size
being used to store the value (16-bit).
However, if you take a look at the disassemble of a program that uses
this probe, you will see:
00072c80 <__cxa_throw@@CXXABI_1.3>:
72c80: 57 push %edi
72c81: 56 push %esi
72c82: 53 push %ebx
72c83: 8b 74 24 10 mov 0x10(%esp),%esi
72c87: e8 74 bf ff ff call 6ec00 <__cxa_finalize@plt+0x980>
72c8c: 81 c3 74 e3 10 00 add $0x10e374,%ebx
72c92: 8b 7c 24 14 mov 0x14(%esp),%edi
72c96: 90 nop <----------------- PROBE IS HERE
72c97: e8 d4 a2 ff ff call 6cf70 <__cxa_get_globals@plt>
72c9c: 83 40 04 01 addl $0x1,0x4(%eax)
72ca0: 83 ec 04 sub $0x4,%esp
72ca3: ff 74 24 1c pushl 0x1c(%esp)
72ca7: 57 push %edi
72ca8: 56 push %esi
72ca9: e8 62 a3 ff ff call 6d010 <__cxa_init_primary_exception@plt>
72cae: 8d 70 40 lea 0x40(%eax),%esi
72cb1: c7 00 01 00 00 00 movl $0x1,(%eax)
72cb7: 89 34 24 mov %esi,(%esp)
72cba: e8 61 96 ff ff call 6c320 <_Unwind_RaiseException@plt>
72cbf: 89 34 24 mov %esi,(%esp)
72cc2: e8 c9 84 ff ff call 6b190 <__cxa_begin_catch@plt>
72cc7: e8 d4 b3 ff ff call 6e0a0 <_ZSt9terminatev@plt>
72ccc: 66 90 xchg %ax,%ax
72cce: 66 90 xchg %ax,%ax
Note how the program is actually using %edi, and not %di, to store the
second argument. This is the problem here.
GDB will basically read the probe argument, then read the contents of
%di, and then cast this value to uint32_t, which causes the wrong
value to be obtained. In the gdb.base/stap-probe.exp case, this makes
GDB read the wrong memory location, and not be able to display a test
string. In Andrew's example, this causes GDB to actually stop at a
"catch throw" when it should actually have *not* stopped.
After some discussion with Frank Eigler and Jakub Jelinek, it was
decided that this bug should be fixed on the client side (i.e., the
program that actually reads the probes), and this is why I'm proposing
this patch.
The idea is simple: we will have a gdbarch method, which, for now, is
only used by i386. The generic code that deals with register operands
on gdb/stap-probe.c will call this method if it exists, passing the
current parse information, the register name and its number.
The i386 method will then verify if the register size is greater or
equal than the size reported by the stap probe (the "4@" part). If it
is, we're fine. Otherwise, it will check if we're dealing with any of
the "extendable" registers (like ax, bx, si, di, sp, etc.). If we
are, it will change the register name to include the "e" prefix.
I have tested the patch here in many scenarios, and it fixes Andrew's
bug and also the regressions I mentioned before, on
gdb.base/stap-probe.exp. No regressions where found on other tests.
Comments?
gdb/ChangeLog:
2019-06-27 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/24541
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh: Add 'stap_adjust_register'.
* i386-tdep.c: Include '<unordered_set>'.
(i386_stap_adjust_register): New function.
(i386_elf_init_abi): Register 'i386_stap_adjust_register'.
* stap-probe.c (stap_parse_register_operand): Call
'gdbarch_stap_adjust_register'.
2019-06-27 05:34:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Remove `expout*' globals from parser-defs.h
This commit removes the "expout*" globals from our parser code, turning
them into a structure that is passed when an expression needs to be
evaluated. This is the initial step to make our parser less
"globalized".
This is mostly a mechanical patch, which creates a structure containing
the "expout*" globals and then modify all the functions that handle them
in order to take the structure as argument. It is big, and has been
reviewed at least 4 times, so I think everything is covered.
Below you can see the message links from the discussions:
- First attempt:
<https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html>
Message-ID: <m3k44s7qej.fsf@gmail.com>
- Second attempt:
<https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html>
Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>
- Third attempt:
<https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html>
Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com>
- Fourth (last) attempt:
<https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html>
Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com>
gdb/
2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com>
Remove some globals from our parser.
* language.c (unk_lang_parser): Add "struct parser_state"
argument.
* language.h (struct language_defn) <la_parser>: Likewise.
* parse.c (expout, expout_size, expout_ptr): Remove variables.
(initialize_expout): Add "struct parser_state" argument.
Rewrite function to use the parser state.
(reallocate_expout, write_exp_elt, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
write_dollar_variable): Likewise.
(parse_exp_in_context_1): Use parser state.
(insert_type_address_space): Add "struct parser_state" argument.
Use parser state.
(increase_expout_size): New function.
* parser-defs.h: Forward declare "struct language_defn" and
"struct parser_state".
(expout, expout_size, expout_ptr): Remove extern declarations.
(parse_gdbarch, parse_language): Rewrite macro declarations to
accept the parser state.
(struct parser_state): New struct.
(initialize_expout, reallocate_expout, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
write_exp_msymbol, write_dollar_variable,
mark_struct_expression, insert_type_address_space): Add "struct
parser_state" argument.
(increase_expout_size): New function.
* utils.c (do_clear_parser_state): New function.
(make_cleanup_clear_parser_state): Likewise.
* utils.h (make_cleanup_clear_parser_state): New function
prototype.
* aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
Update calls to write_exp* in order to pass the parser state.
* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
* i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
(i386_stap_parse_special_token_three_arg_disp): Likewise.
* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
* stap-probe.c (stap_parse_register_operand): Likewise.
(stap_parse_single_operand): Likewise.
(stap_parse_argument_1): Likewise.
(stap_parse_argument): Use parser state.
* stap-probe.h: Include "parser-defs.h".
(struct stap_parse_info) <pstate>: New field.
* c-exp.y (parse_type): Rewrite to use parser state.
(yyparse): Redefine to c_parse_internal.
(pstate): New global variable.
(parse_number): Add "struct parser_state" argument.
(write_destructor_name): Likewise.
(type_exp): Update calls to write_exp* and similars in order to
use parser state.
(exp1, exp, variable, qualified_name, space_identifier,
typename, typebase): Likewise.
(write_destructor_name, parse_number, lex_one_token,
classify_name, classify_inner_name, c_parse): Add "struct
parser_state" argument. Update function to use parser state.
* c-lang.h: Forward declare "struct parser_state".
(c_parse): Add "struct parser_state" argument.
* ada-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to ada_parse_internal.
(pstate): New variable.
(write_int, write_object_renaming, write_var_or_type,
write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
type_int, type_long, type_long_long, type_float, type_double,
type_long_double, type_char, type_boolean, type_system_address):
Add "struct parser_state" argument.
(exp1, primary, simple_exp, relation, and_exp, and_then_exp,
or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
var_or_type, aggregate, aggregate_component_list,
positional_list, others, component_group,
component_associations): Update calls to write_exp* and similar
functions in order to use parser state.
(ada_parse, write_var_from_sym, write_int,
write_exp_op_with_string, write_object_renaming,
find_primitive_type, write_selectors, write_ambiguous_var,
write_var_or_type, write_name_assoc, type_int, type_long,
type_long_long, type_float, type_double, type_long_double,
type_char, type_boolean, type_system_address): Add "struct
parser_state" argument. Adjust function to use parser state.
* ada-lang.c (parse): Likewise.
* ada-lang.h: Forward declare "struct parser_state".
(ada_parse): Add "struct parser_state" argument.
* ada-lex.l (processInt, processReal): Likewise. Adjust all
calls to both functions.
* f-exp.y (parse_type, parse_f_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to f_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp, subrange, typebase): Update calls to write_exp*
and similars in order to use parser state.
(parse_number): Adjust code to use parser state.
(yylex): Likewise.
(f_parse): New function.
* f-lang.h: Forward declare "struct parser_state".
(f_parse): Add "struct parser_state" argument.
* jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro for java_parse_internal.
(pstate): New variable.
(push_expression_name, push_expression_name, insert_exp): Add
"struct parser_state" argument.
(type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
PostIncrementExpression, PostDecrementExpression,
UnaryExpression, PreIncrementExpression, PreDecrementExpression,
UnaryExpressionNotPlusMinus, CastExpression,
MultiplicativeExpression, AdditiveExpression, ShiftExpression,
RelationalExpression, EqualityExpression, AndExpression,
ExclusiveOrExpression, InclusiveOrExpression,
ConditionalAndExpression, ConditionalOrExpression,
ConditionalExpression, Assignment, LeftHandSide): Update
calls to write_exp* and similars in order to use parser state.
(parse_number): Ajust code to use parser state.
(yylex): Likewise.
(java_parse): New function.
(push_variable): Add "struct parser_state" argument. Adjust
code to user parser state.
(push_fieldnames, push_qualified_expression_name,
push_expression_name, insert_exp): Likewise.
* jv-lang.h: Forward declare "struct parser_state".
(java_parse): Add "struct parser_state" argument.
* m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to m2_parse_internal.
(pstate): New variable.
(type_exp, exp, fblock, variable, type): Update calls to
write_exp* and similars to use parser state.
(yylex): Likewise.
(m2_parse): New function.
* m2-lang.h: Forward declare "struct parser_state".
(m2_parse): Add "struct parser_state" argument.
* objc-lang.c (end_msglist): Add "struct parser_state" argument.
* objc-lang.h: Forward declare "struct parser_state".
(end_msglist): Add "struct parser_state" argument.
* p-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to pascal_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, qualified_name, variable): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, yylex): Adjust code to use parser state.
(pascal_parse): New function.
* p-lang.h: Forward declare "struct parser_state".
(pascal_parse): Add "struct parser_state" argument.
* go-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to go_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, variable, type): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, lex_one_token, classify_name, yylex): Adjust code
to use parser state.
(go_parse): Likewise.
* go-lang.h: Forward declare "struct parser_state".
(go_parse): Add "struct parser_state" argument.
2014-03-28 06:10:40 +08:00
|
|
|
|
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
2019-05-17 04:23:24 +08:00
|
|
|
|
str.ptr = regname.c_str ();
|
|
|
|
|
str.length = regname.size ();
|
Remove `expout*' globals from parser-defs.h
This commit removes the "expout*" globals from our parser code, turning
them into a structure that is passed when an expression needs to be
evaluated. This is the initial step to make our parser less
"globalized".
This is mostly a mechanical patch, which creates a structure containing
the "expout*" globals and then modify all the functions that handle them
in order to take the structure as argument. It is big, and has been
reviewed at least 4 times, so I think everything is covered.
Below you can see the message links from the discussions:
- First attempt:
<https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html>
Message-ID: <m3k44s7qej.fsf@gmail.com>
- Second attempt:
<https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html>
Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>
- Third attempt:
<https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html>
Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com>
- Fourth (last) attempt:
<https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html>
Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com>
gdb/
2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com>
Remove some globals from our parser.
* language.c (unk_lang_parser): Add "struct parser_state"
argument.
* language.h (struct language_defn) <la_parser>: Likewise.
* parse.c (expout, expout_size, expout_ptr): Remove variables.
(initialize_expout): Add "struct parser_state" argument.
Rewrite function to use the parser state.
(reallocate_expout, write_exp_elt, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
write_dollar_variable): Likewise.
(parse_exp_in_context_1): Use parser state.
(insert_type_address_space): Add "struct parser_state" argument.
Use parser state.
(increase_expout_size): New function.
* parser-defs.h: Forward declare "struct language_defn" and
"struct parser_state".
(expout, expout_size, expout_ptr): Remove extern declarations.
(parse_gdbarch, parse_language): Rewrite macro declarations to
accept the parser state.
(struct parser_state): New struct.
(initialize_expout, reallocate_expout, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
write_exp_msymbol, write_dollar_variable,
mark_struct_expression, insert_type_address_space): Add "struct
parser_state" argument.
(increase_expout_size): New function.
* utils.c (do_clear_parser_state): New function.
(make_cleanup_clear_parser_state): Likewise.
* utils.h (make_cleanup_clear_parser_state): New function
prototype.
* aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
Update calls to write_exp* in order to pass the parser state.
* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
* i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
(i386_stap_parse_special_token_three_arg_disp): Likewise.
* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
* stap-probe.c (stap_parse_register_operand): Likewise.
(stap_parse_single_operand): Likewise.
(stap_parse_argument_1): Likewise.
(stap_parse_argument): Use parser state.
* stap-probe.h: Include "parser-defs.h".
(struct stap_parse_info) <pstate>: New field.
* c-exp.y (parse_type): Rewrite to use parser state.
(yyparse): Redefine to c_parse_internal.
(pstate): New global variable.
(parse_number): Add "struct parser_state" argument.
(write_destructor_name): Likewise.
(type_exp): Update calls to write_exp* and similars in order to
use parser state.
(exp1, exp, variable, qualified_name, space_identifier,
typename, typebase): Likewise.
(write_destructor_name, parse_number, lex_one_token,
classify_name, classify_inner_name, c_parse): Add "struct
parser_state" argument. Update function to use parser state.
* c-lang.h: Forward declare "struct parser_state".
(c_parse): Add "struct parser_state" argument.
* ada-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to ada_parse_internal.
(pstate): New variable.
(write_int, write_object_renaming, write_var_or_type,
write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
type_int, type_long, type_long_long, type_float, type_double,
type_long_double, type_char, type_boolean, type_system_address):
Add "struct parser_state" argument.
(exp1, primary, simple_exp, relation, and_exp, and_then_exp,
or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
var_or_type, aggregate, aggregate_component_list,
positional_list, others, component_group,
component_associations): Update calls to write_exp* and similar
functions in order to use parser state.
(ada_parse, write_var_from_sym, write_int,
write_exp_op_with_string, write_object_renaming,
find_primitive_type, write_selectors, write_ambiguous_var,
write_var_or_type, write_name_assoc, type_int, type_long,
type_long_long, type_float, type_double, type_long_double,
type_char, type_boolean, type_system_address): Add "struct
parser_state" argument. Adjust function to use parser state.
* ada-lang.c (parse): Likewise.
* ada-lang.h: Forward declare "struct parser_state".
(ada_parse): Add "struct parser_state" argument.
* ada-lex.l (processInt, processReal): Likewise. Adjust all
calls to both functions.
* f-exp.y (parse_type, parse_f_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to f_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp, subrange, typebase): Update calls to write_exp*
and similars in order to use parser state.
(parse_number): Adjust code to use parser state.
(yylex): Likewise.
(f_parse): New function.
* f-lang.h: Forward declare "struct parser_state".
(f_parse): Add "struct parser_state" argument.
* jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro for java_parse_internal.
(pstate): New variable.
(push_expression_name, push_expression_name, insert_exp): Add
"struct parser_state" argument.
(type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
PostIncrementExpression, PostDecrementExpression,
UnaryExpression, PreIncrementExpression, PreDecrementExpression,
UnaryExpressionNotPlusMinus, CastExpression,
MultiplicativeExpression, AdditiveExpression, ShiftExpression,
RelationalExpression, EqualityExpression, AndExpression,
ExclusiveOrExpression, InclusiveOrExpression,
ConditionalAndExpression, ConditionalOrExpression,
ConditionalExpression, Assignment, LeftHandSide): Update
calls to write_exp* and similars in order to use parser state.
(parse_number): Ajust code to use parser state.
(yylex): Likewise.
(java_parse): New function.
(push_variable): Add "struct parser_state" argument. Adjust
code to user parser state.
(push_fieldnames, push_qualified_expression_name,
push_expression_name, insert_exp): Likewise.
* jv-lang.h: Forward declare "struct parser_state".
(java_parse): Add "struct parser_state" argument.
* m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to m2_parse_internal.
(pstate): New variable.
(type_exp, exp, fblock, variable, type): Update calls to
write_exp* and similars to use parser state.
(yylex): Likewise.
(m2_parse): New function.
* m2-lang.h: Forward declare "struct parser_state".
(m2_parse): Add "struct parser_state" argument.
* objc-lang.c (end_msglist): Add "struct parser_state" argument.
* objc-lang.h: Forward declare "struct parser_state".
(end_msglist): Add "struct parser_state" argument.
* p-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to pascal_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, qualified_name, variable): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, yylex): Adjust code to use parser state.
(pascal_parse): New function.
* p-lang.h: Forward declare "struct parser_state".
(pascal_parse): Add "struct parser_state" argument.
* go-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to go_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, variable, type): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, lex_one_token, classify_name, yylex): Adjust code
to use parser state.
(go_parse): Likewise.
* go-lang.h: Forward declare "struct parser_state".
(go_parse): Add "struct parser_state" argument.
2014-03-28 06:10:40 +08:00
|
|
|
|
write_exp_string (&p->pstate, str);
|
|
|
|
|
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
if (indirect_p)
|
|
|
|
|
{
|
|
|
|
|
if (disp_p)
|
Remove `expout*' globals from parser-defs.h
This commit removes the "expout*" globals from our parser code, turning
them into a structure that is passed when an expression needs to be
evaluated. This is the initial step to make our parser less
"globalized".
This is mostly a mechanical patch, which creates a structure containing
the "expout*" globals and then modify all the functions that handle them
in order to take the structure as argument. It is big, and has been
reviewed at least 4 times, so I think everything is covered.
Below you can see the message links from the discussions:
- First attempt:
<https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html>
Message-ID: <m3k44s7qej.fsf@gmail.com>
- Second attempt:
<https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html>
Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>
- Third attempt:
<https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html>
Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com>
- Fourth (last) attempt:
<https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html>
Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com>
gdb/
2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com>
Remove some globals from our parser.
* language.c (unk_lang_parser): Add "struct parser_state"
argument.
* language.h (struct language_defn) <la_parser>: Likewise.
* parse.c (expout, expout_size, expout_ptr): Remove variables.
(initialize_expout): Add "struct parser_state" argument.
Rewrite function to use the parser state.
(reallocate_expout, write_exp_elt, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
write_dollar_variable): Likewise.
(parse_exp_in_context_1): Use parser state.
(insert_type_address_space): Add "struct parser_state" argument.
Use parser state.
(increase_expout_size): New function.
* parser-defs.h: Forward declare "struct language_defn" and
"struct parser_state".
(expout, expout_size, expout_ptr): Remove extern declarations.
(parse_gdbarch, parse_language): Rewrite macro declarations to
accept the parser state.
(struct parser_state): New struct.
(initialize_expout, reallocate_expout, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
write_exp_msymbol, write_dollar_variable,
mark_struct_expression, insert_type_address_space): Add "struct
parser_state" argument.
(increase_expout_size): New function.
* utils.c (do_clear_parser_state): New function.
(make_cleanup_clear_parser_state): Likewise.
* utils.h (make_cleanup_clear_parser_state): New function
prototype.
* aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
Update calls to write_exp* in order to pass the parser state.
* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
* i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
(i386_stap_parse_special_token_three_arg_disp): Likewise.
* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
* stap-probe.c (stap_parse_register_operand): Likewise.
(stap_parse_single_operand): Likewise.
(stap_parse_argument_1): Likewise.
(stap_parse_argument): Use parser state.
* stap-probe.h: Include "parser-defs.h".
(struct stap_parse_info) <pstate>: New field.
* c-exp.y (parse_type): Rewrite to use parser state.
(yyparse): Redefine to c_parse_internal.
(pstate): New global variable.
(parse_number): Add "struct parser_state" argument.
(write_destructor_name): Likewise.
(type_exp): Update calls to write_exp* and similars in order to
use parser state.
(exp1, exp, variable, qualified_name, space_identifier,
typename, typebase): Likewise.
(write_destructor_name, parse_number, lex_one_token,
classify_name, classify_inner_name, c_parse): Add "struct
parser_state" argument. Update function to use parser state.
* c-lang.h: Forward declare "struct parser_state".
(c_parse): Add "struct parser_state" argument.
* ada-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to ada_parse_internal.
(pstate): New variable.
(write_int, write_object_renaming, write_var_or_type,
write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
type_int, type_long, type_long_long, type_float, type_double,
type_long_double, type_char, type_boolean, type_system_address):
Add "struct parser_state" argument.
(exp1, primary, simple_exp, relation, and_exp, and_then_exp,
or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
var_or_type, aggregate, aggregate_component_list,
positional_list, others, component_group,
component_associations): Update calls to write_exp* and similar
functions in order to use parser state.
(ada_parse, write_var_from_sym, write_int,
write_exp_op_with_string, write_object_renaming,
find_primitive_type, write_selectors, write_ambiguous_var,
write_var_or_type, write_name_assoc, type_int, type_long,
type_long_long, type_float, type_double, type_long_double,
type_char, type_boolean, type_system_address): Add "struct
parser_state" argument. Adjust function to use parser state.
* ada-lang.c (parse): Likewise.
* ada-lang.h: Forward declare "struct parser_state".
(ada_parse): Add "struct parser_state" argument.
* ada-lex.l (processInt, processReal): Likewise. Adjust all
calls to both functions.
* f-exp.y (parse_type, parse_f_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to f_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp, subrange, typebase): Update calls to write_exp*
and similars in order to use parser state.
(parse_number): Adjust code to use parser state.
(yylex): Likewise.
(f_parse): New function.
* f-lang.h: Forward declare "struct parser_state".
(f_parse): Add "struct parser_state" argument.
* jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro for java_parse_internal.
(pstate): New variable.
(push_expression_name, push_expression_name, insert_exp): Add
"struct parser_state" argument.
(type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
PostIncrementExpression, PostDecrementExpression,
UnaryExpression, PreIncrementExpression, PreDecrementExpression,
UnaryExpressionNotPlusMinus, CastExpression,
MultiplicativeExpression, AdditiveExpression, ShiftExpression,
RelationalExpression, EqualityExpression, AndExpression,
ExclusiveOrExpression, InclusiveOrExpression,
ConditionalAndExpression, ConditionalOrExpression,
ConditionalExpression, Assignment, LeftHandSide): Update
calls to write_exp* and similars in order to use parser state.
(parse_number): Ajust code to use parser state.
(yylex): Likewise.
(java_parse): New function.
(push_variable): Add "struct parser_state" argument. Adjust
code to user parser state.
(push_fieldnames, push_qualified_expression_name,
push_expression_name, insert_exp): Likewise.
* jv-lang.h: Forward declare "struct parser_state".
(java_parse): Add "struct parser_state" argument.
* m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to m2_parse_internal.
(pstate): New variable.
(type_exp, exp, fblock, variable, type): Update calls to
write_exp* and similars to use parser state.
(yylex): Likewise.
(m2_parse): New function.
* m2-lang.h: Forward declare "struct parser_state".
(m2_parse): Add "struct parser_state" argument.
* objc-lang.c (end_msglist): Add "struct parser_state" argument.
* objc-lang.h: Forward declare "struct parser_state".
(end_msglist): Add "struct parser_state" argument.
* p-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to pascal_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, qualified_name, variable): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, yylex): Adjust code to use parser state.
(pascal_parse): New function.
* p-lang.h: Forward declare "struct parser_state".
(pascal_parse): Add "struct parser_state" argument.
* go-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to go_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, variable, type): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, lex_one_token, classify_name, yylex): Adjust code
to use parser state.
(go_parse): Likewise.
* go-lang.h: Forward declare "struct parser_state".
(go_parse): Add "struct parser_state" argument.
2014-03-28 06:10:40 +08:00
|
|
|
|
write_exp_elt_opcode (&p->pstate, BINOP_ADD);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* Casting to the expected type. */
|
Remove `expout*' globals from parser-defs.h
This commit removes the "expout*" globals from our parser code, turning
them into a structure that is passed when an expression needs to be
evaluated. This is the initial step to make our parser less
"globalized".
This is mostly a mechanical patch, which creates a structure containing
the "expout*" globals and then modify all the functions that handle them
in order to take the structure as argument. It is big, and has been
reviewed at least 4 times, so I think everything is covered.
Below you can see the message links from the discussions:
- First attempt:
<https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html>
Message-ID: <m3k44s7qej.fsf@gmail.com>
- Second attempt:
<https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html>
Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>
- Third attempt:
<https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html>
Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com>
- Fourth (last) attempt:
<https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html>
Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com>
gdb/
2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com>
Remove some globals from our parser.
* language.c (unk_lang_parser): Add "struct parser_state"
argument.
* language.h (struct language_defn) <la_parser>: Likewise.
* parse.c (expout, expout_size, expout_ptr): Remove variables.
(initialize_expout): Add "struct parser_state" argument.
Rewrite function to use the parser state.
(reallocate_expout, write_exp_elt, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
write_dollar_variable): Likewise.
(parse_exp_in_context_1): Use parser state.
(insert_type_address_space): Add "struct parser_state" argument.
Use parser state.
(increase_expout_size): New function.
* parser-defs.h: Forward declare "struct language_defn" and
"struct parser_state".
(expout, expout_size, expout_ptr): Remove extern declarations.
(parse_gdbarch, parse_language): Rewrite macro declarations to
accept the parser state.
(struct parser_state): New struct.
(initialize_expout, reallocate_expout, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
write_exp_msymbol, write_dollar_variable,
mark_struct_expression, insert_type_address_space): Add "struct
parser_state" argument.
(increase_expout_size): New function.
* utils.c (do_clear_parser_state): New function.
(make_cleanup_clear_parser_state): Likewise.
* utils.h (make_cleanup_clear_parser_state): New function
prototype.
* aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
Update calls to write_exp* in order to pass the parser state.
* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
* i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
(i386_stap_parse_special_token_three_arg_disp): Likewise.
* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
* stap-probe.c (stap_parse_register_operand): Likewise.
(stap_parse_single_operand): Likewise.
(stap_parse_argument_1): Likewise.
(stap_parse_argument): Use parser state.
* stap-probe.h: Include "parser-defs.h".
(struct stap_parse_info) <pstate>: New field.
* c-exp.y (parse_type): Rewrite to use parser state.
(yyparse): Redefine to c_parse_internal.
(pstate): New global variable.
(parse_number): Add "struct parser_state" argument.
(write_destructor_name): Likewise.
(type_exp): Update calls to write_exp* and similars in order to
use parser state.
(exp1, exp, variable, qualified_name, space_identifier,
typename, typebase): Likewise.
(write_destructor_name, parse_number, lex_one_token,
classify_name, classify_inner_name, c_parse): Add "struct
parser_state" argument. Update function to use parser state.
* c-lang.h: Forward declare "struct parser_state".
(c_parse): Add "struct parser_state" argument.
* ada-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to ada_parse_internal.
(pstate): New variable.
(write_int, write_object_renaming, write_var_or_type,
write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
type_int, type_long, type_long_long, type_float, type_double,
type_long_double, type_char, type_boolean, type_system_address):
Add "struct parser_state" argument.
(exp1, primary, simple_exp, relation, and_exp, and_then_exp,
or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
var_or_type, aggregate, aggregate_component_list,
positional_list, others, component_group,
component_associations): Update calls to write_exp* and similar
functions in order to use parser state.
(ada_parse, write_var_from_sym, write_int,
write_exp_op_with_string, write_object_renaming,
find_primitive_type, write_selectors, write_ambiguous_var,
write_var_or_type, write_name_assoc, type_int, type_long,
type_long_long, type_float, type_double, type_long_double,
type_char, type_boolean, type_system_address): Add "struct
parser_state" argument. Adjust function to use parser state.
* ada-lang.c (parse): Likewise.
* ada-lang.h: Forward declare "struct parser_state".
(ada_parse): Add "struct parser_state" argument.
* ada-lex.l (processInt, processReal): Likewise. Adjust all
calls to both functions.
* f-exp.y (parse_type, parse_f_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to f_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp, subrange, typebase): Update calls to write_exp*
and similars in order to use parser state.
(parse_number): Adjust code to use parser state.
(yylex): Likewise.
(f_parse): New function.
* f-lang.h: Forward declare "struct parser_state".
(f_parse): Add "struct parser_state" argument.
* jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro for java_parse_internal.
(pstate): New variable.
(push_expression_name, push_expression_name, insert_exp): Add
"struct parser_state" argument.
(type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
PostIncrementExpression, PostDecrementExpression,
UnaryExpression, PreIncrementExpression, PreDecrementExpression,
UnaryExpressionNotPlusMinus, CastExpression,
MultiplicativeExpression, AdditiveExpression, ShiftExpression,
RelationalExpression, EqualityExpression, AndExpression,
ExclusiveOrExpression, InclusiveOrExpression,
ConditionalAndExpression, ConditionalOrExpression,
ConditionalExpression, Assignment, LeftHandSide): Update
calls to write_exp* and similars in order to use parser state.
(parse_number): Ajust code to use parser state.
(yylex): Likewise.
(java_parse): New function.
(push_variable): Add "struct parser_state" argument. Adjust
code to user parser state.
(push_fieldnames, push_qualified_expression_name,
push_expression_name, insert_exp): Likewise.
* jv-lang.h: Forward declare "struct parser_state".
(java_parse): Add "struct parser_state" argument.
* m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to m2_parse_internal.
(pstate): New variable.
(type_exp, exp, fblock, variable, type): Update calls to
write_exp* and similars to use parser state.
(yylex): Likewise.
(m2_parse): New function.
* m2-lang.h: Forward declare "struct parser_state".
(m2_parse): Add "struct parser_state" argument.
* objc-lang.c (end_msglist): Add "struct parser_state" argument.
* objc-lang.h: Forward declare "struct parser_state".
(end_msglist): Add "struct parser_state" argument.
* p-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to pascal_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, qualified_name, variable): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, yylex): Adjust code to use parser state.
(pascal_parse): New function.
* p-lang.h: Forward declare "struct parser_state".
(pascal_parse): Add "struct parser_state" argument.
* go-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to go_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, variable, type): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, lex_one_token, classify_name, yylex): Adjust code
to use parser state.
(go_parse): Likewise.
* go-lang.h: Forward declare "struct parser_state".
(go_parse): Add "struct parser_state" argument.
2014-03-28 06:10:40 +08:00
|
|
|
|
write_exp_elt_opcode (&p->pstate, UNOP_CAST);
|
|
|
|
|
write_exp_elt_type (&p->pstate, lookup_pointer_type (p->arg_type));
|
|
|
|
|
write_exp_elt_opcode (&p->pstate, UNOP_CAST);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Remove `expout*' globals from parser-defs.h
This commit removes the "expout*" globals from our parser code, turning
them into a structure that is passed when an expression needs to be
evaluated. This is the initial step to make our parser less
"globalized".
This is mostly a mechanical patch, which creates a structure containing
the "expout*" globals and then modify all the functions that handle them
in order to take the structure as argument. It is big, and has been
reviewed at least 4 times, so I think everything is covered.
Below you can see the message links from the discussions:
- First attempt:
<https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html>
Message-ID: <m3k44s7qej.fsf@gmail.com>
- Second attempt:
<https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html>
Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>
- Third attempt:
<https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html>
Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com>
- Fourth (last) attempt:
<https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html>
Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com>
gdb/
2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com>
Remove some globals from our parser.
* language.c (unk_lang_parser): Add "struct parser_state"
argument.
* language.h (struct language_defn) <la_parser>: Likewise.
* parse.c (expout, expout_size, expout_ptr): Remove variables.
(initialize_expout): Add "struct parser_state" argument.
Rewrite function to use the parser state.
(reallocate_expout, write_exp_elt, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
write_dollar_variable): Likewise.
(parse_exp_in_context_1): Use parser state.
(insert_type_address_space): Add "struct parser_state" argument.
Use parser state.
(increase_expout_size): New function.
* parser-defs.h: Forward declare "struct language_defn" and
"struct parser_state".
(expout, expout_size, expout_ptr): Remove extern declarations.
(parse_gdbarch, parse_language): Rewrite macro declarations to
accept the parser state.
(struct parser_state): New struct.
(initialize_expout, reallocate_expout, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
write_exp_msymbol, write_dollar_variable,
mark_struct_expression, insert_type_address_space): Add "struct
parser_state" argument.
(increase_expout_size): New function.
* utils.c (do_clear_parser_state): New function.
(make_cleanup_clear_parser_state): Likewise.
* utils.h (make_cleanup_clear_parser_state): New function
prototype.
* aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
Update calls to write_exp* in order to pass the parser state.
* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
* i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
(i386_stap_parse_special_token_three_arg_disp): Likewise.
* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
* stap-probe.c (stap_parse_register_operand): Likewise.
(stap_parse_single_operand): Likewise.
(stap_parse_argument_1): Likewise.
(stap_parse_argument): Use parser state.
* stap-probe.h: Include "parser-defs.h".
(struct stap_parse_info) <pstate>: New field.
* c-exp.y (parse_type): Rewrite to use parser state.
(yyparse): Redefine to c_parse_internal.
(pstate): New global variable.
(parse_number): Add "struct parser_state" argument.
(write_destructor_name): Likewise.
(type_exp): Update calls to write_exp* and similars in order to
use parser state.
(exp1, exp, variable, qualified_name, space_identifier,
typename, typebase): Likewise.
(write_destructor_name, parse_number, lex_one_token,
classify_name, classify_inner_name, c_parse): Add "struct
parser_state" argument. Update function to use parser state.
* c-lang.h: Forward declare "struct parser_state".
(c_parse): Add "struct parser_state" argument.
* ada-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to ada_parse_internal.
(pstate): New variable.
(write_int, write_object_renaming, write_var_or_type,
write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
type_int, type_long, type_long_long, type_float, type_double,
type_long_double, type_char, type_boolean, type_system_address):
Add "struct parser_state" argument.
(exp1, primary, simple_exp, relation, and_exp, and_then_exp,
or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
var_or_type, aggregate, aggregate_component_list,
positional_list, others, component_group,
component_associations): Update calls to write_exp* and similar
functions in order to use parser state.
(ada_parse, write_var_from_sym, write_int,
write_exp_op_with_string, write_object_renaming,
find_primitive_type, write_selectors, write_ambiguous_var,
write_var_or_type, write_name_assoc, type_int, type_long,
type_long_long, type_float, type_double, type_long_double,
type_char, type_boolean, type_system_address): Add "struct
parser_state" argument. Adjust function to use parser state.
* ada-lang.c (parse): Likewise.
* ada-lang.h: Forward declare "struct parser_state".
(ada_parse): Add "struct parser_state" argument.
* ada-lex.l (processInt, processReal): Likewise. Adjust all
calls to both functions.
* f-exp.y (parse_type, parse_f_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to f_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp, subrange, typebase): Update calls to write_exp*
and similars in order to use parser state.
(parse_number): Adjust code to use parser state.
(yylex): Likewise.
(f_parse): New function.
* f-lang.h: Forward declare "struct parser_state".
(f_parse): Add "struct parser_state" argument.
* jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro for java_parse_internal.
(pstate): New variable.
(push_expression_name, push_expression_name, insert_exp): Add
"struct parser_state" argument.
(type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
PostIncrementExpression, PostDecrementExpression,
UnaryExpression, PreIncrementExpression, PreDecrementExpression,
UnaryExpressionNotPlusMinus, CastExpression,
MultiplicativeExpression, AdditiveExpression, ShiftExpression,
RelationalExpression, EqualityExpression, AndExpression,
ExclusiveOrExpression, InclusiveOrExpression,
ConditionalAndExpression, ConditionalOrExpression,
ConditionalExpression, Assignment, LeftHandSide): Update
calls to write_exp* and similars in order to use parser state.
(parse_number): Ajust code to use parser state.
(yylex): Likewise.
(java_parse): New function.
(push_variable): Add "struct parser_state" argument. Adjust
code to user parser state.
(push_fieldnames, push_qualified_expression_name,
push_expression_name, insert_exp): Likewise.
* jv-lang.h: Forward declare "struct parser_state".
(java_parse): Add "struct parser_state" argument.
* m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to m2_parse_internal.
(pstate): New variable.
(type_exp, exp, fblock, variable, type): Update calls to
write_exp* and similars to use parser state.
(yylex): Likewise.
(m2_parse): New function.
* m2-lang.h: Forward declare "struct parser_state".
(m2_parse): Add "struct parser_state" argument.
* objc-lang.c (end_msglist): Add "struct parser_state" argument.
* objc-lang.h: Forward declare "struct parser_state".
(end_msglist): Add "struct parser_state" argument.
* p-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to pascal_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, qualified_name, variable): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, yylex): Adjust code to use parser state.
(pascal_parse): New function.
* p-lang.h: Forward declare "struct parser_state".
(pascal_parse): Add "struct parser_state" argument.
* go-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to go_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, variable, type): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, lex_one_token, classify_name, yylex): Adjust code
to use parser state.
(go_parse): Likewise.
* go-lang.h: Forward declare "struct parser_state".
(go_parse): Add "struct parser_state" argument.
2014-03-28 06:10:40 +08:00
|
|
|
|
write_exp_elt_opcode (&p->pstate, UNOP_IND);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Getting rid of the register name suffix. */
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
if (stap_check_register_suffix (gdbarch, p->arg, ®_suffix))
|
|
|
|
|
p->arg += strlen (reg_suffix);
|
|
|
|
|
else
|
|
|
|
|
error (_("Missing register name suffix on expression `%s'."),
|
|
|
|
|
p->saved_arg);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* Getting rid of the register indirection suffix. */
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
if (indirect_p)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
if (stap_check_register_indirection_suffix (gdbarch, p->arg,
|
|
|
|
|
®_ind_suffix))
|
|
|
|
|
p->arg += strlen (reg_ind_suffix);
|
|
|
|
|
else
|
|
|
|
|
error (_("Missing indirection suffix on expression `%s'."),
|
|
|
|
|
p->saved_arg);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function is responsible for parsing a single operand.
|
|
|
|
|
|
|
|
|
|
A single operand can be:
|
|
|
|
|
|
|
|
|
|
- an unary operation (e.g., `-5', `~2', or even with subexpressions
|
|
|
|
|
like `-(2 + 1)')
|
|
|
|
|
- a register displacement, which will be treated as a register
|
|
|
|
|
operand (e.g., `-4(%eax)' on x86)
|
|
|
|
|
- a numeric constant, or
|
|
|
|
|
- a register operand (see function `stap_parse_register_operand')
|
|
|
|
|
|
|
|
|
|
The function also calls special-handling functions to deal with
|
|
|
|
|
unrecognized operands, allowing arch-specific parsers to be
|
|
|
|
|
created. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
stap_parse_single_operand (struct stap_parse_info *p)
|
|
|
|
|
{
|
|
|
|
|
struct gdbarch *gdbarch = p->gdbarch;
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
const char *int_prefix = NULL;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* We first try to parse this token as a "special token". */
|
2019-05-17 04:17:30 +08:00
|
|
|
|
if (gdbarch_stap_parse_special_token_p (gdbarch)
|
|
|
|
|
&& (gdbarch_stap_parse_special_token (gdbarch, p) != 0))
|
|
|
|
|
{
|
|
|
|
|
/* If the return value of the above function is not zero,
|
|
|
|
|
it means it successfully parsed the special token.
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
2019-05-17 04:17:30 +08:00
|
|
|
|
If it is NULL, we try to parse it using our method. */
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
if (*p->arg == '-' || *p->arg == '~' || *p->arg == '+')
|
|
|
|
|
{
|
|
|
|
|
char c = *p->arg;
|
|
|
|
|
/* We use this variable to do a lookahead. */
|
|
|
|
|
const char *tmp = p->arg;
|
2019-05-17 03:58:55 +08:00
|
|
|
|
bool has_digit = false;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
2013-12-24 06:48:08 +08:00
|
|
|
|
/* Skipping signal. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
++tmp;
|
|
|
|
|
|
|
|
|
|
/* This is an unary operation. Here is a list of allowed tokens
|
|
|
|
|
here:
|
|
|
|
|
|
|
|
|
|
- numeric literal;
|
|
|
|
|
- number (from register displacement)
|
|
|
|
|
- subexpression (beginning with `(')
|
|
|
|
|
|
|
|
|
|
We handle the register displacement here, and the other cases
|
|
|
|
|
recursively. */
|
|
|
|
|
if (p->inside_paren_p)
|
Rename _const functions to use overloading instead
This renames a few functions -- skip_spaces_const,
skip_to_space_const, get_number_const, extract_arg_const -- to drop
the "_const" suffix and instead rely on overloading.
This makes future const fixes simpler by reducing the number of lines
that must be changed. I think it is also not any less clear, as all
these functions have the same interface as their non-const versions by
design. Furthermore there's an example of using an overload in-tree
already, namely check_for_argument.
This patch was largely created using some perl one-liners; then a few
fixes were applied by hand.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* common/common-utils.h (skip_to_space): Remove macro, redeclare
as function.
(skip_to_space): Rename from skip_to_space_const.
* common/common-utils.c (skip_to_space): New function.
(skip_to_space): Rename from skip_to_space_const.
* cli/cli-utils.h (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
* cli/cli-utils.c (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
(number_or_range_parser::get_number): Use ::get_number.
* aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c,
break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c,
cli/cli-script.c, cli/cli-setshow.c, compile/compile.c,
completer.c, demangle.c, disasm.c, findcmd.c, linespec.c,
linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c,
minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c,
python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c,
stap-probe.c, tid-parse.c, tracepoint.c: Update all callers.
2017-09-11 04:19:19 +08:00
|
|
|
|
tmp = skip_spaces (tmp);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Fix for PR gdb/17235: possible bug extracting systemtap probe operand
This patch is a fix to PR gdb/17235. The bug is about an unused
variable that got declared and set during one of the parsing phases of
an SDT probe's argument. I took the opportunity to rewrite some of the
code to improve the parsing. The bug was actually a thinko, because
what I wanted to do in the code was to discard the number on the string
being parsed.
During this portion, the code identifies that it is dealing with an
expression that begins with a sign ('+', '-' or '~'). This means that
the expression could be:
- a numeric literal (e.g., '+5')
- a register displacement (e.g., '-4(%rsp)')
- a subexpression (e.g., '-(2*3)')
So, after saving the sign and moving forward 1 char, now the code needs
to know if there is a digit followed by a register displacement prefix
operand (e.g., '(' on x86_64). If yes, then it is a register
operation. If not, then it will be handled recursively, and the code
will later apply the requested operation on the result (either a '+', a
'-' or a '~').
With the bug, the code was correctly discarding the digit (though using
strtol unnecessarily), but it wasn't properly dealing with
subexpressions when the register indirection prefix was '(', like on
x86_64. This patch also fixes this bug, and includes a testcase. It
passes on x86_64 Fedora 20.
2014-09-06 03:21:44 +08:00
|
|
|
|
while (isdigit (*tmp))
|
2013-03-14 00:45:11 +08:00
|
|
|
|
{
|
Fix for PR gdb/17235: possible bug extracting systemtap probe operand
This patch is a fix to PR gdb/17235. The bug is about an unused
variable that got declared and set during one of the parsing phases of
an SDT probe's argument. I took the opportunity to rewrite some of the
code to improve the parsing. The bug was actually a thinko, because
what I wanted to do in the code was to discard the number on the string
being parsed.
During this portion, the code identifies that it is dealing with an
expression that begins with a sign ('+', '-' or '~'). This means that
the expression could be:
- a numeric literal (e.g., '+5')
- a register displacement (e.g., '-4(%rsp)')
- a subexpression (e.g., '-(2*3)')
So, after saving the sign and moving forward 1 char, now the code needs
to know if there is a digit followed by a register displacement prefix
operand (e.g., '(' on x86_64). If yes, then it is a register
operation. If not, then it will be handled recursively, and the code
will later apply the requested operation on the result (either a '+', a
'-' or a '~').
With the bug, the code was correctly discarding the digit (though using
strtol unnecessarily), but it wasn't properly dealing with
subexpressions when the register indirection prefix was '(', like on
x86_64. This patch also fixes this bug, and includes a testcase. It
passes on x86_64 Fedora 20.
2014-09-06 03:21:44 +08:00
|
|
|
|
/* We skip the digit here because we are only interested in
|
|
|
|
|
knowing what kind of unary operation this is. The digit
|
|
|
|
|
will be handled by one of the functions that will be
|
|
|
|
|
called below ('stap_parse_argument_conditionally' or
|
|
|
|
|
'stap_parse_register_operand'). */
|
|
|
|
|
++tmp;
|
2019-05-17 03:58:55 +08:00
|
|
|
|
has_digit = true;
|
2013-03-14 00:45:11 +08:00
|
|
|
|
}
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Fix for PR gdb/17235: possible bug extracting systemtap probe operand
This patch is a fix to PR gdb/17235. The bug is about an unused
variable that got declared and set during one of the parsing phases of
an SDT probe's argument. I took the opportunity to rewrite some of the
code to improve the parsing. The bug was actually a thinko, because
what I wanted to do in the code was to discard the number on the string
being parsed.
During this portion, the code identifies that it is dealing with an
expression that begins with a sign ('+', '-' or '~'). This means that
the expression could be:
- a numeric literal (e.g., '+5')
- a register displacement (e.g., '-4(%rsp)')
- a subexpression (e.g., '-(2*3)')
So, after saving the sign and moving forward 1 char, now the code needs
to know if there is a digit followed by a register displacement prefix
operand (e.g., '(' on x86_64). If yes, then it is a register
operation. If not, then it will be handled recursively, and the code
will later apply the requested operation on the result (either a '+', a
'-' or a '~').
With the bug, the code was correctly discarding the digit (though using
strtol unnecessarily), but it wasn't properly dealing with
subexpressions when the register indirection prefix was '(', like on
x86_64. This patch also fixes this bug, and includes a testcase. It
passes on x86_64 Fedora 20.
2014-09-06 03:21:44 +08:00
|
|
|
|
if (has_digit && stap_is_register_indirection_prefix (gdbarch, tmp,
|
|
|
|
|
NULL))
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
/* If we are here, it means it is a displacement. The only
|
|
|
|
|
operations allowed here are `-' and `+'. */
|
2019-05-17 04:17:30 +08:00
|
|
|
|
if (c != '-' && c != '+')
|
2012-04-28 04:47:57 +08:00
|
|
|
|
error (_("Invalid operator `%c' for register displacement "
|
|
|
|
|
"on expression `%s'."), c, p->saved_arg);
|
|
|
|
|
|
|
|
|
|
stap_parse_register_operand (p);
|
|
|
|
|
}
|
Fix for PR gdb/17235: possible bug extracting systemtap probe operand
This patch is a fix to PR gdb/17235. The bug is about an unused
variable that got declared and set during one of the parsing phases of
an SDT probe's argument. I took the opportunity to rewrite some of the
code to improve the parsing. The bug was actually a thinko, because
what I wanted to do in the code was to discard the number on the string
being parsed.
During this portion, the code identifies that it is dealing with an
expression that begins with a sign ('+', '-' or '~'). This means that
the expression could be:
- a numeric literal (e.g., '+5')
- a register displacement (e.g., '-4(%rsp)')
- a subexpression (e.g., '-(2*3)')
So, after saving the sign and moving forward 1 char, now the code needs
to know if there is a digit followed by a register displacement prefix
operand (e.g., '(' on x86_64). If yes, then it is a register
operation. If not, then it will be handled recursively, and the code
will later apply the requested operation on the result (either a '+', a
'-' or a '~').
With the bug, the code was correctly discarding the digit (though using
strtol unnecessarily), but it wasn't properly dealing with
subexpressions when the register indirection prefix was '(', like on
x86_64. This patch also fixes this bug, and includes a testcase. It
passes on x86_64 Fedora 20.
2014-09-06 03:21:44 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* This is not a displacement. We skip the operator, and
|
|
|
|
|
deal with it when the recursion returns. */
|
|
|
|
|
++p->arg;
|
|
|
|
|
stap_parse_argument_conditionally (p);
|
|
|
|
|
if (c == '-')
|
|
|
|
|
write_exp_elt_opcode (&p->pstate, UNOP_NEG);
|
|
|
|
|
else if (c == '~')
|
|
|
|
|
write_exp_elt_opcode (&p->pstate, UNOP_COMPLEMENT);
|
|
|
|
|
}
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
else if (isdigit (*p->arg))
|
|
|
|
|
{
|
|
|
|
|
/* A temporary variable, needed for lookahead. */
|
|
|
|
|
const char *tmp = p->arg;
|
2013-03-14 00:45:11 +08:00
|
|
|
|
char *endp;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
long number;
|
|
|
|
|
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
/* We can be dealing with a numeric constant, or with a register
|
|
|
|
|
displacement. */
|
2013-03-14 00:45:11 +08:00
|
|
|
|
number = strtol (tmp, &endp, 10);
|
|
|
|
|
tmp = endp;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
if (p->inside_paren_p)
|
Rename _const functions to use overloading instead
This renames a few functions -- skip_spaces_const,
skip_to_space_const, get_number_const, extract_arg_const -- to drop
the "_const" suffix and instead rely on overloading.
This makes future const fixes simpler by reducing the number of lines
that must be changed. I think it is also not any less clear, as all
these functions have the same interface as their non-const versions by
design. Furthermore there's an example of using an overload in-tree
already, namely check_for_argument.
This patch was largely created using some perl one-liners; then a few
fixes were applied by hand.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* common/common-utils.h (skip_to_space): Remove macro, redeclare
as function.
(skip_to_space): Rename from skip_to_space_const.
* common/common-utils.c (skip_to_space): New function.
(skip_to_space): Rename from skip_to_space_const.
* cli/cli-utils.h (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
* cli/cli-utils.c (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
(number_or_range_parser::get_number): Use ::get_number.
* aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c,
break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c,
cli/cli-script.c, cli/cli-setshow.c, compile/compile.c,
completer.c, demangle.c, disasm.c, findcmd.c, linespec.c,
linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c,
minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c,
python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c,
stap-probe.c, tid-parse.c, tracepoint.c: Update all callers.
2017-09-11 04:19:19 +08:00
|
|
|
|
tmp = skip_spaces (tmp);
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
|
|
|
|
|
/* If "stap_is_integer_prefix" returns true, it means we can
|
|
|
|
|
accept integers without a prefix here. But we also need to
|
|
|
|
|
check whether the next token (i.e., "tmp") is not a register
|
|
|
|
|
indirection prefix. */
|
|
|
|
|
if (stap_is_integer_prefix (gdbarch, p->arg, NULL)
|
|
|
|
|
&& !stap_is_register_indirection_prefix (gdbarch, tmp, NULL))
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
const char *int_suffix;
|
|
|
|
|
|
2012-04-28 04:47:57 +08:00
|
|
|
|
/* We are dealing with a numeric constant. */
|
Remove `expout*' globals from parser-defs.h
This commit removes the "expout*" globals from our parser code, turning
them into a structure that is passed when an expression needs to be
evaluated. This is the initial step to make our parser less
"globalized".
This is mostly a mechanical patch, which creates a structure containing
the "expout*" globals and then modify all the functions that handle them
in order to take the structure as argument. It is big, and has been
reviewed at least 4 times, so I think everything is covered.
Below you can see the message links from the discussions:
- First attempt:
<https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html>
Message-ID: <m3k44s7qej.fsf@gmail.com>
- Second attempt:
<https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html>
Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>
- Third attempt:
<https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html>
Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com>
- Fourth (last) attempt:
<https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html>
Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com>
gdb/
2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com>
Remove some globals from our parser.
* language.c (unk_lang_parser): Add "struct parser_state"
argument.
* language.h (struct language_defn) <la_parser>: Likewise.
* parse.c (expout, expout_size, expout_ptr): Remove variables.
(initialize_expout): Add "struct parser_state" argument.
Rewrite function to use the parser state.
(reallocate_expout, write_exp_elt, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
write_dollar_variable): Likewise.
(parse_exp_in_context_1): Use parser state.
(insert_type_address_space): Add "struct parser_state" argument.
Use parser state.
(increase_expout_size): New function.
* parser-defs.h: Forward declare "struct language_defn" and
"struct parser_state".
(expout, expout_size, expout_ptr): Remove extern declarations.
(parse_gdbarch, parse_language): Rewrite macro declarations to
accept the parser state.
(struct parser_state): New struct.
(initialize_expout, reallocate_expout, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
write_exp_msymbol, write_dollar_variable,
mark_struct_expression, insert_type_address_space): Add "struct
parser_state" argument.
(increase_expout_size): New function.
* utils.c (do_clear_parser_state): New function.
(make_cleanup_clear_parser_state): Likewise.
* utils.h (make_cleanup_clear_parser_state): New function
prototype.
* aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
Update calls to write_exp* in order to pass the parser state.
* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
* i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
(i386_stap_parse_special_token_three_arg_disp): Likewise.
* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
* stap-probe.c (stap_parse_register_operand): Likewise.
(stap_parse_single_operand): Likewise.
(stap_parse_argument_1): Likewise.
(stap_parse_argument): Use parser state.
* stap-probe.h: Include "parser-defs.h".
(struct stap_parse_info) <pstate>: New field.
* c-exp.y (parse_type): Rewrite to use parser state.
(yyparse): Redefine to c_parse_internal.
(pstate): New global variable.
(parse_number): Add "struct parser_state" argument.
(write_destructor_name): Likewise.
(type_exp): Update calls to write_exp* and similars in order to
use parser state.
(exp1, exp, variable, qualified_name, space_identifier,
typename, typebase): Likewise.
(write_destructor_name, parse_number, lex_one_token,
classify_name, classify_inner_name, c_parse): Add "struct
parser_state" argument. Update function to use parser state.
* c-lang.h: Forward declare "struct parser_state".
(c_parse): Add "struct parser_state" argument.
* ada-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to ada_parse_internal.
(pstate): New variable.
(write_int, write_object_renaming, write_var_or_type,
write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
type_int, type_long, type_long_long, type_float, type_double,
type_long_double, type_char, type_boolean, type_system_address):
Add "struct parser_state" argument.
(exp1, primary, simple_exp, relation, and_exp, and_then_exp,
or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
var_or_type, aggregate, aggregate_component_list,
positional_list, others, component_group,
component_associations): Update calls to write_exp* and similar
functions in order to use parser state.
(ada_parse, write_var_from_sym, write_int,
write_exp_op_with_string, write_object_renaming,
find_primitive_type, write_selectors, write_ambiguous_var,
write_var_or_type, write_name_assoc, type_int, type_long,
type_long_long, type_float, type_double, type_long_double,
type_char, type_boolean, type_system_address): Add "struct
parser_state" argument. Adjust function to use parser state.
* ada-lang.c (parse): Likewise.
* ada-lang.h: Forward declare "struct parser_state".
(ada_parse): Add "struct parser_state" argument.
* ada-lex.l (processInt, processReal): Likewise. Adjust all
calls to both functions.
* f-exp.y (parse_type, parse_f_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to f_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp, subrange, typebase): Update calls to write_exp*
and similars in order to use parser state.
(parse_number): Adjust code to use parser state.
(yylex): Likewise.
(f_parse): New function.
* f-lang.h: Forward declare "struct parser_state".
(f_parse): Add "struct parser_state" argument.
* jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro for java_parse_internal.
(pstate): New variable.
(push_expression_name, push_expression_name, insert_exp): Add
"struct parser_state" argument.
(type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
PostIncrementExpression, PostDecrementExpression,
UnaryExpression, PreIncrementExpression, PreDecrementExpression,
UnaryExpressionNotPlusMinus, CastExpression,
MultiplicativeExpression, AdditiveExpression, ShiftExpression,
RelationalExpression, EqualityExpression, AndExpression,
ExclusiveOrExpression, InclusiveOrExpression,
ConditionalAndExpression, ConditionalOrExpression,
ConditionalExpression, Assignment, LeftHandSide): Update
calls to write_exp* and similars in order to use parser state.
(parse_number): Ajust code to use parser state.
(yylex): Likewise.
(java_parse): New function.
(push_variable): Add "struct parser_state" argument. Adjust
code to user parser state.
(push_fieldnames, push_qualified_expression_name,
push_expression_name, insert_exp): Likewise.
* jv-lang.h: Forward declare "struct parser_state".
(java_parse): Add "struct parser_state" argument.
* m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to m2_parse_internal.
(pstate): New variable.
(type_exp, exp, fblock, variable, type): Update calls to
write_exp* and similars to use parser state.
(yylex): Likewise.
(m2_parse): New function.
* m2-lang.h: Forward declare "struct parser_state".
(m2_parse): Add "struct parser_state" argument.
* objc-lang.c (end_msglist): Add "struct parser_state" argument.
* objc-lang.h: Forward declare "struct parser_state".
(end_msglist): Add "struct parser_state" argument.
* p-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to pascal_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, qualified_name, variable): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, yylex): Adjust code to use parser state.
(pascal_parse): New function.
* p-lang.h: Forward declare "struct parser_state".
(pascal_parse): Add "struct parser_state" argument.
* go-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to go_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, variable, type): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, lex_one_token, classify_name, yylex): Adjust code
to use parser state.
(go_parse): Likewise.
* go-lang.h: Forward declare "struct parser_state".
(go_parse): Add "struct parser_state" argument.
2014-03-28 06:10:40 +08:00
|
|
|
|
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
|
|
|
|
write_exp_elt_type (&p->pstate,
|
|
|
|
|
builtin_type (gdbarch)->builtin_long);
|
|
|
|
|
write_exp_elt_longcst (&p->pstate, number);
|
|
|
|
|
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
p->arg = tmp;
|
|
|
|
|
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
if (stap_check_integer_suffix (gdbarch, p->arg, &int_suffix))
|
|
|
|
|
p->arg += strlen (int_suffix);
|
|
|
|
|
else
|
|
|
|
|
error (_("Invalid constant suffix on expression `%s'."),
|
|
|
|
|
p->saved_arg);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
else if (stap_is_register_indirection_prefix (gdbarch, tmp, NULL))
|
2012-04-28 04:47:57 +08:00
|
|
|
|
stap_parse_register_operand (p);
|
|
|
|
|
else
|
|
|
|
|
error (_("Unknown numeric token on expression `%s'."),
|
|
|
|
|
p->saved_arg);
|
|
|
|
|
}
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
else if (stap_is_integer_prefix (gdbarch, p->arg, &int_prefix))
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
/* We are dealing with a numeric constant. */
|
|
|
|
|
long number;
|
2013-03-14 00:45:11 +08:00
|
|
|
|
char *endp;
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
const char *int_suffix;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
p->arg += strlen (int_prefix);
|
2013-03-14 00:45:11 +08:00
|
|
|
|
number = strtol (p->arg, &endp, 10);
|
|
|
|
|
p->arg = endp;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Remove `expout*' globals from parser-defs.h
This commit removes the "expout*" globals from our parser code, turning
them into a structure that is passed when an expression needs to be
evaluated. This is the initial step to make our parser less
"globalized".
This is mostly a mechanical patch, which creates a structure containing
the "expout*" globals and then modify all the functions that handle them
in order to take the structure as argument. It is big, and has been
reviewed at least 4 times, so I think everything is covered.
Below you can see the message links from the discussions:
- First attempt:
<https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html>
Message-ID: <m3k44s7qej.fsf@gmail.com>
- Second attempt:
<https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html>
Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>
- Third attempt:
<https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html>
Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com>
- Fourth (last) attempt:
<https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html>
Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com>
gdb/
2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com>
Remove some globals from our parser.
* language.c (unk_lang_parser): Add "struct parser_state"
argument.
* language.h (struct language_defn) <la_parser>: Likewise.
* parse.c (expout, expout_size, expout_ptr): Remove variables.
(initialize_expout): Add "struct parser_state" argument.
Rewrite function to use the parser state.
(reallocate_expout, write_exp_elt, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
write_dollar_variable): Likewise.
(parse_exp_in_context_1): Use parser state.
(insert_type_address_space): Add "struct parser_state" argument.
Use parser state.
(increase_expout_size): New function.
* parser-defs.h: Forward declare "struct language_defn" and
"struct parser_state".
(expout, expout_size, expout_ptr): Remove extern declarations.
(parse_gdbarch, parse_language): Rewrite macro declarations to
accept the parser state.
(struct parser_state): New struct.
(initialize_expout, reallocate_expout, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
write_exp_msymbol, write_dollar_variable,
mark_struct_expression, insert_type_address_space): Add "struct
parser_state" argument.
(increase_expout_size): New function.
* utils.c (do_clear_parser_state): New function.
(make_cleanup_clear_parser_state): Likewise.
* utils.h (make_cleanup_clear_parser_state): New function
prototype.
* aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
Update calls to write_exp* in order to pass the parser state.
* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
* i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
(i386_stap_parse_special_token_three_arg_disp): Likewise.
* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
* stap-probe.c (stap_parse_register_operand): Likewise.
(stap_parse_single_operand): Likewise.
(stap_parse_argument_1): Likewise.
(stap_parse_argument): Use parser state.
* stap-probe.h: Include "parser-defs.h".
(struct stap_parse_info) <pstate>: New field.
* c-exp.y (parse_type): Rewrite to use parser state.
(yyparse): Redefine to c_parse_internal.
(pstate): New global variable.
(parse_number): Add "struct parser_state" argument.
(write_destructor_name): Likewise.
(type_exp): Update calls to write_exp* and similars in order to
use parser state.
(exp1, exp, variable, qualified_name, space_identifier,
typename, typebase): Likewise.
(write_destructor_name, parse_number, lex_one_token,
classify_name, classify_inner_name, c_parse): Add "struct
parser_state" argument. Update function to use parser state.
* c-lang.h: Forward declare "struct parser_state".
(c_parse): Add "struct parser_state" argument.
* ada-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to ada_parse_internal.
(pstate): New variable.
(write_int, write_object_renaming, write_var_or_type,
write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
type_int, type_long, type_long_long, type_float, type_double,
type_long_double, type_char, type_boolean, type_system_address):
Add "struct parser_state" argument.
(exp1, primary, simple_exp, relation, and_exp, and_then_exp,
or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
var_or_type, aggregate, aggregate_component_list,
positional_list, others, component_group,
component_associations): Update calls to write_exp* and similar
functions in order to use parser state.
(ada_parse, write_var_from_sym, write_int,
write_exp_op_with_string, write_object_renaming,
find_primitive_type, write_selectors, write_ambiguous_var,
write_var_or_type, write_name_assoc, type_int, type_long,
type_long_long, type_float, type_double, type_long_double,
type_char, type_boolean, type_system_address): Add "struct
parser_state" argument. Adjust function to use parser state.
* ada-lang.c (parse): Likewise.
* ada-lang.h: Forward declare "struct parser_state".
(ada_parse): Add "struct parser_state" argument.
* ada-lex.l (processInt, processReal): Likewise. Adjust all
calls to both functions.
* f-exp.y (parse_type, parse_f_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to f_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp, subrange, typebase): Update calls to write_exp*
and similars in order to use parser state.
(parse_number): Adjust code to use parser state.
(yylex): Likewise.
(f_parse): New function.
* f-lang.h: Forward declare "struct parser_state".
(f_parse): Add "struct parser_state" argument.
* jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro for java_parse_internal.
(pstate): New variable.
(push_expression_name, push_expression_name, insert_exp): Add
"struct parser_state" argument.
(type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
PostIncrementExpression, PostDecrementExpression,
UnaryExpression, PreIncrementExpression, PreDecrementExpression,
UnaryExpressionNotPlusMinus, CastExpression,
MultiplicativeExpression, AdditiveExpression, ShiftExpression,
RelationalExpression, EqualityExpression, AndExpression,
ExclusiveOrExpression, InclusiveOrExpression,
ConditionalAndExpression, ConditionalOrExpression,
ConditionalExpression, Assignment, LeftHandSide): Update
calls to write_exp* and similars in order to use parser state.
(parse_number): Ajust code to use parser state.
(yylex): Likewise.
(java_parse): New function.
(push_variable): Add "struct parser_state" argument. Adjust
code to user parser state.
(push_fieldnames, push_qualified_expression_name,
push_expression_name, insert_exp): Likewise.
* jv-lang.h: Forward declare "struct parser_state".
(java_parse): Add "struct parser_state" argument.
* m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to m2_parse_internal.
(pstate): New variable.
(type_exp, exp, fblock, variable, type): Update calls to
write_exp* and similars to use parser state.
(yylex): Likewise.
(m2_parse): New function.
* m2-lang.h: Forward declare "struct parser_state".
(m2_parse): Add "struct parser_state" argument.
* objc-lang.c (end_msglist): Add "struct parser_state" argument.
* objc-lang.h: Forward declare "struct parser_state".
(end_msglist): Add "struct parser_state" argument.
* p-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to pascal_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, qualified_name, variable): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, yylex): Adjust code to use parser state.
(pascal_parse): New function.
* p-lang.h: Forward declare "struct parser_state".
(pascal_parse): Add "struct parser_state" argument.
* go-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to go_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, variable, type): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, lex_one_token, classify_name, yylex): Adjust code
to use parser state.
(go_parse): Likewise.
* go-lang.h: Forward declare "struct parser_state".
(go_parse): Add "struct parser_state" argument.
2014-03-28 06:10:40 +08:00
|
|
|
|
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
|
|
|
|
write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long);
|
|
|
|
|
write_exp_elt_longcst (&p->pstate, number);
|
|
|
|
|
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
if (stap_check_integer_suffix (gdbarch, p->arg, &int_suffix))
|
|
|
|
|
p->arg += strlen (int_suffix);
|
|
|
|
|
else
|
|
|
|
|
error (_("Invalid constant suffix on expression `%s'."),
|
|
|
|
|
p->saved_arg);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe
arguments. It can be almost considered a cleanup, but the main point of
it is actually to allow the generic parser to accept multiple prefixes
and suffixes for the its operands (i.e., integers, register names, and
register indirection).
I have chosen to implement this as a list of const strings, and declare
this list as "static" inside each target's method used to initialize
gdbarch.
This patch is actually a preparation for an upcoming patch for ARM,
which implements the support for multiple integer prefixes (as defined
by ARM's asm spec). And AArch64 will also need this, for the same
reason.
This patch was regtested on all architectures that it touches (i.e.,
i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found.
2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com>
* amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (stap_integer_prefix, stap_integer_suffix)
(stap_register_prefix, stap_register_suffix)
(stap_register_indirection_prefix)
(stap_register_indirection_suffix): Declare as "const char *const
*" instead of "const char *". Adjust printing function. Rename
all of the variables to the plural.
(pstring_list): New function.
* i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe
argument prefixes and suffixes. Initialize gdbarch with them.
* ia64-linux-tdep.c (ia64_linux_init_abi): Likewise.
* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* stap-probe.c (stap_is_generic_prefix): New function.
(stap_is_register_prefix): Likewise.
(stap_is_register_indirection_prefix): Likewise.
(stap_is_integer_prefix): Likewise.
(stap_generic_check_suffix): Likewise.
(stap_check_integer_suffix): Likewise.
(stap_check_register_suffix): Likewise.
(stap_check_register_indirection_suffix): Likewise.
(stap_parse_register_operand): Remove unecessary declarations for
variables holding prefix and suffix information. Use the new
functions listed above for checking for prefixes and suffixes.
(stap_parse_single_operand): Likewise.
2013-12-20 04:53:40 +08:00
|
|
|
|
else if (stap_is_register_prefix (gdbarch, p->arg, NULL)
|
|
|
|
|
|| stap_is_register_indirection_prefix (gdbarch, p->arg, NULL))
|
2012-04-28 04:47:57 +08:00
|
|
|
|
stap_parse_register_operand (p);
|
|
|
|
|
else
|
|
|
|
|
error (_("Operator `%c' not recognized on expression `%s'."),
|
|
|
|
|
*p->arg, p->saved_arg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function parses an argument conditionally, based on single or
|
|
|
|
|
non-single operands. A non-single operand would be a parenthesized
|
|
|
|
|
expression (e.g., `(2 + 1)'), and a single operand is anything that
|
|
|
|
|
starts with `-', `~', `+' (i.e., unary operators), a digit, or
|
|
|
|
|
something recognized by `gdbarch_stap_is_single_operand'. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
stap_parse_argument_conditionally (struct stap_parse_info *p)
|
|
|
|
|
{
|
2013-12-24 06:48:08 +08:00
|
|
|
|
gdb_assert (gdbarch_stap_is_single_operand_p (p->gdbarch));
|
|
|
|
|
|
2012-04-28 04:47:57 +08:00
|
|
|
|
if (*p->arg == '-' || *p->arg == '~' || *p->arg == '+' /* Unary. */
|
|
|
|
|
|| isdigit (*p->arg)
|
|
|
|
|
|| gdbarch_stap_is_single_operand (p->gdbarch, p->arg))
|
|
|
|
|
stap_parse_single_operand (p);
|
|
|
|
|
else if (*p->arg == '(')
|
|
|
|
|
{
|
|
|
|
|
/* We are dealing with a parenthesized operand. It means we
|
|
|
|
|
have to parse it as it was a separate expression, without
|
|
|
|
|
left-side or precedence. */
|
|
|
|
|
++p->arg;
|
Rename _const functions to use overloading instead
This renames a few functions -- skip_spaces_const,
skip_to_space_const, get_number_const, extract_arg_const -- to drop
the "_const" suffix and instead rely on overloading.
This makes future const fixes simpler by reducing the number of lines
that must be changed. I think it is also not any less clear, as all
these functions have the same interface as their non-const versions by
design. Furthermore there's an example of using an overload in-tree
already, namely check_for_argument.
This patch was largely created using some perl one-liners; then a few
fixes were applied by hand.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* common/common-utils.h (skip_to_space): Remove macro, redeclare
as function.
(skip_to_space): Rename from skip_to_space_const.
* common/common-utils.c (skip_to_space): New function.
(skip_to_space): Rename from skip_to_space_const.
* cli/cli-utils.h (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
* cli/cli-utils.c (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
(number_or_range_parser::get_number): Use ::get_number.
* aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c,
break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c,
cli/cli-script.c, cli/cli-setshow.c, compile/compile.c,
completer.c, demangle.c, disasm.c, findcmd.c, linespec.c,
linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c,
minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c,
python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c,
stap-probe.c, tid-parse.c, tracepoint.c: Update all callers.
2017-09-11 04:19:19 +08:00
|
|
|
|
p->arg = skip_spaces (p->arg);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
++p->inside_paren_p;
|
|
|
|
|
|
|
|
|
|
stap_parse_argument_1 (p, 0, STAP_OPERAND_PREC_NONE);
|
|
|
|
|
|
|
|
|
|
--p->inside_paren_p;
|
|
|
|
|
if (*p->arg != ')')
|
|
|
|
|
error (_("Missign close-paren on expression `%s'."),
|
|
|
|
|
p->saved_arg);
|
|
|
|
|
|
|
|
|
|
++p->arg;
|
|
|
|
|
if (p->inside_paren_p)
|
Rename _const functions to use overloading instead
This renames a few functions -- skip_spaces_const,
skip_to_space_const, get_number_const, extract_arg_const -- to drop
the "_const" suffix and instead rely on overloading.
This makes future const fixes simpler by reducing the number of lines
that must be changed. I think it is also not any less clear, as all
these functions have the same interface as their non-const versions by
design. Furthermore there's an example of using an overload in-tree
already, namely check_for_argument.
This patch was largely created using some perl one-liners; then a few
fixes were applied by hand.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* common/common-utils.h (skip_to_space): Remove macro, redeclare
as function.
(skip_to_space): Rename from skip_to_space_const.
* common/common-utils.c (skip_to_space): New function.
(skip_to_space): Rename from skip_to_space_const.
* cli/cli-utils.h (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
* cli/cli-utils.c (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
(number_or_range_parser::get_number): Use ::get_number.
* aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c,
break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c,
cli/cli-script.c, cli/cli-setshow.c, compile/compile.c,
completer.c, demangle.c, disasm.c, findcmd.c, linespec.c,
linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c,
minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c,
python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c,
stap-probe.c, tid-parse.c, tracepoint.c: Update all callers.
2017-09-11 04:19:19 +08:00
|
|
|
|
p->arg = skip_spaces (p->arg);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
error (_("Cannot parse expression `%s'."), p->saved_arg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function for `stap_parse_argument'. Please, see its comments to
|
|
|
|
|
better understand what this function does. */
|
|
|
|
|
|
|
|
|
|
static void
|
2019-05-17 03:58:55 +08:00
|
|
|
|
stap_parse_argument_1 (struct stap_parse_info *p, bool has_lhs,
|
2012-04-28 04:47:57 +08:00
|
|
|
|
enum stap_operand_prec prec)
|
|
|
|
|
{
|
|
|
|
|
/* This is an operator-precedence parser.
|
|
|
|
|
|
|
|
|
|
We work with left- and right-sides of expressions, and
|
|
|
|
|
parse them depending on the precedence of the operators
|
|
|
|
|
we find. */
|
|
|
|
|
|
2013-12-24 06:48:08 +08:00
|
|
|
|
gdb_assert (p->arg != NULL);
|
|
|
|
|
|
2012-04-28 04:47:57 +08:00
|
|
|
|
if (p->inside_paren_p)
|
Rename _const functions to use overloading instead
This renames a few functions -- skip_spaces_const,
skip_to_space_const, get_number_const, extract_arg_const -- to drop
the "_const" suffix and instead rely on overloading.
This makes future const fixes simpler by reducing the number of lines
that must be changed. I think it is also not any less clear, as all
these functions have the same interface as their non-const versions by
design. Furthermore there's an example of using an overload in-tree
already, namely check_for_argument.
This patch was largely created using some perl one-liners; then a few
fixes were applied by hand.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* common/common-utils.h (skip_to_space): Remove macro, redeclare
as function.
(skip_to_space): Rename from skip_to_space_const.
* common/common-utils.c (skip_to_space): New function.
(skip_to_space): Rename from skip_to_space_const.
* cli/cli-utils.h (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
* cli/cli-utils.c (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
(number_or_range_parser::get_number): Use ::get_number.
* aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c,
break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c,
cli/cli-script.c, cli/cli-setshow.c, compile/compile.c,
completer.c, demangle.c, disasm.c, findcmd.c, linespec.c,
linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c,
minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c,
python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c,
stap-probe.c, tid-parse.c, tracepoint.c: Update all callers.
2017-09-11 04:19:19 +08:00
|
|
|
|
p->arg = skip_spaces (p->arg);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
if (!has_lhs)
|
|
|
|
|
{
|
|
|
|
|
/* We were called without a left-side, either because this is the
|
|
|
|
|
first call, or because we were called to parse a parenthesized
|
|
|
|
|
expression. It doesn't really matter; we have to parse the
|
|
|
|
|
left-side in order to continue the process. */
|
|
|
|
|
stap_parse_argument_conditionally (p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Start to parse the right-side, and to "join" left and right sides
|
|
|
|
|
depending on the operation specified.
|
|
|
|
|
|
|
|
|
|
This loop shall continue until we run out of characters in the input,
|
|
|
|
|
or until we find a close-parenthesis, which means that we've reached
|
|
|
|
|
the end of a sub-expression. */
|
2013-12-24 06:48:08 +08:00
|
|
|
|
while (*p->arg != '\0' && *p->arg != ')' && !isspace (*p->arg))
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
const char *tmp_exp_buf;
|
|
|
|
|
enum exp_opcode opcode;
|
|
|
|
|
enum stap_operand_prec cur_prec;
|
|
|
|
|
|
2012-05-04 04:04:06 +08:00
|
|
|
|
if (!stap_is_operator (p->arg))
|
2012-04-28 04:47:57 +08:00
|
|
|
|
error (_("Invalid operator `%c' on expression `%s'."), *p->arg,
|
|
|
|
|
p->saved_arg);
|
|
|
|
|
|
|
|
|
|
/* We have to save the current value of the expression buffer because
|
|
|
|
|
the `stap_get_opcode' modifies it in order to get the current
|
|
|
|
|
operator. If this operator's precedence is lower than PREC, we
|
|
|
|
|
should return and not advance the expression buffer pointer. */
|
|
|
|
|
tmp_exp_buf = p->arg;
|
2012-05-04 04:04:06 +08:00
|
|
|
|
opcode = stap_get_opcode (&tmp_exp_buf);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
cur_prec = stap_get_operator_prec (opcode);
|
|
|
|
|
if (cur_prec < prec)
|
|
|
|
|
{
|
|
|
|
|
/* If the precedence of the operator that we are seeing now is
|
|
|
|
|
lower than the precedence of the first operator seen before
|
|
|
|
|
this parsing process began, it means we should stop parsing
|
|
|
|
|
and return. */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p->arg = tmp_exp_buf;
|
|
|
|
|
if (p->inside_paren_p)
|
Rename _const functions to use overloading instead
This renames a few functions -- skip_spaces_const,
skip_to_space_const, get_number_const, extract_arg_const -- to drop
the "_const" suffix and instead rely on overloading.
This makes future const fixes simpler by reducing the number of lines
that must be changed. I think it is also not any less clear, as all
these functions have the same interface as their non-const versions by
design. Furthermore there's an example of using an overload in-tree
already, namely check_for_argument.
This patch was largely created using some perl one-liners; then a few
fixes were applied by hand.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* common/common-utils.h (skip_to_space): Remove macro, redeclare
as function.
(skip_to_space): Rename from skip_to_space_const.
* common/common-utils.c (skip_to_space): New function.
(skip_to_space): Rename from skip_to_space_const.
* cli/cli-utils.h (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
* cli/cli-utils.c (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
(number_or_range_parser::get_number): Use ::get_number.
* aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c,
break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c,
cli/cli-script.c, cli/cli-setshow.c, compile/compile.c,
completer.c, demangle.c, disasm.c, findcmd.c, linespec.c,
linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c,
minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c,
python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c,
stap-probe.c, tid-parse.c, tracepoint.c: Update all callers.
2017-09-11 04:19:19 +08:00
|
|
|
|
p->arg = skip_spaces (p->arg);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* Parse the right-side of the expression. */
|
|
|
|
|
stap_parse_argument_conditionally (p);
|
|
|
|
|
|
|
|
|
|
/* While we still have operators, try to parse another
|
|
|
|
|
right-side, but using the current right-side as a left-side. */
|
2013-12-24 06:48:08 +08:00
|
|
|
|
while (*p->arg != '\0' && stap_is_operator (p->arg))
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
enum exp_opcode lookahead_opcode;
|
|
|
|
|
enum stap_operand_prec lookahead_prec;
|
|
|
|
|
|
|
|
|
|
/* Saving the current expression buffer position. The explanation
|
|
|
|
|
is the same as above. */
|
|
|
|
|
tmp_exp_buf = p->arg;
|
2012-05-04 04:04:06 +08:00
|
|
|
|
lookahead_opcode = stap_get_opcode (&tmp_exp_buf);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
lookahead_prec = stap_get_operator_prec (lookahead_opcode);
|
|
|
|
|
|
|
|
|
|
if (lookahead_prec <= prec)
|
|
|
|
|
{
|
|
|
|
|
/* If we are dealing with an operator whose precedence is lower
|
|
|
|
|
than the first one, just abandon the attempt. */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Parse the right-side of the expression, but since we already
|
|
|
|
|
have a left-side at this point, set `has_lhs' to 1. */
|
|
|
|
|
stap_parse_argument_1 (p, 1, lookahead_prec);
|
|
|
|
|
}
|
|
|
|
|
|
Remove `expout*' globals from parser-defs.h
This commit removes the "expout*" globals from our parser code, turning
them into a structure that is passed when an expression needs to be
evaluated. This is the initial step to make our parser less
"globalized".
This is mostly a mechanical patch, which creates a structure containing
the "expout*" globals and then modify all the functions that handle them
in order to take the structure as argument. It is big, and has been
reviewed at least 4 times, so I think everything is covered.
Below you can see the message links from the discussions:
- First attempt:
<https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html>
Message-ID: <m3k44s7qej.fsf@gmail.com>
- Second attempt:
<https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html>
Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>
- Third attempt:
<https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html>
Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com>
- Fourth (last) attempt:
<https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html>
Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com>
gdb/
2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com>
Remove some globals from our parser.
* language.c (unk_lang_parser): Add "struct parser_state"
argument.
* language.h (struct language_defn) <la_parser>: Likewise.
* parse.c (expout, expout_size, expout_ptr): Remove variables.
(initialize_expout): Add "struct parser_state" argument.
Rewrite function to use the parser state.
(reallocate_expout, write_exp_elt, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
write_dollar_variable): Likewise.
(parse_exp_in_context_1): Use parser state.
(insert_type_address_space): Add "struct parser_state" argument.
Use parser state.
(increase_expout_size): New function.
* parser-defs.h: Forward declare "struct language_defn" and
"struct parser_state".
(expout, expout_size, expout_ptr): Remove extern declarations.
(parse_gdbarch, parse_language): Rewrite macro declarations to
accept the parser state.
(struct parser_state): New struct.
(initialize_expout, reallocate_expout, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
write_exp_msymbol, write_dollar_variable,
mark_struct_expression, insert_type_address_space): Add "struct
parser_state" argument.
(increase_expout_size): New function.
* utils.c (do_clear_parser_state): New function.
(make_cleanup_clear_parser_state): Likewise.
* utils.h (make_cleanup_clear_parser_state): New function
prototype.
* aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
Update calls to write_exp* in order to pass the parser state.
* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
* i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
(i386_stap_parse_special_token_three_arg_disp): Likewise.
* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
* stap-probe.c (stap_parse_register_operand): Likewise.
(stap_parse_single_operand): Likewise.
(stap_parse_argument_1): Likewise.
(stap_parse_argument): Use parser state.
* stap-probe.h: Include "parser-defs.h".
(struct stap_parse_info) <pstate>: New field.
* c-exp.y (parse_type): Rewrite to use parser state.
(yyparse): Redefine to c_parse_internal.
(pstate): New global variable.
(parse_number): Add "struct parser_state" argument.
(write_destructor_name): Likewise.
(type_exp): Update calls to write_exp* and similars in order to
use parser state.
(exp1, exp, variable, qualified_name, space_identifier,
typename, typebase): Likewise.
(write_destructor_name, parse_number, lex_one_token,
classify_name, classify_inner_name, c_parse): Add "struct
parser_state" argument. Update function to use parser state.
* c-lang.h: Forward declare "struct parser_state".
(c_parse): Add "struct parser_state" argument.
* ada-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to ada_parse_internal.
(pstate): New variable.
(write_int, write_object_renaming, write_var_or_type,
write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
type_int, type_long, type_long_long, type_float, type_double,
type_long_double, type_char, type_boolean, type_system_address):
Add "struct parser_state" argument.
(exp1, primary, simple_exp, relation, and_exp, and_then_exp,
or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
var_or_type, aggregate, aggregate_component_list,
positional_list, others, component_group,
component_associations): Update calls to write_exp* and similar
functions in order to use parser state.
(ada_parse, write_var_from_sym, write_int,
write_exp_op_with_string, write_object_renaming,
find_primitive_type, write_selectors, write_ambiguous_var,
write_var_or_type, write_name_assoc, type_int, type_long,
type_long_long, type_float, type_double, type_long_double,
type_char, type_boolean, type_system_address): Add "struct
parser_state" argument. Adjust function to use parser state.
* ada-lang.c (parse): Likewise.
* ada-lang.h: Forward declare "struct parser_state".
(ada_parse): Add "struct parser_state" argument.
* ada-lex.l (processInt, processReal): Likewise. Adjust all
calls to both functions.
* f-exp.y (parse_type, parse_f_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to f_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp, subrange, typebase): Update calls to write_exp*
and similars in order to use parser state.
(parse_number): Adjust code to use parser state.
(yylex): Likewise.
(f_parse): New function.
* f-lang.h: Forward declare "struct parser_state".
(f_parse): Add "struct parser_state" argument.
* jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro for java_parse_internal.
(pstate): New variable.
(push_expression_name, push_expression_name, insert_exp): Add
"struct parser_state" argument.
(type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
PostIncrementExpression, PostDecrementExpression,
UnaryExpression, PreIncrementExpression, PreDecrementExpression,
UnaryExpressionNotPlusMinus, CastExpression,
MultiplicativeExpression, AdditiveExpression, ShiftExpression,
RelationalExpression, EqualityExpression, AndExpression,
ExclusiveOrExpression, InclusiveOrExpression,
ConditionalAndExpression, ConditionalOrExpression,
ConditionalExpression, Assignment, LeftHandSide): Update
calls to write_exp* and similars in order to use parser state.
(parse_number): Ajust code to use parser state.
(yylex): Likewise.
(java_parse): New function.
(push_variable): Add "struct parser_state" argument. Adjust
code to user parser state.
(push_fieldnames, push_qualified_expression_name,
push_expression_name, insert_exp): Likewise.
* jv-lang.h: Forward declare "struct parser_state".
(java_parse): Add "struct parser_state" argument.
* m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to m2_parse_internal.
(pstate): New variable.
(type_exp, exp, fblock, variable, type): Update calls to
write_exp* and similars to use parser state.
(yylex): Likewise.
(m2_parse): New function.
* m2-lang.h: Forward declare "struct parser_state".
(m2_parse): Add "struct parser_state" argument.
* objc-lang.c (end_msglist): Add "struct parser_state" argument.
* objc-lang.h: Forward declare "struct parser_state".
(end_msglist): Add "struct parser_state" argument.
* p-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to pascal_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, qualified_name, variable): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, yylex): Adjust code to use parser state.
(pascal_parse): New function.
* p-lang.h: Forward declare "struct parser_state".
(pascal_parse): Add "struct parser_state" argument.
* go-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to go_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, variable, type): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, lex_one_token, classify_name, yylex): Adjust code
to use parser state.
(go_parse): Likewise.
* go-lang.h: Forward declare "struct parser_state".
(go_parse): Add "struct parser_state" argument.
2014-03-28 06:10:40 +08:00
|
|
|
|
write_exp_elt_opcode (&p->pstate, opcode);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Parse a probe's argument.
|
|
|
|
|
|
|
|
|
|
Assuming that:
|
|
|
|
|
|
|
|
|
|
LP = literal integer prefix
|
|
|
|
|
LS = literal integer suffix
|
|
|
|
|
|
|
|
|
|
RP = register prefix
|
|
|
|
|
RS = register suffix
|
|
|
|
|
|
|
|
|
|
RIP = register indirection prefix
|
|
|
|
|
RIS = register indirection suffix
|
|
|
|
|
|
|
|
|
|
This routine assumes that arguments' tokens are of the form:
|
|
|
|
|
|
|
|
|
|
- [LP] NUMBER [LS]
|
|
|
|
|
- [RP] REGISTER [RS]
|
|
|
|
|
- [RIP] [RP] REGISTER [RS] [RIS]
|
|
|
|
|
- If we find a number without LP, we try to parse it as a literal integer
|
|
|
|
|
constant (if LP == NULL), or as a register displacement.
|
|
|
|
|
- We count parenthesis, and only skip whitespaces if we are inside them.
|
|
|
|
|
- If we find an operator, we skip it.
|
|
|
|
|
|
|
|
|
|
This function can also call a special function that will try to match
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
unknown tokens. It will return the expression_up generated from
|
|
|
|
|
parsing the argument. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
static expression_up
|
2012-04-28 04:47:57 +08:00
|
|
|
|
stap_parse_argument (const char **arg, struct type *atype,
|
|
|
|
|
struct gdbarch *gdbarch)
|
|
|
|
|
{
|
|
|
|
|
/* We need to initialize the expression buffer, in order to begin
|
Explicitly use language_c when evaluating a SDT probe argument
Joel contacted me offlist with a question about a warning that one of
his customers was seeing. The message came from the new
linker-debugger interface, which uses SDT probes internally. The
warning said:
(gdb) run
[...]
warning: Probes-based dynamic linker interface failed.
Reverting to original interface.
Argument to arithmetic operation not a number or boolean.
This should not have happened in the environment the customer was
using (RHEL-6.x), so I found it strange. Another thing caught my
attention: the last message, saying "Argument to arithmetic operation
not a number or boolean.".
Joel kindly investigated the issue further, and found the answer for
this. To quote him:
(gdb) set lang c
(gdb) p 48+$ebp
$4 = (void *) 0xffffd0f8
So far so good. But...
(gdb) set lang ada
(gdb) p 48+$ebp
Argument to arithmetic operation not a number or boolean.
Ooops! Interestingly, if you revert the order of the operands...
(gdb) p $ebp+48
$5 = (access void) 0xffffd0f8
So the problem is doing pointer arithmetics when the language is set
to Ada.
I remembered that, during the parsing and the evaluation of SDT probe
arguments, the code sets the language as current_language, because, at
that time, I thought it was not necessary to worry about the language
given that the code implements its own parser. I was wrong. So here
is a patch to fix that, by setting the language as C, which should
guarantee that the maths are done in the right way (TM).
It was somewhat hard to find a reproducer for this issue. In the end,
what I had to do was to create a testcase that used the %ebp register
on some displacement (e.g., "-4(%ebp)"), which finally triggered the
bug. I am not sure why I could not trigger it when using other
registers, but I did not want to spend too much time investigating
this issue, which seemed like an Ada issue. Also, because of this
peculiar way to trigger the problem, the testcase only covers x86-like
targets (i.e., i*86 and x86_64 with -m32).
Joel kindly tested this for me, and it worked. I also ran a full
regression test here on my Fedora 20 x86_64, and everything is fine.
I will push this patch in a few days if there are no comments.
gdb/ChangeLog:
2014-10-14 Sergio Durigan Junior <sergiodj@redhat.com>
* stap-probe.c (stap_parse_argument): Initialize expout explicitly
using language_c, instead of current_language.
gdb/testsuite/ChangeLog:
2014-10-14 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.arch/stap-eval-lang-ada.S: Likewise.
* gdb.arch/stap-eval-lang-ada.c: Likewise.
* gdb.arch/stap-eval-lang-ada.exp: New file.
2014-10-15 02:31:09 +08:00
|
|
|
|
our parsing efforts. We use language_c here because we may need
|
|
|
|
|
to do pointer arithmetics. */
|
2019-03-24 22:40:32 +08:00
|
|
|
|
struct stap_parse_info p (*arg, atype, language_def (language_c),
|
2017-11-23 12:45:53 +08:00
|
|
|
|
gdbarch);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
stap_parse_argument_1 (&p, 0, STAP_OPERAND_PREC_NONE);
|
|
|
|
|
|
|
|
|
|
gdb_assert (p.inside_paren_p == 0);
|
|
|
|
|
|
|
|
|
|
/* Casting the final expression to the appropriate type. */
|
Remove `expout*' globals from parser-defs.h
This commit removes the "expout*" globals from our parser code, turning
them into a structure that is passed when an expression needs to be
evaluated. This is the initial step to make our parser less
"globalized".
This is mostly a mechanical patch, which creates a structure containing
the "expout*" globals and then modify all the functions that handle them
in order to take the structure as argument. It is big, and has been
reviewed at least 4 times, so I think everything is covered.
Below you can see the message links from the discussions:
- First attempt:
<https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html>
Message-ID: <m3k44s7qej.fsf@gmail.com>
- Second attempt:
<https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html>
Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>
- Third attempt:
<https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html>
Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com>
- Fourth (last) attempt:
<https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html>
Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com>
gdb/
2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com>
Remove some globals from our parser.
* language.c (unk_lang_parser): Add "struct parser_state"
argument.
* language.h (struct language_defn) <la_parser>: Likewise.
* parse.c (expout, expout_size, expout_ptr): Remove variables.
(initialize_expout): Add "struct parser_state" argument.
Rewrite function to use the parser state.
(reallocate_expout, write_exp_elt, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
write_dollar_variable): Likewise.
(parse_exp_in_context_1): Use parser state.
(insert_type_address_space): Add "struct parser_state" argument.
Use parser state.
(increase_expout_size): New function.
* parser-defs.h: Forward declare "struct language_defn" and
"struct parser_state".
(expout, expout_size, expout_ptr): Remove extern declarations.
(parse_gdbarch, parse_language): Rewrite macro declarations to
accept the parser state.
(struct parser_state): New struct.
(initialize_expout, reallocate_expout, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
write_exp_msymbol, write_dollar_variable,
mark_struct_expression, insert_type_address_space): Add "struct
parser_state" argument.
(increase_expout_size): New function.
* utils.c (do_clear_parser_state): New function.
(make_cleanup_clear_parser_state): Likewise.
* utils.h (make_cleanup_clear_parser_state): New function
prototype.
* aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
Update calls to write_exp* in order to pass the parser state.
* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
* i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
(i386_stap_parse_special_token_three_arg_disp): Likewise.
* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
* stap-probe.c (stap_parse_register_operand): Likewise.
(stap_parse_single_operand): Likewise.
(stap_parse_argument_1): Likewise.
(stap_parse_argument): Use parser state.
* stap-probe.h: Include "parser-defs.h".
(struct stap_parse_info) <pstate>: New field.
* c-exp.y (parse_type): Rewrite to use parser state.
(yyparse): Redefine to c_parse_internal.
(pstate): New global variable.
(parse_number): Add "struct parser_state" argument.
(write_destructor_name): Likewise.
(type_exp): Update calls to write_exp* and similars in order to
use parser state.
(exp1, exp, variable, qualified_name, space_identifier,
typename, typebase): Likewise.
(write_destructor_name, parse_number, lex_one_token,
classify_name, classify_inner_name, c_parse): Add "struct
parser_state" argument. Update function to use parser state.
* c-lang.h: Forward declare "struct parser_state".
(c_parse): Add "struct parser_state" argument.
* ada-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to ada_parse_internal.
(pstate): New variable.
(write_int, write_object_renaming, write_var_or_type,
write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
type_int, type_long, type_long_long, type_float, type_double,
type_long_double, type_char, type_boolean, type_system_address):
Add "struct parser_state" argument.
(exp1, primary, simple_exp, relation, and_exp, and_then_exp,
or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
var_or_type, aggregate, aggregate_component_list,
positional_list, others, component_group,
component_associations): Update calls to write_exp* and similar
functions in order to use parser state.
(ada_parse, write_var_from_sym, write_int,
write_exp_op_with_string, write_object_renaming,
find_primitive_type, write_selectors, write_ambiguous_var,
write_var_or_type, write_name_assoc, type_int, type_long,
type_long_long, type_float, type_double, type_long_double,
type_char, type_boolean, type_system_address): Add "struct
parser_state" argument. Adjust function to use parser state.
* ada-lang.c (parse): Likewise.
* ada-lang.h: Forward declare "struct parser_state".
(ada_parse): Add "struct parser_state" argument.
* ada-lex.l (processInt, processReal): Likewise. Adjust all
calls to both functions.
* f-exp.y (parse_type, parse_f_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to f_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp, subrange, typebase): Update calls to write_exp*
and similars in order to use parser state.
(parse_number): Adjust code to use parser state.
(yylex): Likewise.
(f_parse): New function.
* f-lang.h: Forward declare "struct parser_state".
(f_parse): Add "struct parser_state" argument.
* jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro for java_parse_internal.
(pstate): New variable.
(push_expression_name, push_expression_name, insert_exp): Add
"struct parser_state" argument.
(type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
PostIncrementExpression, PostDecrementExpression,
UnaryExpression, PreIncrementExpression, PreDecrementExpression,
UnaryExpressionNotPlusMinus, CastExpression,
MultiplicativeExpression, AdditiveExpression, ShiftExpression,
RelationalExpression, EqualityExpression, AndExpression,
ExclusiveOrExpression, InclusiveOrExpression,
ConditionalAndExpression, ConditionalOrExpression,
ConditionalExpression, Assignment, LeftHandSide): Update
calls to write_exp* and similars in order to use parser state.
(parse_number): Ajust code to use parser state.
(yylex): Likewise.
(java_parse): New function.
(push_variable): Add "struct parser_state" argument. Adjust
code to user parser state.
(push_fieldnames, push_qualified_expression_name,
push_expression_name, insert_exp): Likewise.
* jv-lang.h: Forward declare "struct parser_state".
(java_parse): Add "struct parser_state" argument.
* m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to m2_parse_internal.
(pstate): New variable.
(type_exp, exp, fblock, variable, type): Update calls to
write_exp* and similars to use parser state.
(yylex): Likewise.
(m2_parse): New function.
* m2-lang.h: Forward declare "struct parser_state".
(m2_parse): Add "struct parser_state" argument.
* objc-lang.c (end_msglist): Add "struct parser_state" argument.
* objc-lang.h: Forward declare "struct parser_state".
(end_msglist): Add "struct parser_state" argument.
* p-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to pascal_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, qualified_name, variable): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, yylex): Adjust code to use parser state.
(pascal_parse): New function.
* p-lang.h: Forward declare "struct parser_state".
(pascal_parse): Add "struct parser_state" argument.
* go-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to go_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, variable, type): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, lex_one_token, classify_name, yylex): Adjust code
to use parser state.
(go_parse): Likewise.
* go-lang.h: Forward declare "struct parser_state".
(go_parse): Add "struct parser_state" argument.
2014-03-28 06:10:40 +08:00
|
|
|
|
write_exp_elt_opcode (&p.pstate, UNOP_CAST);
|
|
|
|
|
write_exp_elt_type (&p.pstate, atype);
|
|
|
|
|
write_exp_elt_opcode (&p.pstate, UNOP_CAST);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Rename _const functions to use overloading instead
This renames a few functions -- skip_spaces_const,
skip_to_space_const, get_number_const, extract_arg_const -- to drop
the "_const" suffix and instead rely on overloading.
This makes future const fixes simpler by reducing the number of lines
that must be changed. I think it is also not any less clear, as all
these functions have the same interface as their non-const versions by
design. Furthermore there's an example of using an overload in-tree
already, namely check_for_argument.
This patch was largely created using some perl one-liners; then a few
fixes were applied by hand.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* common/common-utils.h (skip_to_space): Remove macro, redeclare
as function.
(skip_to_space): Rename from skip_to_space_const.
* common/common-utils.c (skip_to_space): New function.
(skip_to_space): Rename from skip_to_space_const.
* cli/cli-utils.h (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
* cli/cli-utils.c (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
(number_or_range_parser::get_number): Use ::get_number.
* aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c,
break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c,
cli/cli-script.c, cli/cli-setshow.c, compile/compile.c,
completer.c, demangle.c, disasm.c, findcmd.c, linespec.c,
linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c,
minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c,
python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c,
stap-probe.c, tid-parse.c, tracepoint.c: Update all callers.
2017-09-11 04:19:19 +08:00
|
|
|
|
p.arg = skip_spaces (p.arg);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
*arg = p.arg;
|
|
|
|
|
|
2017-11-23 12:45:53 +08:00
|
|
|
|
return p.pstate.release ();
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
/* Implementation of 'parse_arguments' method. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
void
|
|
|
|
|
stap_probe::parse_arguments (struct gdbarch *gdbarch)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
const char *cur;
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
gdb_assert (!m_have_parsed_args);
|
|
|
|
|
cur = m_unparsed_args_text;
|
|
|
|
|
m_have_parsed_args = true;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
2013-12-24 06:48:08 +08:00
|
|
|
|
if (cur == NULL || *cur == '\0' || *cur == ':')
|
2012-04-28 04:47:57 +08:00
|
|
|
|
return;
|
|
|
|
|
|
2013-12-24 06:48:08 +08:00
|
|
|
|
while (*cur != '\0')
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
enum stap_arg_bitness bitness;
|
|
|
|
|
bool got_minus = false;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* We expect to find something like:
|
|
|
|
|
|
|
|
|
|
N@OP
|
|
|
|
|
|
2014-05-03 04:50:45 +08:00
|
|
|
|
Where `N' can be [+,-][1,2,4,8]. This is not mandatory, so
|
2012-04-28 04:47:57 +08:00
|
|
|
|
we check it here. If we don't find it, go to the next
|
|
|
|
|
state. */
|
2014-05-03 04:45:35 +08:00
|
|
|
|
if ((cur[0] == '-' && isdigit (cur[1]) && cur[2] == '@')
|
|
|
|
|
|| (isdigit (cur[0]) && cur[1] == '@'))
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
if (*cur == '-')
|
|
|
|
|
{
|
|
|
|
|
/* Discard the `-'. */
|
|
|
|
|
++cur;
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
got_minus = true;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-03 04:50:45 +08:00
|
|
|
|
/* Defining the bitness. */
|
|
|
|
|
switch (*cur)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
2014-05-03 04:50:45 +08:00
|
|
|
|
case '1':
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
bitness = (got_minus ? STAP_ARG_BITNESS_8BIT_SIGNED
|
|
|
|
|
: STAP_ARG_BITNESS_8BIT_UNSIGNED);
|
2014-05-03 04:50:45 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '2':
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
bitness = (got_minus ? STAP_ARG_BITNESS_16BIT_SIGNED
|
|
|
|
|
: STAP_ARG_BITNESS_16BIT_UNSIGNED);
|
2014-05-03 04:50:45 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '4':
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
bitness = (got_minus ? STAP_ARG_BITNESS_32BIT_SIGNED
|
|
|
|
|
: STAP_ARG_BITNESS_32BIT_UNSIGNED);
|
2014-05-03 04:50:45 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '8':
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
bitness = (got_minus ? STAP_ARG_BITNESS_64BIT_SIGNED
|
|
|
|
|
: STAP_ARG_BITNESS_64BIT_UNSIGNED);
|
2014-05-03 04:50:45 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
/* We have an error, because we don't expect anything
|
|
|
|
|
except 1, 2, 4 and 8. */
|
|
|
|
|
warning (_("unrecognized bitness %s%c' for probe `%s'"),
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
got_minus ? "`-" : "`", *cur,
|
|
|
|
|
this->get_name ().c_str ());
|
2014-05-03 04:50:45 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
/* Discard the number and the `@' sign. */
|
|
|
|
|
cur += 2;
|
|
|
|
|
}
|
2014-05-03 04:45:35 +08:00
|
|
|
|
else
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
bitness = STAP_ARG_BITNESS_UNDEFINED;
|
2014-05-03 04:45:35 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
struct type *atype
|
|
|
|
|
= stap_get_expected_argument_type (gdbarch, bitness,
|
|
|
|
|
this->get_name ().c_str ());
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
expression_up expr = stap_parse_argument (&cur, atype, gdbarch);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
if (stap_expression_debug)
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
dump_raw_expression (expr.get (), gdb_stdlog,
|
2012-04-28 04:47:57 +08:00
|
|
|
|
"before conversion to prefix form");
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
prefixify_expression (expr.get ());
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
if (stap_expression_debug)
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
dump_prefix_expression (expr.get (), gdb_stdlog);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
m_parsed_args.emplace_back (bitness, atype, std::move (expr));
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* Start it over again. */
|
Rename _const functions to use overloading instead
This renames a few functions -- skip_spaces_const,
skip_to_space_const, get_number_const, extract_arg_const -- to drop
the "_const" suffix and instead rely on overloading.
This makes future const fixes simpler by reducing the number of lines
that must be changed. I think it is also not any less clear, as all
these functions have the same interface as their non-const versions by
design. Furthermore there's an example of using an overload in-tree
already, namely check_for_argument.
This patch was largely created using some perl one-liners; then a few
fixes were applied by hand.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* common/common-utils.h (skip_to_space): Remove macro, redeclare
as function.
(skip_to_space): Rename from skip_to_space_const.
* common/common-utils.c (skip_to_space): New function.
(skip_to_space): Rename from skip_to_space_const.
* cli/cli-utils.h (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
* cli/cli-utils.c (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
(number_or_range_parser::get_number): Use ::get_number.
* aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c,
break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c,
cli/cli-script.c, cli/cli-setshow.c, compile/compile.c,
completer.c, demangle.c, disasm.c, findcmd.c, linespec.c,
linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c,
minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c,
python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c,
stap-probe.c, tid-parse.c, tracepoint.c: Update all callers.
2017-09-11 04:19:19 +08:00
|
|
|
|
cur = skip_spaces (cur);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Fix PR gdb/22491: Regression when setting SystemTap probe semaphores
Pedro has kindly pointed out that
gdb.arch/amd64-stap-optional-prefix.exp was failing after my
C++-ification patches touching the probe interface. The failure is
kind of cryptic:
77 break -pstap bar
78 Breakpoint 3 at 0x40048d
79 (gdb) PASS: gdb.arch/amd64-stap-optional-prefix.exp: bar: break -pstap bar
80 continue
81 Continuing.
82
83 Program received signal SIGILL, Illegal instruction.
84 main () at amd64-stap-optional-prefix.S:26
85 26 STAP_PROBE1(probe, foo, (%rsp))
It took me a while to figure out where this SIGILL is coming from.
Initially I thought it was something related to writing registers to
the inferior when dealing with probe arguments, but I discarded this
since the arguments were not touching any registers.
In the end, this was a mistake that was introduced during the review
process of the patch. When setting/clearing a SystemTap probe's
semaphore, the code was using 'm_address' (which refers the probe's
address) instead of 'm_sem_addr' (which refers to the semaphore's
address). This caused GDB to write a bogus value in the wrong memory
position, which in turn caused the SIGILL.
I am pushing this patch to correct the mistake.
On a side note: I told Pedro that the BuildBot hadn't caught the
failure during my try build, and for a moment there was a suspicion
that the BuildBot might be at fault here. However, I investigate this
and noticed that I only did one try build, with a patch that was
correctly using 'm_sem_addr' where applicable, and therefore no
failure should have happened indeed. I probably should have requested
another try build after addressing the review's comments, but they
were mostly basic and I didn't think it was needed. Oh, well.
2017-11-25 Sergio Durigan Junior <sergiodj@redhat.com>
PR gdb/22491
* stap-probe.c (relocate_address): New function.
(stap_probe::get_relocated_address): Use 'relocate_address'.
(stap_probe::set_semaphore): Use 'relocate_address' and pass
'm_sem_addr'.
(stap_probe::clear_semaphore): Likewise.
2017-11-25 14:13:03 +08:00
|
|
|
|
/* Helper function to relocate an address. */
|
|
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
|
relocate_address (CORE_ADDR address, struct objfile *objfile)
|
|
|
|
|
{
|
|
|
|
|
return address + ANOFFSET (objfile->section_offsets,
|
|
|
|
|
SECT_OFF_DATA (objfile));
|
|
|
|
|
}
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
/* Implementation of the get_relocated_address method. */
|
change probes to be program-space-independent
This changes the probes to be independent of the program space.
After this, when a probe's address is needed, it is determined by
applying offsets at the point of use.
This introduces a bound_probe object, similar to bound minimal
symbols. Objects of this type are used when it's necessary to pass a
probe and its corresponding objfile.
This removes the backlink from probe to objfile, which was primarily
used to fetch the architecture to use.
This adds a get_probe_address function which calls a probe method to
compute the probe's relocated address. Similarly, it adds an objfile
parameter to the semaphore methods so they can do the relocation
properly as well.
2014-03-03 Tom Tromey <tromey@redhat.com>
* break-catch-throw.c (fetch_probe_arguments): Use bound probes.
* breakpoint.c (create_longjmp_master_breakpoint): Use
get_probe_address.
(add_location_to_breakpoint, bkpt_probe_insert_location)
(bkpt_probe_remove_location): Update.
* breakpoint.h (struct bp_location) <probe>: Now a bound_probe.
* elfread.c (elf_symfile_relocate_probe): Remove.
(elf_probe_fns): Update.
(insert_exception_resume_breakpoint): Change type of "probe"
parameter to bound_probe.
(check_exception_resume): Update.
* objfiles.c (objfile_relocate1): Don't relocate probes.
* probe.c (bound_probe_s): New typedef.
(parse_probes): Use get_probe_address. Set sal's objfile.
(find_probe_by_pc): Return a bound_probe.
(collect_probes): Return a VEC(bound_probe_s).
(compare_probes): Update.
(gen_ui_out_table_header_info): Change type of "probes"
parameter. Update.
(info_probes_for_ops): Update.
(get_probe_address): New function.
(probe_safe_evaluate_at_pc): Update.
* probe.h (struct probe_ops) <get_probe_address>: New field.
<set_semaphore, clear_semaphore>: Add objfile parameter.
(struct probe) <objfile>: Remove field.
<arch>: New field.
<address>: Update comment.
(struct bound_probe): New.
(find_probe_by_pc): Return a bound_probe.
(get_probe_address): Declare.
* solib-svr4.c (struct probe_and_action) <address>: New field.
(hash_probe_and_action, equal_probe_and_action): Update.
(register_solib_event_probe): Add address parameter.
(solib_event_probe_at): Update.
(svr4_create_probe_breakpoints): Add objfile parameter. Use
get_probe_address.
* stap-probe.c (struct stap_probe) <sem_addr>: Update comment.
(stap_get_probe_address): New function.
(stap_can_evaluate_probe_arguments, compute_probe_arg)
(compile_probe_arg): Update.
(stap_set_semaphore, stap_clear_semaphore): Compute semaphore's
address.
(handle_stap_probe): Don't relocate the probe.
(stap_relocate): Remove.
(stap_gen_info_probes_table_values): Update.
(stap_probe_ops): Remove stap_relocate.
* symfile-debug.c (debug_sym_relocate_probe): Remove.
(debug_sym_probe_fns): Update.
* symfile.h (struct sym_probe_fns) <sym_relocate_probe>: Remove.
* symtab.c (init_sal): Use memset.
* symtab.h (struct symtab_and_line) <objfile>: New field.
* tracepoint.c (start_tracing, stop_tracing): Update.
2013-12-03 04:58:59 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
CORE_ADDR
|
|
|
|
|
stap_probe::get_relocated_address (struct objfile *objfile)
|
change probes to be program-space-independent
This changes the probes to be independent of the program space.
After this, when a probe's address is needed, it is determined by
applying offsets at the point of use.
This introduces a bound_probe object, similar to bound minimal
symbols. Objects of this type are used when it's necessary to pass a
probe and its corresponding objfile.
This removes the backlink from probe to objfile, which was primarily
used to fetch the architecture to use.
This adds a get_probe_address function which calls a probe method to
compute the probe's relocated address. Similarly, it adds an objfile
parameter to the semaphore methods so they can do the relocation
properly as well.
2014-03-03 Tom Tromey <tromey@redhat.com>
* break-catch-throw.c (fetch_probe_arguments): Use bound probes.
* breakpoint.c (create_longjmp_master_breakpoint): Use
get_probe_address.
(add_location_to_breakpoint, bkpt_probe_insert_location)
(bkpt_probe_remove_location): Update.
* breakpoint.h (struct bp_location) <probe>: Now a bound_probe.
* elfread.c (elf_symfile_relocate_probe): Remove.
(elf_probe_fns): Update.
(insert_exception_resume_breakpoint): Change type of "probe"
parameter to bound_probe.
(check_exception_resume): Update.
* objfiles.c (objfile_relocate1): Don't relocate probes.
* probe.c (bound_probe_s): New typedef.
(parse_probes): Use get_probe_address. Set sal's objfile.
(find_probe_by_pc): Return a bound_probe.
(collect_probes): Return a VEC(bound_probe_s).
(compare_probes): Update.
(gen_ui_out_table_header_info): Change type of "probes"
parameter. Update.
(info_probes_for_ops): Update.
(get_probe_address): New function.
(probe_safe_evaluate_at_pc): Update.
* probe.h (struct probe_ops) <get_probe_address>: New field.
<set_semaphore, clear_semaphore>: Add objfile parameter.
(struct probe) <objfile>: Remove field.
<arch>: New field.
<address>: Update comment.
(struct bound_probe): New.
(find_probe_by_pc): Return a bound_probe.
(get_probe_address): Declare.
* solib-svr4.c (struct probe_and_action) <address>: New field.
(hash_probe_and_action, equal_probe_and_action): Update.
(register_solib_event_probe): Add address parameter.
(solib_event_probe_at): Update.
(svr4_create_probe_breakpoints): Add objfile parameter. Use
get_probe_address.
* stap-probe.c (struct stap_probe) <sem_addr>: Update comment.
(stap_get_probe_address): New function.
(stap_can_evaluate_probe_arguments, compute_probe_arg)
(compile_probe_arg): Update.
(stap_set_semaphore, stap_clear_semaphore): Compute semaphore's
address.
(handle_stap_probe): Don't relocate the probe.
(stap_relocate): Remove.
(stap_gen_info_probes_table_values): Update.
(stap_probe_ops): Remove stap_relocate.
* symfile-debug.c (debug_sym_relocate_probe): Remove.
(debug_sym_probe_fns): Update.
* symfile.h (struct sym_probe_fns) <sym_relocate_probe>: Remove.
* symtab.c (init_sal): Use memset.
* symtab.h (struct symtab_and_line) <objfile>: New field.
* tracepoint.c (start_tracing, stop_tracing): Update.
2013-12-03 04:58:59 +08:00
|
|
|
|
{
|
Fix PR gdb/22491: Regression when setting SystemTap probe semaphores
Pedro has kindly pointed out that
gdb.arch/amd64-stap-optional-prefix.exp was failing after my
C++-ification patches touching the probe interface. The failure is
kind of cryptic:
77 break -pstap bar
78 Breakpoint 3 at 0x40048d
79 (gdb) PASS: gdb.arch/amd64-stap-optional-prefix.exp: bar: break -pstap bar
80 continue
81 Continuing.
82
83 Program received signal SIGILL, Illegal instruction.
84 main () at amd64-stap-optional-prefix.S:26
85 26 STAP_PROBE1(probe, foo, (%rsp))
It took me a while to figure out where this SIGILL is coming from.
Initially I thought it was something related to writing registers to
the inferior when dealing with probe arguments, but I discarded this
since the arguments were not touching any registers.
In the end, this was a mistake that was introduced during the review
process of the patch. When setting/clearing a SystemTap probe's
semaphore, the code was using 'm_address' (which refers the probe's
address) instead of 'm_sem_addr' (which refers to the semaphore's
address). This caused GDB to write a bogus value in the wrong memory
position, which in turn caused the SIGILL.
I am pushing this patch to correct the mistake.
On a side note: I told Pedro that the BuildBot hadn't caught the
failure during my try build, and for a moment there was a suspicion
that the BuildBot might be at fault here. However, I investigate this
and noticed that I only did one try build, with a patch that was
correctly using 'm_sem_addr' where applicable, and therefore no
failure should have happened indeed. I probably should have requested
another try build after addressing the review's comments, but they
were mostly basic and I didn't think it was needed. Oh, well.
2017-11-25 Sergio Durigan Junior <sergiodj@redhat.com>
PR gdb/22491
* stap-probe.c (relocate_address): New function.
(stap_probe::get_relocated_address): Use 'relocate_address'.
(stap_probe::set_semaphore): Use 'relocate_address' and pass
'm_sem_addr'.
(stap_probe::clear_semaphore): Likewise.
2017-11-25 14:13:03 +08:00
|
|
|
|
return relocate_address (this->get_address (), objfile);
|
change probes to be program-space-independent
This changes the probes to be independent of the program space.
After this, when a probe's address is needed, it is determined by
applying offsets at the point of use.
This introduces a bound_probe object, similar to bound minimal
symbols. Objects of this type are used when it's necessary to pass a
probe and its corresponding objfile.
This removes the backlink from probe to objfile, which was primarily
used to fetch the architecture to use.
This adds a get_probe_address function which calls a probe method to
compute the probe's relocated address. Similarly, it adds an objfile
parameter to the semaphore methods so they can do the relocation
properly as well.
2014-03-03 Tom Tromey <tromey@redhat.com>
* break-catch-throw.c (fetch_probe_arguments): Use bound probes.
* breakpoint.c (create_longjmp_master_breakpoint): Use
get_probe_address.
(add_location_to_breakpoint, bkpt_probe_insert_location)
(bkpt_probe_remove_location): Update.
* breakpoint.h (struct bp_location) <probe>: Now a bound_probe.
* elfread.c (elf_symfile_relocate_probe): Remove.
(elf_probe_fns): Update.
(insert_exception_resume_breakpoint): Change type of "probe"
parameter to bound_probe.
(check_exception_resume): Update.
* objfiles.c (objfile_relocate1): Don't relocate probes.
* probe.c (bound_probe_s): New typedef.
(parse_probes): Use get_probe_address. Set sal's objfile.
(find_probe_by_pc): Return a bound_probe.
(collect_probes): Return a VEC(bound_probe_s).
(compare_probes): Update.
(gen_ui_out_table_header_info): Change type of "probes"
parameter. Update.
(info_probes_for_ops): Update.
(get_probe_address): New function.
(probe_safe_evaluate_at_pc): Update.
* probe.h (struct probe_ops) <get_probe_address>: New field.
<set_semaphore, clear_semaphore>: Add objfile parameter.
(struct probe) <objfile>: Remove field.
<arch>: New field.
<address>: Update comment.
(struct bound_probe): New.
(find_probe_by_pc): Return a bound_probe.
(get_probe_address): Declare.
* solib-svr4.c (struct probe_and_action) <address>: New field.
(hash_probe_and_action, equal_probe_and_action): Update.
(register_solib_event_probe): Add address parameter.
(solib_event_probe_at): Update.
(svr4_create_probe_breakpoints): Add objfile parameter. Use
get_probe_address.
* stap-probe.c (struct stap_probe) <sem_addr>: Update comment.
(stap_get_probe_address): New function.
(stap_can_evaluate_probe_arguments, compute_probe_arg)
(compile_probe_arg): Update.
(stap_set_semaphore, stap_clear_semaphore): Compute semaphore's
address.
(handle_stap_probe): Don't relocate the probe.
(stap_relocate): Remove.
(stap_gen_info_probes_table_values): Update.
(stap_probe_ops): Remove stap_relocate.
* symfile-debug.c (debug_sym_relocate_probe): Remove.
(debug_sym_probe_fns): Update.
* symfile.h (struct sym_probe_fns) <sym_relocate_probe>: Remove.
* symtab.c (init_sal): Use memset.
* symtab.h (struct symtab_and_line) <objfile>: New field.
* tracepoint.c (start_tracing, stop_tracing): Update.
2013-12-03 04:58:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2012-04-28 04:47:57 +08:00
|
|
|
|
/* Given PROBE, returns the number of arguments present in that probe's
|
|
|
|
|
argument string. */
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
unsigned
|
2019-08-21 22:24:02 +08:00
|
|
|
|
stap_probe::get_argument_count (struct gdbarch *gdbarch)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
if (!m_have_parsed_args)
|
2013-07-25 03:50:32 +08:00
|
|
|
|
{
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
if (this->can_evaluate_arguments ())
|
|
|
|
|
this->parse_arguments (gdbarch);
|
2013-07-25 03:50:32 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
2019-05-17 03:58:55 +08:00
|
|
|
|
static bool have_warned_stap_incomplete = false;
|
2013-07-25 03:50:32 +08:00
|
|
|
|
|
|
|
|
|
if (!have_warned_stap_incomplete)
|
|
|
|
|
{
|
|
|
|
|
warning (_(
|
|
|
|
|
"The SystemTap SDT probe support is not fully implemented on this target;\n"
|
|
|
|
|
"you will not be able to inspect the arguments of the probes.\n"
|
|
|
|
|
"Please report a bug against GDB requesting a port to this target."));
|
2019-05-17 03:58:55 +08:00
|
|
|
|
have_warned_stap_incomplete = true;
|
2013-07-25 03:50:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Marking the arguments as "already parsed". */
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
m_have_parsed_args = true;
|
2013-07-25 03:50:32 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
gdb_assert (m_have_parsed_args);
|
|
|
|
|
return m_parsed_args.size ();
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
/* Return true if OP is a valid operator inside a probe argument, or
|
|
|
|
|
false otherwise. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
2019-05-17 03:58:55 +08:00
|
|
|
|
static bool
|
2012-05-04 04:04:06 +08:00
|
|
|
|
stap_is_operator (const char *op)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
2019-05-17 03:58:55 +08:00
|
|
|
|
bool ret = true;
|
2012-05-04 04:04:06 +08:00
|
|
|
|
|
|
|
|
|
switch (*op)
|
|
|
|
|
{
|
|
|
|
|
case '*':
|
|
|
|
|
case '/':
|
|
|
|
|
case '%':
|
|
|
|
|
case '^':
|
|
|
|
|
case '!':
|
|
|
|
|
case '+':
|
|
|
|
|
case '-':
|
|
|
|
|
case '<':
|
|
|
|
|
case '>':
|
|
|
|
|
case '|':
|
|
|
|
|
case '&':
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '=':
|
|
|
|
|
if (op[1] != '=')
|
2019-05-17 03:58:55 +08:00
|
|
|
|
ret = false;
|
2012-05-04 04:04:06 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
/* We didn't find any operator. */
|
2019-05-17 03:58:55 +08:00
|
|
|
|
ret = false;
|
2012-05-04 04:04:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
/* Implement the `can_evaluate_arguments' method. */
|
Improve error reporting when handling SystemTap SDT probes
This patch improves the error reporting when handling SystemTap SDT
probes. "Handling", in this case, mostly means "parsing".
On gdb/probe.h, only trivial changes on functions' comments in order
to explicitly mention that some of them can throw exceptions. This is
just to make the API a bit more clear.
On gdb/stap-probe.c, I have s/internal_error/error/ on two functions
that are responsible for parsing specific bits of the probes'
arguments: stap_get_opcode and stap_get_expected_argument_type. It is
not correct to call internal_error on such situations because it is
not really GDB's fault if the probes have malformed arguments. I also
improved the error reported on stap_get_expected_argument_type by also
including the probe name on it.
Aside from that, and perhaps most importantly, I added a check on
stap_get_arg to make sure that we don't try to extract an argument
from a probe that has no arguments. This check issues an
internal_error, because it really means that GDB is doing something it
shouldn't.
Although it can be considered almost trivial, and despite the fact
that I am the maintainer for this part of the code, I am posting this
patch for review. I will wait a few days, and if nobody has anything
to say, I will go ahead and push it.
gdb/ChangeLog:
2015-09-01 Sergio Durigan Junior <sergiodj@redhat.com>
* probe.h (struct probe_ops) <get_probe_argument_count,
evaluate_probe_argument, enable_probe, disable_probe>: Mention in
the comment that the function can throw an exception.
(get_probe_argument_count): Likewise.
(evaluate_probe_argument): Likewise.
* stap-probe.c (stap_get_opcode): Call error instead of
internal_error.
(stap_get_expected_argument_type): Likewise. Add argument
'probe'. Improve error message by mentioning the probe's name.
(stap_parse_probe_arguments): Adjust call to
stap_get_expected_argument_type.
(stap_get_arg): Add comment. Assert that 'probe->args_parsed' is
not zero. Call internal_error if GDB requests an argument but the
probe has no arguments.
2015-08-22 06:13:46 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
bool
|
|
|
|
|
stap_probe::can_evaluate_arguments () const
|
2013-07-25 03:50:32 +08:00
|
|
|
|
{
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
struct gdbarch *gdbarch = this->get_gdbarch ();
|
2013-07-25 03:50:32 +08:00
|
|
|
|
|
|
|
|
|
/* For SystemTap probes, we have to guarantee that the method
|
|
|
|
|
stap_is_single_operand is defined on gdbarch. If it is not, then it
|
|
|
|
|
means that argument evaluation is not implemented on this target. */
|
|
|
|
|
return gdbarch_stap_is_single_operand_p (gdbarch);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-28 04:47:57 +08:00
|
|
|
|
/* Evaluate the probe's argument N (indexed from 0), returning a value
|
|
|
|
|
corresponding to it. Assertion is thrown if N does not exist. */
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
struct value *
|
|
|
|
|
stap_probe::evaluate_argument (unsigned n, struct frame_info *frame)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
struct stap_probe_arg *arg;
|
|
|
|
|
int pos = 0;
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (frame);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
arg = this->get_arg_by_number (n, gdbarch);
|
|
|
|
|
return evaluate_subexp_standard (arg->atype, arg->aexpr.get (), &pos,
|
|
|
|
|
EVAL_NORMAL);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Compile the probe's argument N (indexed from 0) to agent expression.
|
|
|
|
|
Assertion is thrown if N does not exist. */
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
void
|
|
|
|
|
stap_probe::compile_to_ax (struct agent_expr *expr, struct axs_value *value,
|
|
|
|
|
unsigned n)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
struct stap_probe_arg *arg;
|
|
|
|
|
union exp_element *pc;
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
arg = this->get_arg_by_number (n, expr->gdbarch);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
pc = arg->aexpr->elts;
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
gen_expr (arg->aexpr.get (), &pc, expr, value);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
require_rvalue (expr, value);
|
|
|
|
|
value->type = arg->atype;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Set or clear a SystemTap semaphore. ADDRESS is the semaphore's
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
address. SET is zero if the semaphore should be cleared, or one if
|
|
|
|
|
it should be set. This is a helper function for
|
|
|
|
|
'stap_probe::set_semaphore' and 'stap_probe::clear_semaphore'. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch)
|
|
|
|
|
{
|
|
|
|
|
gdb_byte bytes[sizeof (LONGEST)];
|
|
|
|
|
/* The ABI specifies "unsigned short". */
|
|
|
|
|
struct type *type = builtin_type (gdbarch)->builtin_unsigned_short;
|
|
|
|
|
ULONGEST value;
|
|
|
|
|
|
|
|
|
|
if (address == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Swallow errors. */
|
|
|
|
|
if (target_read_memory (address, bytes, TYPE_LENGTH (type)) != 0)
|
|
|
|
|
{
|
|
|
|
|
warning (_("Could not read the value of a SystemTap semaphore."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
value = extract_unsigned_integer (bytes, TYPE_LENGTH (type),
|
|
|
|
|
gdbarch_byte_order (gdbarch));
|
|
|
|
|
/* Note that we explicitly don't worry about overflow or
|
|
|
|
|
underflow. */
|
|
|
|
|
if (set)
|
|
|
|
|
++value;
|
|
|
|
|
else
|
|
|
|
|
--value;
|
|
|
|
|
|
|
|
|
|
store_unsigned_integer (bytes, TYPE_LENGTH (type),
|
|
|
|
|
gdbarch_byte_order (gdbarch), value);
|
|
|
|
|
|
|
|
|
|
if (target_write_memory (address, bytes, TYPE_LENGTH (type)) != 0)
|
|
|
|
|
warning (_("Could not write the value of a SystemTap semaphore."));
|
|
|
|
|
}
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
/* Implementation of the 'set_semaphore' method.
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
SystemTap semaphores act as reference counters, so calls to this
|
|
|
|
|
function must be paired with calls to 'clear_semaphore'.
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
This function and 'clear_semaphore' race with another tool
|
|
|
|
|
changing the probes, but that is too rare to care. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
stap_probe::set_semaphore (struct objfile *objfile, struct gdbarch *gdbarch)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
Fix PR gdb/22491: Regression when setting SystemTap probe semaphores
Pedro has kindly pointed out that
gdb.arch/amd64-stap-optional-prefix.exp was failing after my
C++-ification patches touching the probe interface. The failure is
kind of cryptic:
77 break -pstap bar
78 Breakpoint 3 at 0x40048d
79 (gdb) PASS: gdb.arch/amd64-stap-optional-prefix.exp: bar: break -pstap bar
80 continue
81 Continuing.
82
83 Program received signal SIGILL, Illegal instruction.
84 main () at amd64-stap-optional-prefix.S:26
85 26 STAP_PROBE1(probe, foo, (%rsp))
It took me a while to figure out where this SIGILL is coming from.
Initially I thought it was something related to writing registers to
the inferior when dealing with probe arguments, but I discarded this
since the arguments were not touching any registers.
In the end, this was a mistake that was introduced during the review
process of the patch. When setting/clearing a SystemTap probe's
semaphore, the code was using 'm_address' (which refers the probe's
address) instead of 'm_sem_addr' (which refers to the semaphore's
address). This caused GDB to write a bogus value in the wrong memory
position, which in turn caused the SIGILL.
I am pushing this patch to correct the mistake.
On a side note: I told Pedro that the BuildBot hadn't caught the
failure during my try build, and for a moment there was a suspicion
that the BuildBot might be at fault here. However, I investigate this
and noticed that I only did one try build, with a patch that was
correctly using 'm_sem_addr' where applicable, and therefore no
failure should have happened indeed. I probably should have requested
another try build after addressing the review's comments, but they
were mostly basic and I didn't think it was needed. Oh, well.
2017-11-25 Sergio Durigan Junior <sergiodj@redhat.com>
PR gdb/22491
* stap-probe.c (relocate_address): New function.
(stap_probe::get_relocated_address): Use 'relocate_address'.
(stap_probe::set_semaphore): Use 'relocate_address' and pass
'm_sem_addr'.
(stap_probe::clear_semaphore): Likewise.
2017-11-25 14:13:03 +08:00
|
|
|
|
stap_modify_semaphore (relocate_address (m_sem_addr, objfile), 1, gdbarch);
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
}
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
/* Implementation of the 'clear_semaphore' method. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
void
|
|
|
|
|
stap_probe::clear_semaphore (struct objfile *objfile, struct gdbarch *gdbarch)
|
|
|
|
|
{
|
Fix PR gdb/22491: Regression when setting SystemTap probe semaphores
Pedro has kindly pointed out that
gdb.arch/amd64-stap-optional-prefix.exp was failing after my
C++-ification patches touching the probe interface. The failure is
kind of cryptic:
77 break -pstap bar
78 Breakpoint 3 at 0x40048d
79 (gdb) PASS: gdb.arch/amd64-stap-optional-prefix.exp: bar: break -pstap bar
80 continue
81 Continuing.
82
83 Program received signal SIGILL, Illegal instruction.
84 main () at amd64-stap-optional-prefix.S:26
85 26 STAP_PROBE1(probe, foo, (%rsp))
It took me a while to figure out where this SIGILL is coming from.
Initially I thought it was something related to writing registers to
the inferior when dealing with probe arguments, but I discarded this
since the arguments were not touching any registers.
In the end, this was a mistake that was introduced during the review
process of the patch. When setting/clearing a SystemTap probe's
semaphore, the code was using 'm_address' (which refers the probe's
address) instead of 'm_sem_addr' (which refers to the semaphore's
address). This caused GDB to write a bogus value in the wrong memory
position, which in turn caused the SIGILL.
I am pushing this patch to correct the mistake.
On a side note: I told Pedro that the BuildBot hadn't caught the
failure during my try build, and for a moment there was a suspicion
that the BuildBot might be at fault here. However, I investigate this
and noticed that I only did one try build, with a patch that was
correctly using 'm_sem_addr' where applicable, and therefore no
failure should have happened indeed. I probably should have requested
another try build after addressing the review's comments, but they
were mostly basic and I didn't think it was needed. Oh, well.
2017-11-25 Sergio Durigan Junior <sergiodj@redhat.com>
PR gdb/22491
* stap-probe.c (relocate_address): New function.
(stap_probe::get_relocated_address): Use 'relocate_address'.
(stap_probe::set_semaphore): Use 'relocate_address' and pass
'm_sem_addr'.
(stap_probe::clear_semaphore): Likewise.
2017-11-25 14:13:03 +08:00
|
|
|
|
stap_modify_semaphore (relocate_address (m_sem_addr, objfile), 0, gdbarch);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
/* Implementation of the 'get_static_ops' method. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
const static_probe_ops *
|
|
|
|
|
stap_probe::get_static_ops () const
|
|
|
|
|
{
|
|
|
|
|
return &stap_static_probe_ops;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implementation of the 'gen_info_probes_table_values' method. */
|
|
|
|
|
|
|
|
|
|
std::vector<const char *>
|
|
|
|
|
stap_probe::gen_info_probes_table_values () const
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
const char *val = NULL;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
if (m_sem_addr != 0)
|
|
|
|
|
val = print_core_address (this->get_gdbarch (), m_sem_addr);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
return std::vector<const char *> { val };
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function that parses the information contained in a
|
|
|
|
|
SystemTap's probe. Basically, the information consists in:
|
|
|
|
|
|
|
|
|
|
- Probe's PC address;
|
|
|
|
|
- Link-time section address of `.stapsdt.base' section;
|
|
|
|
|
- Link-time address of the semaphore variable, or ZERO if the
|
|
|
|
|
probe doesn't have an associated semaphore;
|
|
|
|
|
- Probe's provider name;
|
|
|
|
|
- Probe's name;
|
2019-05-17 04:11:20 +08:00
|
|
|
|
- Probe's argument format. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
|
2019-05-01 13:47:54 +08:00
|
|
|
|
std::vector<std::unique_ptr<probe>> *probesp,
|
|
|
|
|
CORE_ADDR base)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
bfd *abfd = objfile->obfd;
|
|
|
|
|
int size = bfd_get_arch_size (abfd) / 8;
|
|
|
|
|
struct gdbarch *gdbarch = get_objfile_arch (objfile);
|
|
|
|
|
struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
|
|
|
|
|
|
|
|
|
|
/* Provider and the name of the probe. */
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
const char *provider = (const char *) &el->data[3 * size];
|
|
|
|
|
const char *name = ((const char *)
|
|
|
|
|
memchr (provider, '\0',
|
|
|
|
|
(char *) el->data + el->size - provider));
|
2012-04-28 04:47:57 +08:00
|
|
|
|
/* Making sure there is a name. */
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
if (name == NULL)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
2019-05-17 04:20:39 +08:00
|
|
|
|
complaint (_("corrupt probe name when reading `%s'"),
|
Code cleanup: Add objfile_name accessor
gdb/
2013-09-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup: Add objfile_name accessor function.
* ada-lang.c (is_known_support_routine): Use objfile_name.
* auto-load.c (source_gdb_script_for_objfile)
(auto_load_objfile_script): Likewise.
* coffread.c (coff_symtab_read, read_one_sym): Likewise.
* dbxread.c (dbx_symfile_read): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
* dwarf2loc.c (locexpr_describe_location_piece): Likewise.
* dwarf2read.c (dwarf2_get_dwz_file, dwarf2_read_index)
(dw2_symtab_iter_next, dw2_expand_symtabs_matching)
(lookup_dwp_signatured_type, lookup_dwo_unit)
(dwarf2_build_psymtabs_hard, scan_partial_symbols, process_queue)
(fixup_go_packaging, process_imported_unit_die, dwarf2_physname)
(read_import_statement, create_dwo_cu, open_and_init_dwp_file)
(lookup_dwo_cutu, read_call_site_scope, dwarf2_ranges_read)
(dwarf2_record_block_ranges, read_common_block, read_typedef)
(read_subrange_type, load_partial_dies, read_partial_die)
(read_addr_index_1, read_str_index, dwarf_decode_lines_1)
(die_containing_type, build_error_marker_type, lookup_die_type)
(follow_die_ref_or_sig, follow_die_ref, dwarf2_fetch_die_loc_sect_off)
(dwarf2_fetch_constant_bytes, follow_die_sig, get_signatured_type)
(get_DW_AT_signature_type, write_psymtabs_to_index)
(save_gdb_index_command): Likewise.
* elfread.c (find_separate_debug_file_by_buildid, elf_symfile_read):
Likewise.
* expprint.c (dump_subexp_body_standard): Likewise.
* gdbtypes.c (type_name_no_tag_or_error): Likewise.
* jit.c (jit_object_close_impl): Use the objfile field name renamed to
original_name.
* linux-thread-db.c (try_thread_db_load_from_pdir_1): New variable
obj_name, use objfile_name for it, use the variable.
(try_thread_db_load_from_pdir, has_libpthread, thread_db_new_objfile):
Use objfile_name.
* machoread.c (macho_symtab_read, macho_check_dsym)
(macho_symfile_relocate): Likewise.
* maint.c (maintenance_translate_address): Likewise.
* minidebug.c (find_separate_debug_file_in_section): Likewise.
* minsyms.c (install_minimal_symbols): Likewise.
* objfiles.c (allocate_objfile): Use the objfile field name renamed to
original_name.
(filter_overlapping_sections): Use objfile_name.
(objfile_name): New function.
* objfiles.h (struct objfile): Rename field name to original_name.
(objfile_name): New prototype.
* printcmd.c (sym_info, address_info): Use objfile_name.
* probe.c (parse_probes, collect_probes, compare_probes)
(info_probes_for_ops): Likewise.
* progspace.c (clone_program_space): Likewise.
* psymtab.c (require_partial_symbols, dump_psymtab, allocate_psymtab)
(maintenance_info_psymtabs): Likewise.
* python/py-auto-load.c (gdbpy_load_auto_script_for_objfile)
(source_section_scripts): Likewise.
* python/py-objfile.c (objfpy_get_filename): Likewise.
* python/py-progspace.c (pspy_get_filename): Likewise.
* solib-aix.c (solib_aix_get_toc_value): Likewise.
* solib-som.c (match_main, som_solib_section_offsets): Likewise.
* solib.c (solib_read_symbols): Likewise.
* stabsread.c (scan_file_globals): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (symbol_file_clear, separate_debug_file_exists)
(find_separate_debug_file_by_debuglink): Likewise.
(reread_symbols): Likewise. Use the objfile field name renamed to
original_name.
(allocate_symtab): Use objfile_name.
* symmisc.c (print_symbol_bcache_statistics, print_objfile_statistics)
(dump_objfile, dump_msymbols, dump_symtab_1)
(maintenance_print_msymbols, maintenance_print_objfiles)
(maintenance_info_symtabs, maintenance_check_symtabs): Likewise.
* target.c (target_translate_tls_address, target_info): Likewise.
* xcoffread.c (xcoff_initial_scan): Make variable name const. Use
objfile_name.
2013-09-24 21:57:38 +08:00
|
|
|
|
objfile_name (objfile));
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* There is no way to use a probe without a name or a provider, so
|
2019-05-17 04:20:39 +08:00
|
|
|
|
returning here makes sense. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
++name;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* Retrieving the probe's address. */
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
CORE_ADDR address = extract_typed_address (&el->data[0], ptr_type);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* Link-time sh_addr of `.stapsdt.base' section. */
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
CORE_ADDR base_ref = extract_typed_address (&el->data[size], ptr_type);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* Semaphore address. */
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
CORE_ADDR sem_addr = extract_typed_address (&el->data[2 * size], ptr_type);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
address += base - base_ref;
|
|
|
|
|
if (sem_addr != 0)
|
|
|
|
|
sem_addr += base - base_ref;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* Arguments. We can only extract the argument format if there is a valid
|
|
|
|
|
name for this probe. */
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
const char *probe_args = ((const char*)
|
|
|
|
|
memchr (name, '\0',
|
|
|
|
|
(char *) el->data + el->size - name));
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
if (probe_args != NULL)
|
|
|
|
|
++probe_args;
|
|
|
|
|
|
2013-12-24 06:48:08 +08:00
|
|
|
|
if (probe_args == NULL
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
|| (memchr (probe_args, '\0', (char *) el->data + el->size - name)
|
2013-12-24 06:48:08 +08:00
|
|
|
|
!= el->data + el->size - 1))
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
2019-05-17 04:20:39 +08:00
|
|
|
|
complaint (_("corrupt probe argument when reading `%s'"),
|
Code cleanup: Add objfile_name accessor
gdb/
2013-09-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup: Add objfile_name accessor function.
* ada-lang.c (is_known_support_routine): Use objfile_name.
* auto-load.c (source_gdb_script_for_objfile)
(auto_load_objfile_script): Likewise.
* coffread.c (coff_symtab_read, read_one_sym): Likewise.
* dbxread.c (dbx_symfile_read): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
* dwarf2loc.c (locexpr_describe_location_piece): Likewise.
* dwarf2read.c (dwarf2_get_dwz_file, dwarf2_read_index)
(dw2_symtab_iter_next, dw2_expand_symtabs_matching)
(lookup_dwp_signatured_type, lookup_dwo_unit)
(dwarf2_build_psymtabs_hard, scan_partial_symbols, process_queue)
(fixup_go_packaging, process_imported_unit_die, dwarf2_physname)
(read_import_statement, create_dwo_cu, open_and_init_dwp_file)
(lookup_dwo_cutu, read_call_site_scope, dwarf2_ranges_read)
(dwarf2_record_block_ranges, read_common_block, read_typedef)
(read_subrange_type, load_partial_dies, read_partial_die)
(read_addr_index_1, read_str_index, dwarf_decode_lines_1)
(die_containing_type, build_error_marker_type, lookup_die_type)
(follow_die_ref_or_sig, follow_die_ref, dwarf2_fetch_die_loc_sect_off)
(dwarf2_fetch_constant_bytes, follow_die_sig, get_signatured_type)
(get_DW_AT_signature_type, write_psymtabs_to_index)
(save_gdb_index_command): Likewise.
* elfread.c (find_separate_debug_file_by_buildid, elf_symfile_read):
Likewise.
* expprint.c (dump_subexp_body_standard): Likewise.
* gdbtypes.c (type_name_no_tag_or_error): Likewise.
* jit.c (jit_object_close_impl): Use the objfile field name renamed to
original_name.
* linux-thread-db.c (try_thread_db_load_from_pdir_1): New variable
obj_name, use objfile_name for it, use the variable.
(try_thread_db_load_from_pdir, has_libpthread, thread_db_new_objfile):
Use objfile_name.
* machoread.c (macho_symtab_read, macho_check_dsym)
(macho_symfile_relocate): Likewise.
* maint.c (maintenance_translate_address): Likewise.
* minidebug.c (find_separate_debug_file_in_section): Likewise.
* minsyms.c (install_minimal_symbols): Likewise.
* objfiles.c (allocate_objfile): Use the objfile field name renamed to
original_name.
(filter_overlapping_sections): Use objfile_name.
(objfile_name): New function.
* objfiles.h (struct objfile): Rename field name to original_name.
(objfile_name): New prototype.
* printcmd.c (sym_info, address_info): Use objfile_name.
* probe.c (parse_probes, collect_probes, compare_probes)
(info_probes_for_ops): Likewise.
* progspace.c (clone_program_space): Likewise.
* psymtab.c (require_partial_symbols, dump_psymtab, allocate_psymtab)
(maintenance_info_psymtabs): Likewise.
* python/py-auto-load.c (gdbpy_load_auto_script_for_objfile)
(source_section_scripts): Likewise.
* python/py-objfile.c (objfpy_get_filename): Likewise.
* python/py-progspace.c (pspy_get_filename): Likewise.
* solib-aix.c (solib_aix_get_toc_value): Likewise.
* solib-som.c (match_main, som_solib_section_offsets): Likewise.
* solib.c (solib_read_symbols): Likewise.
* stabsread.c (scan_file_globals): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (symbol_file_clear, separate_debug_file_exists)
(find_separate_debug_file_by_debuglink): Likewise.
(reread_symbols): Likewise. Use the objfile field name renamed to
original_name.
(allocate_symtab): Use objfile_name.
* symmisc.c (print_symbol_bcache_statistics, print_objfile_statistics)
(dump_objfile, dump_msymbols, dump_symtab_1)
(maintenance_print_msymbols, maintenance_print_objfiles)
(maintenance_info_symtabs, maintenance_check_symtabs): Likewise.
* target.c (target_translate_tls_address, target_info): Likewise.
* xcoffread.c (xcoff_initial_scan): Make variable name const. Use
objfile_name.
2013-09-24 21:57:38 +08:00
|
|
|
|
objfile_name (objfile));
|
2012-04-28 04:47:57 +08:00
|
|
|
|
/* If the argument string is NULL, it means some problem happened with
|
2019-05-17 04:20:39 +08:00
|
|
|
|
it. So we return. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
stap_probe *ret = new stap_probe (std::string (name), std::string (provider),
|
|
|
|
|
address, gdbarch, sem_addr, probe_args);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
/* Successfully created probe. */
|
2019-05-01 13:47:54 +08:00
|
|
|
|
probesp->emplace_back (ret);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function which tries to find the base address of the SystemTap
|
|
|
|
|
base section named STAP_BASE_SECTION_NAME. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_stap_base_address_1 (bfd *abfd, asection *sect, void *obj)
|
|
|
|
|
{
|
2015-09-26 02:08:07 +08:00
|
|
|
|
asection **ret = (asection **) obj;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
if ((sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS))
|
|
|
|
|
&& sect->name && !strcmp (sect->name, STAP_BASE_SECTION_NAME))
|
|
|
|
|
*ret = sect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function which iterates over every section in the BFD file,
|
|
|
|
|
trying to find the base address of the SystemTap base section.
|
|
|
|
|
Returns 1 if found (setting BASE to the proper value), zero otherwise. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
get_stap_base_address (bfd *obfd, bfd_vma *base)
|
|
|
|
|
{
|
|
|
|
|
asection *ret = NULL;
|
|
|
|
|
|
|
|
|
|
bfd_map_over_sections (obfd, get_stap_base_address_1, (void *) &ret);
|
|
|
|
|
|
2013-12-24 06:48:08 +08:00
|
|
|
|
if (ret == NULL)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
Remove symfile_complaints
The complaint system seems to allow for multiple different complaint
topics. However, in practice only symfile_complaints has ever been
defined. Seeing that complaints.c dates to 1992, and that no new
complaints have been added in the intervening years, I think it is
reasonable to admit that complaints are specifically related to
debuginfo reading.
This patch removes symfile_complaints and updates all the callers.
Some of these spots should perhaps be calls to warning instead, but I
did not make that change.
gdb/ChangeLog
2018-05-23 Tom Tromey <tom@tromey.com>
* complaints.c (symfile_complaints): Remove.
(complaint_internal): Remove "complaints" parameter.
(clear_complaints, vcomplaint): Remove "c" parameter.
(get_complaints): Remove.
* dwarf2read.c (dwarf2_statement_list_fits_in_line_number_section_complaint)
(dwarf2_debug_line_missing_file_complaint)
(dwarf2_debug_line_missing_end_sequence_complaint)
(dwarf2_complex_location_expr_complaint)
(dwarf2_const_value_length_mismatch_complaint)
(dwarf2_section_buffer_overflow_complaint)
(dwarf2_macro_malformed_definition_complaint)
(dwarf2_invalid_attrib_class_complaint)
(create_addrmap_from_index, dw2_symtab_iter_next)
(dw2_expand_marked_cus)
(dw2_debug_names_iterator::find_vec_in_debug_names)
(dw2_debug_names_iterator::next, dw2_debug_names_iterator::next)
(create_debug_type_hash_table, init_cutu_and_read_dies)
(partial_die_parent_scope, add_partial_enumeration)
(skip_one_die, fixup_go_packaging, quirk_rust_enum, process_die)
(dwarf2_compute_name, dwarf2_physname, read_namespace_alias)
(read_import_statement, read_file_scope, create_dwo_cu_reader)
(create_cus_hash_table, create_dwp_hash_table)
(inherit_abstract_dies, read_func_scope, read_call_site_scope)
(dwarf2_rnglists_process, dwarf2_ranges_process)
(dwarf2_add_type_defn, dwarf2_attach_fields_to_type)
(dwarf2_add_member_fn, get_alignment, maybe_set_alignment)
(handle_struct_member_die, process_structure_scope)
(read_array_type, read_common_block, read_module_type)
(read_tag_pointer_type, read_typedef, read_base_type)
(read_subrange_type, load_partial_dies, partial_die_info::read)
(partial_die_info::read, partial_die_info::read)
(partial_die_info::read, read_checked_initial_length_and_offset)
(dwarf2_string_attr, read_formatted_entries)
(dwarf_decode_line_header)
(lnp_state_machine::check_line_address, dwarf_decode_lines_1)
(new_symbol, dwarf2_const_value_attr, lookup_die_type)
(read_type_die_1, determine_prefix, dwarf2_get_ref_die_offset)
(dwarf2_get_attr_constant_value, dwarf2_fetch_constant_bytes)
(get_signatured_type, get_DW_AT_signature_type)
(decode_locdesc, file_file_name, consume_improper_spaces)
(skip_form_bytes, skip_unknown_opcode, dwarf_parse_macro_header)
(dwarf_decode_macro_bytes, dwarf_decode_macros)
(dwarf2_symbol_mark_computed, set_die_type)
(read_attribute_value): Update.
* stap-probe.c (handle_stap_probe, get_stap_base_address):
Update.
* dbxread.c (unknown_symtype_complaint)
(lbrac_mismatch_complaint, repeated_header_complaint)
(set_namestring, function_outside_compilation_unit_complaint)
(read_dbx_symtab, process_one_symbol): Update.
* gdbtypes.c (stub_noname_complaint): Update.
* windows-nat.c (handle_unload_dll): Update.
* coffread.c (coff_symtab_read, enter_linenos, decode_type)
(decode_base_type): Update.
* xcoffread.c (bf_notfound_complaint, ef_complaint)
(eb_complaint, record_include_begin, record_include_end)
(enter_line_range, xcoff_next_symbol_text, read_xcoff_symtab)
(process_xcoff_symbol, read_symbol)
(function_outside_compilation_unit_complaint)
(scan_xcoff_symtab): Update.
* machoread.c (macho_symtab_read, macho_add_oso_symfile): Update.
* buildsym.c (finish_block_internal, make_blockvector)
(end_symtab_get_static_block, augment_type_symtab): Update.
* dtrace-probe.c (dtrace_process_dof)
(dtrace_static_probe_ops::get_probes): Update.
* complaints.h (struct complaint): Don't declare.
(symfile_complaints): Remove.
(complaint_internal): Remove "complaints" parameter.
(complaint): Likewise.
(clear_complaints): Likewise.
* symfile.c (syms_from_objfile_1, finish_new_objfile)
(reread_symbols): Update.
* dwarf2-frame.c (dwarf2_restore_rule, execute_cfa_program)
(dwarf2_frame_cache, decode_frame_entry): Update.
* dwarf2loc.c (dwarf_reg_to_regnum): Update.
* objc-lang.c (lookup_objc_class, lookup_child_selector)
(info_selectors_command): Update.
* macrotab.c (macro_include, check_for_redefinition)
(macro_undef): Update.
* objfiles.c (filter_overlapping_sections): Update.
* stabsread.c (invalid_cpp_abbrev_complaint)
(reg_value_complaint, stabs_general_complaint, dbx_lookup_type)
(define_symbol, error_type, read_type, rs6000_builtin_type)
(stabs_method_name_from_physname, read_member_functions)
(read_cpp_abbrev, read_baseclasses, read_tilde_fields)
(attach_fields_to_type, complain_about_struct_wipeout)
(read_range_type, read_args, common_block_start)
(common_block_end, cleanup_undefined_types_1, scan_file_globals):
Update.
* mdebugread.c (index_complaint, unknown_ext_complaint)
(basic_type_complaint, bad_tag_guess_complaint)
(bad_rfd_entry_complaint, unexpected_type_code_complaint)
(reg_value_complaint, parse_symbol, parse_type, upgrade_type)
(parse_procedure, parse_lines)
(function_outside_compilation_unit_complaint)
(parse_partial_symbols, psymtab_to_symtab_1, cross_ref)
(bad_tag_guess_complaint, reg_value_complaint): Update.
* cp-support.c (demangled_name_complaint): Update.
* macroscope.c (sal_macro_scope): Update.
* dwarf-index-write.c (class debug_names): Update.
gdb/testsuite/ChangeLog
2018-05-23 Tom Tromey <tom@tromey.com>
* gdb.gdb/complaints.exp (test_initial_complaints): Don't mention
symfile_complaints.
(test_short_complaints): Likewise.
(test_empty_complaints): Likewise.
(test_initial_complaints): Update.
2018-05-17 12:54:44 +08:00
|
|
|
|
complaint (_("could not obtain base address for "
|
2012-04-28 04:47:57 +08:00
|
|
|
|
"SystemTap section on objfile `%s'."),
|
|
|
|
|
obfd->filename);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-24 06:48:08 +08:00
|
|
|
|
if (base != NULL)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
*base = ret->vma;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
/* Implementation of the 'is_linespec' method. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
bool
|
|
|
|
|
stap_static_probe_ops::is_linespec (const char **linespecp) const
|
|
|
|
|
{
|
|
|
|
|
static const char *const keywords[] = { "-pstap", "-probe-stap", NULL };
|
|
|
|
|
|
|
|
|
|
return probe_is_linespec_by_keyword (linespecp, keywords);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implementation of the 'get_probes' method. */
|
|
|
|
|
|
|
|
|
|
void
|
2019-05-01 13:47:54 +08:00
|
|
|
|
stap_static_probe_ops::get_probes
|
|
|
|
|
(std::vector<std::unique_ptr<probe>> *probesp,
|
|
|
|
|
struct objfile *objfile) const
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
/* If we are here, then this is the first time we are parsing the
|
|
|
|
|
SystemTap probe's information. We basically have to count how many
|
|
|
|
|
probes the objfile has, and then fill in the necessary information
|
|
|
|
|
for each one. */
|
|
|
|
|
bfd *obfd = objfile->obfd;
|
|
|
|
|
bfd_vma base;
|
|
|
|
|
struct sdt_note *iter;
|
2017-09-12 19:37:00 +08:00
|
|
|
|
unsigned save_probesp_len = probesp->size ();
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
2012-05-08 09:35:35 +08:00
|
|
|
|
if (objfile->separate_debug_objfile_backlink != NULL)
|
|
|
|
|
{
|
|
|
|
|
/* This is a .debug file, not the objfile itself. */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-24 06:48:08 +08:00
|
|
|
|
if (elf_tdata (obfd)->sdt_note_head == NULL)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
/* There isn't any probe here. */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!get_stap_base_address (obfd, &base))
|
|
|
|
|
{
|
|
|
|
|
/* There was an error finding the base address for the section.
|
|
|
|
|
Just return NULL. */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Parsing each probe's information. */
|
2013-12-24 06:48:08 +08:00
|
|
|
|
for (iter = elf_tdata (obfd)->sdt_note_head;
|
|
|
|
|
iter != NULL;
|
|
|
|
|
iter = iter->next)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
/* We first have to handle all the information about the
|
|
|
|
|
probe which is present in the section. */
|
|
|
|
|
handle_stap_probe (objfile, iter, probesp, base);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-12 19:37:00 +08:00
|
|
|
|
if (save_probesp_len == probesp->size ())
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
|
|
|
|
/* If we are here, it means we have failed to parse every known
|
|
|
|
|
probe. */
|
2019-05-17 04:20:39 +08:00
|
|
|
|
complaint (_("could not parse SystemTap probe(s) from inferior"));
|
2012-04-28 04:47:57 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-17 22:49:12 +08:00
|
|
|
|
/* Implementation of the type_name method. */
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
const char *
|
|
|
|
|
stap_static_probe_ops::type_name () const
|
2015-02-17 22:49:12 +08:00
|
|
|
|
{
|
|
|
|
|
return "stap";
|
|
|
|
|
}
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
/* Implementation of the 'gen_info_probes_table_header' method. */
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
std::vector<struct info_probe_column>
|
|
|
|
|
stap_static_probe_ops::gen_info_probes_table_header () const
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
struct info_probe_column stap_probe_column;
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
stap_probe_column.field_name = "semaphore";
|
|
|
|
|
stap_probe_column.print_name = _("Semaphore");
|
|
|
|
|
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
return std::vector<struct info_probe_column> { stap_probe_column };
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Implementation of the `info probes stap' command. */
|
|
|
|
|
|
|
|
|
|
static void
|
2017-09-13 11:13:21 +08:00
|
|
|
|
info_probes_stap_command (const char *arg, int from_tty)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
info_probes_for_spops (arg, from_tty, &stap_static_probe_ops);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_initialize_stap_probe (void)
|
|
|
|
|
{
|
Convert SystemTap probe interface to C++ (and perform some cleanups)
This patch converts the SystemTap probe
interface (gdb/stap-probe.[ch]) to C++, and also performs some
cleanups that were on my TODO list for a while.
The main changes were the conversion of 'struct stap_probe' to 'class
stap_probe', and a new 'class stap_static_probe_ops' to replace the
use of 'stap_probe_ops'. Both classes implement the virtual methods
exported by their parents, 'class probe' and 'class static_probe_ops',
respectively. I believe it's now a bit simpler to understand the
logic behind the stap-probe interface.
There are several helper functions used to parse parts of a stap
probe, and since they are generic and don't need to know about the
probe they're working on, I decided to leave them as simple static
functions (instead of e.g. converting them to class methods).
I've also converted a few uses of "VEC" to "std::vector", which makes
the code simpler and easier to maintain. And, as usual, some cleanups
here and there.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simark@simark.ca>
* stap-probe.c (struct probe_ops stap_probe_ops): Delete
variable.
(struct stap_probe_arg) <stap_probe_arg>: New constructor.
<aexpr>: Change type to 'expression_up'.
(stap_probe_arg_s): Delete type and VEC.
(struct stap_probe): Delete. Replace by...
(class stap_static_probe_ops): ...this and...
(class stap_probe): ...this. Rename variables to add 'm_'
prefix. Do not use 'union' for arguments anymore.
(stap_get_expected_argument_type): Receive probe name instead
of 'struct stap_probe'. Adjust code.
(stap_parse_probe_arguments): Rename to...
(stap_probe::parse_arguments): ...this. Adjust code to
reflect change.
(stap_get_probe_address): Rename to...
(stap_probe::get_relocated_address): ...this. Adjust code
to reflect change.
(stap_get_probe_argument_count): Rename to...
(stap_probe::get_argument_count): ...this. Adjust code
to reflect change.
(stap_get_arg): Rename to...
(stap_probe::get_arg_by_number'): ...this. Adjust code to
reflect change.
(can_evaluate_probe_arguments): Rename to...
(stap_probe::can_evaluate_arguments): ...this. Adjust code
to reflect change.
(stap_evaluate_probe_argument): Rename to...
(stap_probe::evaluate_argument): ...this. Adjust code
to reflect change.
(stap_compile_to_ax): Rename to...
(stap_probe::compile_to_ax): ...this. Adjust code to
reflect change.
(stap_probe_destroy): Delete.
(stap_modify_semaphore): Adjust comment.
(stap_set_semaphore): Rename to...
(stap_probe::set_semaphore): ...this. Adjust code to reflect
change.
(stap_clear_semaphore): Rename to...
(stap_probe::clear_semaphore): ...this. Adjust code to
reflect change.
(stap_probe::get_static_ops): New method.
(handle_stap_probe): Adjust code to create instance of
'stap_probe'.
(stap_get_probes): Rename to...
(stap_static_probe_ops::get_probes): ...this. Adjust code to
reflect change.
(stap_probe_is_linespec): Rename to...
(stap_static_probe_ops::is_linespec): ...this. Adjust code to
reflect change.
(stap_type_name): Rename to...
(stap_static_probe_ops::type_name): ...this. Adjust code to
reflect change.
(stap_gen_info_probes_table_header): Rename to...
(stap_static_probe_ops::gen_info_probes_table_header):
...this. Adjust code to reflect change.
(stap_gen_info_probes_table_values): Rename to...
(stap_probe::gen_info_probes_table_values): ...this. Adjust
code to reflect change.
(struct probe_ops stap_probe_ops): Delete.
(info_probes_stap_command): Use 'info_probes_for_spops'
instead of 'info_probes_for_ops'.
(_initialize_stap_probe): Use 'all_static_probe_ops' instead
of 'all_probe_ops'.
2017-11-13 14:05:57 +08:00
|
|
|
|
all_static_probe_ops.push_back (&stap_static_probe_ops);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
2012-08-02 17:36:40 +08:00
|
|
|
|
add_setshow_zuinteger_cmd ("stap-expression", class_maintenance,
|
|
|
|
|
&stap_expression_debug,
|
|
|
|
|
_("Set SystemTap expression debugging."),
|
|
|
|
|
_("Show SystemTap expression debugging."),
|
|
|
|
|
_("When non-zero, the internal representation "
|
|
|
|
|
"of SystemTap expressions will be printed."),
|
|
|
|
|
NULL,
|
|
|
|
|
show_stapexpressiondebug,
|
|
|
|
|
&setdebuglist, &showdebuglist);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
|
|
|
|
|
add_cmd ("stap", class_info, info_probes_stap_command,
|
|
|
|
|
_("\
|
|
|
|
|
Show information about SystemTap static probes.\n\
|
|
|
|
|
Usage: info probes stap [PROVIDER [NAME [OBJECT]]]\n\
|
|
|
|
|
Each argument is a regular expression, used to select probes.\n\
|
|
|
|
|
PROVIDER matches probe provider names.\n\
|
|
|
|
|
NAME matches the probe names.\n\
|
|
|
|
|
OBJECT matches the executable or shared library name."),
|
|
|
|
|
info_probes_cmdlist_get ());
|
|
|
|
|
|
|
|
|
|
}
|