X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fstap-probe.c;h=50f6d518133a3f7e47ee46f7b2df20d287e52fbe;hb=2f4fcf00399bc0ad5a4fed6b530128e8be4f40da;hp=aa1c8144d8a0b43c902fdb36d74659375366033f;hpb=7d7571f0c14b4673ca95f6dc31d6f07d429e6697;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index aa1c8144d8..50f6d51813 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -1,6 +1,6 @@ /* SystemTap probe support for GDB. - Copyright (C) 2012-2019 Free Software Foundation, Inc. + Copyright (C) 2012-2020 Free Software Foundation, Inc. This file is part of GDB. @@ -20,7 +20,6 @@ #include "defs.h" #include "stap-probe.h" #include "probe.h" -#include "common/vec.h" #include "ui-out.h" #include "objfiles.h" #include "arch-utils.h" @@ -102,6 +101,12 @@ struct stap_probe_arg class stap_static_probe_ops : public static_probe_ops { public: + /* We need a user-provided constructor to placate some compilers. + See PR build/24937. */ + stap_static_probe_ops () + { + } + /* See probe.h. */ bool is_linespec (const char **linespecp) const override; @@ -136,7 +141,7 @@ public: CORE_ADDR get_relocated_address (struct objfile *objfile) override; /* See probe.h. */ - unsigned get_argument_count (struct frame_info *frame) override; + unsigned get_argument_count (struct gdbarch *gdbarch) override; /* See probe.h. */ bool can_evaluate_arguments () const override; @@ -774,23 +779,24 @@ stap_parse_register_operand (struct stap_parse_info *p) code would like to perform on the register name. */ if (gdbarch_stap_adjust_register_p (gdbarch)) { - std::string oldregname = regname; + std::string newregname + = gdbarch_stap_adjust_register (gdbarch, p, regname, regnum); - gdbarch_stap_adjust_register (gdbarch, p, regname, regnum); - - if (regname != oldregname) + if (regname != newregname) { /* This is just a check we perform to make sure that the arch-dependent code has provided us with a valid register name. */ - regnum = user_reg_map_name_to_regnum (gdbarch, regname.c_str (), - regname.size ()); + regnum = user_reg_map_name_to_regnum (gdbarch, newregname.c_str (), + newregname.size ()); if (regnum == -1) internal_error (__FILE__, __LINE__, _("Invalid register name '%s' after replacing it" " (previous name was '%s')"), - regname.c_str (), oldregname.c_str ()); + newregname.c_str (), regname.c_str ()); + + regname = newregname; } } @@ -1284,8 +1290,7 @@ stap_probe::parse_arguments (struct gdbarch *gdbarch) static CORE_ADDR relocate_address (CORE_ADDR address, struct objfile *objfile) { - return address + ANOFFSET (objfile->section_offsets, - SECT_OFF_DATA (objfile)); + return address + objfile->section_offsets[SECT_OFF_DATA (objfile)]; } /* Implementation of the get_relocated_address method. */ @@ -1300,10 +1305,8 @@ stap_probe::get_relocated_address (struct objfile *objfile) argument string. */ unsigned -stap_probe::get_argument_count (struct frame_info *frame) +stap_probe::get_argument_count (struct gdbarch *gdbarch) { - struct gdbarch *gdbarch = get_frame_arch (frame); - if (!m_have_parsed_args) { if (this->can_evaluate_arguments ()) @@ -1427,9 +1430,6 @@ stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch) 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) { @@ -1437,8 +1437,8 @@ stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch) return; } - value = extract_unsigned_integer (bytes, TYPE_LENGTH (type), - gdbarch_byte_order (gdbarch)); + enum bfd_endian byte_order = type_byte_order (type); + value = extract_unsigned_integer (bytes, TYPE_LENGTH (type), byte_order); /* Note that we explicitly don't worry about overflow or underflow. */ if (set) @@ -1446,8 +1446,7 @@ stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch) else --value; - store_unsigned_integer (bytes, TYPE_LENGTH (type), - gdbarch_byte_order (gdbarch), value); + store_unsigned_integer (bytes, TYPE_LENGTH (type), byte_order, value); if (target_write_memory (address, bytes, TYPE_LENGTH (type)) != 0) warning (_("Could not write the value of a SystemTap semaphore.")); @@ -1464,6 +1463,8 @@ stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch) void stap_probe::set_semaphore (struct objfile *objfile, struct gdbarch *gdbarch) { + if (m_sem_addr == 0) + return; stap_modify_semaphore (relocate_address (m_sem_addr, objfile), 1, gdbarch); } @@ -1472,6 +1473,8 @@ stap_probe::set_semaphore (struct objfile *objfile, struct gdbarch *gdbarch) void stap_probe::clear_semaphore (struct objfile *objfile, struct gdbarch *gdbarch) { + if (m_sem_addr == 0) + return; stap_modify_semaphore (relocate_address (m_sem_addr, objfile), 0, gdbarch); }