2012-04-28 04:47:57 +08:00
|
|
|
|
/* SystemTap probe support for GDB.
|
|
|
|
|
|
2018-01-01 12:43:02 +08:00
|
|
|
|
Copyright (C) 2012-2018 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"
|
|
|
|
|
#include "vec.h"
|
|
|
|
|
#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. */
|
|
|
|
|
void get_probes (std::vector<probe *> *probesp,
|
|
|
|
|
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. */
|
|
|
|
|
|
|
|
|
|
const stap_static_probe_ops stap_static_probe_ops;
|
|
|
|
|
|
|
|
|
|
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. */
|
|
|
|
|
unsigned get_argument_count (struct frame_info *frame) override;
|
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void stap_parse_argument_1 (struct stap_parse_info *p, int has_lhs,
|
|
|
|
|
enum stap_operand_prec prec);
|
|
|
|
|
|
|
|
|
|
static void stap_parse_argument_conditionally (struct stap_parse_info *p);
|
|
|
|
|
|
|
|
|
|
/* Returns 1 if *S is an operator, zero otherwise. */
|
|
|
|
|
|
2012-05-04 04:04:06 +08:00
|
|
|
|
static int 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Given S, read the operator in it and fills the OP pointer with its code.
|
|
|
|
|
Return 1 on success, zero if the operator was not recognized. */
|
|
|
|
|
|
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
|
|
|
|
|
corresponding `struct type *'. */
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
Return 1 if any prefix has been found, zero otherwise. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
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 = "";
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2013-12-24 06:48:08 +08:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return 1 if S points to a register prefix, zero otherwise. For a
|
|
|
|
|
description of the arguments, look at stap_is_generic_prefix. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return 1 if S points to a register indirection prefix, zero
|
|
|
|
|
otherwise. For a description of the arguments, look at
|
|
|
|
|
stap_is_generic_prefix. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return 1 if S points to an integer prefix, zero otherwise. For a
|
|
|
|
|
description of the arguments, look at stap_is_generic_prefix.
|
|
|
|
|
|
|
|
|
|
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. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
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 = "";
|
|
|
|
|
|
|
|
|
|
return isdigit (*s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
expecting at least one suffix, then it returns 1 if a suffix has
|
|
|
|
|
been found, zero otherwise. 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 suffix. SUFFIXES is the list of
|
|
|
|
|
expected suffixes. This function does a case-insensitive
|
|
|
|
|
match. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
stap_generic_check_suffix (struct gdbarch *gdbarch, const char *s,
|
|
|
|
|
const char **r, const char *const *suffixes)
|
|
|
|
|
{
|
|
|
|
|
const char *const *p;
|
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
|
|
if (suffixes == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (r != NULL)
|
|
|
|
|
*r = "";
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (p = suffixes; *p != NULL; ++p)
|
|
|
|
|
if (strncasecmp (s, *p, strlen (*p)) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (r != NULL)
|
|
|
|
|
*r = *p;
|
|
|
|
|
|
|
|
|
|
found = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return 1 if S points to an integer suffix, zero otherwise. For a
|
|
|
|
|
description of the arguments, look at
|
|
|
|
|
stap_generic_check_suffix. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return 1 if S points to a register suffix, zero otherwise. For a
|
|
|
|
|
description of the arguments, look at
|
|
|
|
|
stap_generic_check_suffix. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return 1 if S points to a register indirection suffix, zero
|
|
|
|
|
otherwise. For a description of the arguments, look at
|
|
|
|
|
stap_generic_check_suffix. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
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. */
|
|
|
|
|
int got_minus = 0;
|
|
|
|
|
/* Flags to indicate whether this register access is being displaced and/or
|
|
|
|
|
indirected. */
|
|
|
|
|
int disp_p = 0, indirect_p = 0;
|
|
|
|
|
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;
|
|
|
|
|
char *regname;
|
|
|
|
|
int len;
|
|
|
|
|
const char *gdb_reg_prefix = gdbarch_stap_gdb_register_prefix (gdbarch);
|
|
|
|
|
int gdb_reg_prefix_len = gdb_reg_prefix ? strlen (gdb_reg_prefix) : 0;
|
|
|
|
|
const char *gdb_reg_suffix = gdbarch_stap_gdb_register_suffix (gdbarch);
|
|
|
|
|
int gdb_reg_suffix_len = gdb_reg_suffix ? strlen (gdb_reg_suffix) : 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
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*p->arg == '-')
|
|
|
|
|
{
|
|
|
|
|
got_minus = 1;
|
|
|
|
|
++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
|
|
|
|
|
|
|
|
|
disp_p = 1;
|
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
|
|
|
|
{
|
|
|
|
|
indirect_p = 1;
|
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;
|
|
|
|
|
|
|
|
|
|
len = p->arg - start;
|
|
|
|
|
|
2015-09-26 02:08:06 +08:00
|
|
|
|
regname = (char *) alloca (len + gdb_reg_prefix_len + gdb_reg_suffix_len + 1);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
regname[0] = '\0';
|
|
|
|
|
|
|
|
|
|
/* We only add the GDB's register prefix/suffix if we are dealing with
|
|
|
|
|
a numeric register. */
|
|
|
|
|
if (gdb_reg_prefix && isdigit (*start))
|
|
|
|
|
{
|
|
|
|
|
strncpy (regname, gdb_reg_prefix, gdb_reg_prefix_len);
|
|
|
|
|
strncpy (regname + gdb_reg_prefix_len, start, len);
|
|
|
|
|
|
|
|
|
|
if (gdb_reg_suffix)
|
|
|
|
|
strncpy (regname + gdb_reg_prefix_len + len,
|
|
|
|
|
gdb_reg_suffix, gdb_reg_suffix_len);
|
|
|
|
|
|
|
|
|
|
len += gdb_reg_prefix_len + gdb_reg_suffix_len;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
strncpy (regname, start, len);
|
|
|
|
|
|
|
|
|
|
regname[len] = '\0';
|
|
|
|
|
|
|
|
|
|
/* Is this a valid register name? */
|
|
|
|
|
if (user_reg_map_name_to_regnum (gdbarch, regname, len) == -1)
|
|
|
|
|
error (_("Invalid register name `%s' on expression `%s'."),
|
|
|
|
|
regname, p->saved_arg);
|
|
|
|
|
|
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);
|
2012-04-28 04:47:57 +08:00
|
|
|
|
str.ptr = regname;
|
|
|
|
|
str.length = len;
|
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". */
|
|
|
|
|
if (gdbarch_stap_parse_special_token_p (gdbarch))
|
2013-12-24 06:48:08 +08:00
|
|
|
|
if (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
|
|
|
|
|
2013-12-24 06:48:08 +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;
|
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
|
|
|
|
int has_digit = 0;
|
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;
|
|
|
|
|
has_digit = 1;
|
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 `+'. */
|
|
|
|
|
if (c == '~')
|
|
|
|
|
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
|
|
|
|
|
stap_parse_argument_1 (struct stap_parse_info *p, int has_lhs,
|
|
|
|
|
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. */
|
2017-11-23 12:45:53 +08:00
|
|
|
|
struct stap_parse_info p (*arg, atype, 10, language_def (language_c),
|
|
|
|
|
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
|
|
|
|
|
stap_probe::get_argument_count (struct frame_info *frame)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
2013-12-11 09:53:25 +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
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
static int have_warned_stap_incomplete = 0;
|
|
|
|
|
|
|
|
|
|
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."));
|
|
|
|
|
have_warned_stap_incomplete = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return 1 if OP is a valid operator inside a probe argument, or zero
|
|
|
|
|
otherwise. */
|
|
|
|
|
|
|
|
|
|
static int
|
2012-05-04 04:04:06 +08:00
|
|
|
|
stap_is_operator (const char *op)
|
2012-04-28 04:47:57 +08:00
|
|
|
|
{
|
2012-05-04 04:04:06 +08:00
|
|
|
|
int ret = 1;
|
|
|
|
|
|
|
|
|
|
switch (*op)
|
|
|
|
|
{
|
|
|
|
|
case '*':
|
|
|
|
|
case '/':
|
|
|
|
|
case '%':
|
|
|
|
|
case '^':
|
|
|
|
|
case '!':
|
|
|
|
|
case '+':
|
|
|
|
|
case '-':
|
|
|
|
|
case '<':
|
|
|
|
|
case '>':
|
|
|
|
|
case '|':
|
|
|
|
|
case '&':
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '=':
|
|
|
|
|
if (op[1] != '=')
|
|
|
|
|
ret = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
/* We didn't find any operator. */
|
|
|
|
|
ret = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
- Probe's argument format
|
|
|
|
|
|
|
|
|
|
This function returns 1 if the handling was successful, and zero
|
|
|
|
|
otherwise. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
|
2017-09-12 19:37:00 +08:00
|
|
|
|
std::vector<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
|
|
|
|
{
|
|
|
|
|
complaint (&symfile_complaints, _("corrupt probe name when "
|
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
|
|
|
|
"reading `%s'"),
|
|
|
|
|
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
|
|
|
|
|
returning zero here makes sense. */
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
complaint (&symfile_complaints, _("corrupt probe argument when "
|
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
|
|
|
|
"reading `%s'"),
|
|
|
|
|
objfile_name (objfile));
|
2012-04-28 04:47:57 +08:00
|
|
|
|
/* If the argument string is NULL, it means some problem happened with
|
|
|
|
|
it. So we return 0. */
|
|
|
|
|
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. */
|
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
|
|
|
|
probesp->push_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
|
|
|
|
{
|
|
|
|
|
complaint (&symfile_complaints, _("could not obtain base address for "
|
|
|
|
|
"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
|
|
|
|
|
stap_static_probe_ops::get_probes (std::vector<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. */
|
|
|
|
|
complaint (&symfile_complaints, _("could not parse SystemTap probe(s) "
|
|
|
|
|
"from inferior"));
|
|
|
|
|
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 ());
|
|
|
|
|
|
|
|
|
|
}
|