binutils-gdb/gdb/gdbarch.h

1886 lines
101 KiB
C
Raw Normal View History

gdb/ * copying.awk: Print buffer-read-only and vi ro markers. * copying.c: Rebuild. * gdbarch.sh (copyright): Print buffer-read-only and vi ro markers. * gdbarch.c, gdbarch.h: Rebuild. * target-descriptions.c (maint_print_c_tdesc_cmd): Print buffer-read-only and vi ro markers. * features/arm-with-iwmmxt.c: Rebuild. * features/arm-with-m-fpa-layout.c: Rebuild. * features/arm-with-m-vfp-d16.c: Rebuild. * features/arm-with-m.c: Rebuild. * features/arm-with-neon.c: Rebuild. * features/arm-with-vfpv2.c: Rebuild. * features/arm-with-vfpv3.c: Rebuild. * features/i386/amd64-avx-linux.c: Rebuild. * features/i386/amd64-avx.c: Rebuild. * features/i386/amd64-linux.c: Rebuild. * features/i386/amd64.c: Rebuild. * features/i386/i386-avx-linux.c: Rebuild. * features/i386/i386-avx.c: Rebuild. * features/i386/i386-linux.c: Rebuild. * features/i386/i386-mmx-linux.c: Rebuild. * features/i386/i386-mmx.c: Rebuild. * features/i386/i386.c: Rebuild. * features/i386/x32-avx-linux.c: Rebuild. * features/i386/x32-avx.c: Rebuild. * features/i386/x32-linux.c: Rebuild. * features/i386/x32.c: Rebuild. * features/mips-dsp-linux.c: Rebuild. * features/mips-linux.c: Rebuild. * features/mips64-dsp-linux.c: Rebuild. * features/mips64-linux.c: Rebuild. * features/rs6000/powerpc-32.c: Rebuild. * features/rs6000/powerpc-32l.c: Rebuild. * features/rs6000/powerpc-403.c: Rebuild. * features/rs6000/powerpc-403gc.c: Rebuild. * features/rs6000/powerpc-405.c: Rebuild. * features/rs6000/powerpc-505.c: Rebuild. * features/rs6000/powerpc-601.c: Rebuild. * features/rs6000/powerpc-602.c: Rebuild. * features/rs6000/powerpc-603.c: Rebuild. * features/rs6000/powerpc-604.c: Rebuild. * features/rs6000/powerpc-64.c: Rebuild. * features/rs6000/powerpc-64l.c: Rebuild. * features/rs6000/powerpc-7400.c: Rebuild. * features/rs6000/powerpc-750.c: Rebuild. * features/rs6000/powerpc-860.c: Rebuild. * features/rs6000/powerpc-altivec32.c: Rebuild. * features/rs6000/powerpc-altivec32l.c: Rebuild. * features/rs6000/powerpc-altivec64.c: Rebuild. * features/rs6000/powerpc-altivec64l.c: Rebuild. * features/rs6000/powerpc-cell32l.c: Rebuild. * features/rs6000/powerpc-cell64l.c: Rebuild. * features/rs6000/powerpc-e500.c: Rebuild. * features/rs6000/powerpc-e500l.c: Rebuild. * features/rs6000/powerpc-isa205-32l.c: Rebuild. * features/rs6000/powerpc-isa205-64l.c: Rebuild. * features/rs6000/powerpc-isa205-altivec32l.c: Rebuild. * features/rs6000/powerpc-isa205-altivec64l.c: Rebuild. * features/rs6000/powerpc-isa205-vsx32l.c: Rebuild. * features/rs6000/powerpc-isa205-vsx64l.c: Rebuild. * features/rs6000/powerpc-vsx32.c: Rebuild. * features/rs6000/powerpc-vsx32l.c: Rebuild. * features/rs6000/powerpc-vsx64.c: Rebuild. * features/rs6000/powerpc-vsx64l.c: Rebuild. * features/rs6000/rs6000.c: Rebuild. * features/s390-linux32.c: Rebuild. * features/s390-linux32v1.c: Rebuild. * features/s390-linux32v2.c: Rebuild. * features/s390-linux64.c: Rebuild. * features/s390-linux64v1.c: Rebuild. * features/s390-linux64v2.c: Rebuild. * features/s390x-linux64.c: Rebuild. * features/s390x-linux64v1.c: Rebuild. * features/s390x-linux64v2.c: Rebuild. * features/tic6x-c62x-linux.c: Rebuild. * features/tic6x-c62x.c: Rebuild. * features/tic6x-c64x-linux.c: Rebuild. * features/tic6x-c64x.c: Rebuild. * features/tic6x-c64xp-linux.c: Rebuild. * features/tic6x-c64xp.c: Rebuild.
2012-07-27 22:23:05 +02:00
/* *INDENT-OFF* */ /* THIS FILE IS GENERATED -*- buffer-read-only: t -*- */
/* vi:set ro: */
2000-03-30 07:32:23 +02:00
1999-07-20 01:30:11 +02:00
/* Dynamic architecture support for GDB, the GNU debugger.
Copyright (C) 1998-2019 Free Software Foundation, Inc.
1999-07-07 22:19:36 +02:00
This file is part of GDB.
1999-07-07 22:19:36 +02:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
1999-07-07 22:19:36 +02:00
(at your option) any later version.
1999-07-07 22:19:36 +02:00
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
1999-07-07 22:19:36 +02:00
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
1999-08-31 03:14:27 +02:00
/* This file was created with the aid of ``gdbarch.sh''.
The Bourne shell script ``gdbarch.sh'' creates the files
1999-08-31 03:14:27 +02:00
``new-gdbarch.c'' and ``new-gdbarch.h and then compares them
against the existing ``gdbarch.[hc]''. Any differences found
being reported.
If editing this file, please also run gdbarch.sh and merge any
changes into that script. Conversely, when making sweeping changes
1999-08-31 03:14:27 +02:00
to this file, modifying gdbarch.sh and using its output may prove
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
easier. */
1999-07-20 01:30:11 +02:00
#ifndef GDBARCH_H
#define GDBARCH_H
Change return type of gdbarch_software_single_step to vector<CORE_ADDR> This is a relatively straightforward patch that changes gdbarch_software_single_step so it returns an std::vector<CORE_ADDR> instead of a VEC (CORE_ADDR). gdb/ChangeLog: * gdbarch.sh (software_single_step): Change return type to std::vector<CORE_ADDR>. * gdbarch.c, gdbarch.h: Re-generate. * arch/arm-get-next-pcs.c (thumb_deal_with_atomic_sequence_raw): Adjust. (arm_deal_with_atomic_sequence_raw): Adjust. (thumb_get_next_pcs_raw): Adjust. (arm_get_next_pcs_raw): Adjust. (arm_get_next_pcs): Adjust. * arch/arm-get-next-pcs.h (arm_get_next_pcs): Adjust. * aarch64-tdep.c (aarch64_software_single_step): Adjust. * alpha-tdep.c (alpha_deal_with_atomic_sequence): Adjust. (alpha_software_single_step): Adjust. * alpha-tdep.h (alpha_software_single_step): Adjust. * arm-linux-tdep.c (arm_linux_software_single_step): Adjust. * arm-tdep.c (arm_software_single_step): Adjust. (arm_breakpoint_kind_from_current_state): Adjust. * arm-tdep.h (arm_software_single_step): Adjust. * breakpoint.c (insert_single_step_breakpoint): Adjust. * cris-tdep.c (cris_software_single_step): Adjust. * mips-tdep.c (mips_deal_with_atomic_sequence): Adjust. (micromips_deal_with_atomic_sequence): Adjust. (deal_with_atomic_sequence): Adjust. (mips_software_single_step): Adjust. * mips-tdep.h (mips_software_single_step): Adjust. * moxie-tdep.c (moxie_software_single_step): Adjust. * nios2-tdep.c (nios2_software_single_step): Adjust. * ppc-tdep.h (ppc_deal_with_atomic_sequence): Adjust. * rs6000-aix-tdep.c (rs6000_software_single_step): Adjust. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust. * s390-linux-tdep.c (s390_software_single_step): Adjust. * sparc-tdep.c (sparc_software_single_step): Adjust. * spu-tdep.c (spu_software_single_step): Adjust. * tic6x-tdep.c (tic6x_software_single_step): Adjust. gdb/gdbserver/ChangeLog: * linux-arm-low.c (arm_gdbserver_get_next_pcs): Adjust to software_single_step change of return type to std::vector<CORE_ADDR>. * linux-low.c (install_software_single_step_breakpoints): Likewise. * linux-low.h (install_software_single_step_breakpoints): Likewise.
2017-05-02 19:30:07 +02:00
#include <vector>
#include "frame.h"
GDB: Add support for the new set/show disassembler-options commands. This commit adds support to GDB so that it can modify the disassembler-options value that is passed to the disassembler, similar to objdump's -M option. Currently, the only supported targets are ARM, PowerPC and S/390, but adding support for a new target(s) is not difficult. include/ * dis-asm.h (disasm_options_t): New typedef. (parse_arm_disassembler_option): Remove prototype. (set_arm_regname_option): Likewise. (get_arm_regnames): Likewise. (get_arm_regname_num_options): Likewise. (disassemble_init_s390): New prototype. (disassembler_options_powerpc): Likewise. (disassembler_options_arm): Likewise. (disassembler_options_s390): Likewise. (remove_whitespace_and_extra_commas): Likewise. (disassembler_options_cmp): Likewise. (next_disassembler_option): New inline function. (FOR_EACH_DISASSEMBLER_OPTION): New macro. opcodes/ * disassemble.c Include "safe-ctype.h". (disassemble_init_for_target): Handle s390 init. (remove_whitespace_and_extra_commas): New function. (disassembler_options_cmp): Likewise. * arm-dis.c: Include "libiberty.h". (NUM_ELEM): Delete. (regnames): Use long disassembler style names. Add force-thumb and no-force-thumb options. (NUM_ARM_REGNAMES): Rename from this... (NUM_ARM_OPTIONS): ...to this. Use ARRAY_SIZE. (get_arm_regname_num_options): Delete. (set_arm_regname_option): Likewise. (get_arm_regnames): Likewise. (parse_disassembler_options): Likewise. (parse_arm_disassembler_option): Rename from this... (parse_arm_disassembler_options): ...to this. Make static. Use new FOR_EACH_DISASSEMBLER_OPTION macro to scan over options. (print_insn): Use parse_arm_disassembler_options. (disassembler_options_arm): New function. (print_arm_disassembler_options): Handle updated regnames. * ppc-dis.c: Include "libiberty.h". (ppc_opts): Add "32" and "64" entries. (ppc_parse_cpu): Use ARRAY_SIZE and disassembler_options_cmp. (powerpc_init_dialect): Add break to switch statement. Use new FOR_EACH_DISASSEMBLER_OPTION macro. (disassembler_options_powerpc): New function. (print_ppc_disassembler_options): Use ARRAY_SIZE. Remove printing of "32" and "64". * s390-dis.c: Include "libiberty.h". (init_flag): Remove unneeded variable. (struct s390_options_t): New structure type. (options): New structure. (init_disasm): Rename from this... (disassemble_init_s390): ...to this. Add initializations for current_arch_mask and option_use_insn_len_bits_p. Remove init_flag. (print_insn_s390): Delete call to init_disasm. (disassembler_options_s390): New function. (print_s390_disassembler_options): Print using information from struct 'options'. * po/opcodes.pot: Regenerate. binutils/ * objdump.c (main): Use remove_whitespace_and_extra_commas. gdb/ * NEWS: Mention new set/show disassembler-options commands. * doc/gdb.texinfo: Document new set/show disassembler-options commands. * disasm.c: Include "arch-utils.h", "gdbcmd.h" and "safe-ctype.h". (prospective_options): New static variable. (gdb_disassembler::gdb_disassembler): Initialize m_di.disassembler_options. (gdb_buffered_insn_length_init_dis): Initilize di->disassembler_options. (get_disassembler_options): New function. (set_disassembler_options): Likewise. (set_disassembler_options_sfunc): Likewise. (show_disassembler_options_sfunc): Likewise. (disassembler_options_completer): Likewise. (_initialize_disasm): Likewise. * disasm.h (get_disassembler_options): New prototype. (set_disassembler_options): Likewise. * gdbarch.sh (gdbarch_disassembler_options): New variable. (gdbarch_verify_disassembler_options): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * arm-tdep.c (num_disassembly_options): Delete. (set_disassembly_style): Likewise. (arm_disassembler_options): New static variable. (set_disassembly_style_sfunc): Convert short style name into long option name. Call set_disassembler_options. (show_disassembly_style_sfunc): New function. (arm_gdbarch_init): Call set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. (_initialize_arm_tdep): Delete regnames variable and update callers. (arm_disassembler_options): Initialize. (disasm_options): New variable. (num_disassembly_options): Rename from this... (num_disassembly_styles): ...to this. Compute by scanning through disasm_options. (valid_disassembly_styles): Initialize using disasm_options. Remove calls to parse_arm_disassembler_option, get_arm_regnames and set_arm_regname_option. Pass show_disassembly_style_sfunc to the "disassembler" setshow command. * rs6000-tdep.c (powerpc_disassembler_options): New static variable. (rs6000_gdbarch_init): Call set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. * s390-tdep.c (s390_disassembler_options): New static variable. (s390_gdbarch_init):all set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. gdb/testsuite/ * gdb.arch/powerpc-power.exp: Delete test. * gdb.arch/powerpc-power.s: Likewise. * gdb.disasm/disassembler-options.exp: New test. * gdb.arch/powerpc-altivec.exp: Likewise. * gdb.arch/powerpc-altivec.s: Likewise. * gdb.arch/powerpc-altivec2.exp: Likewise. * gdb.arch/powerpc-altivec2.s: Likewise. * gdb.arch/powerpc-altivec3.exp: Likewise. * gdb.arch/powerpc-altivec3.s: Likewise. * gdb.arch/powerpc-power7.exp: Likewise. * gdb.arch/powerpc-power7.s: Likewise. * gdb.arch/powerpc-power8.exp: Likewise. * gdb.arch/powerpc-power8.s: Likewise. * gdb.arch/powerpc-power9.exp: Likewise. * gdb.arch/powerpc-power9.s: Likewise. * gdb.arch/powerpc-vsx.exp: Likewise. * gdb.arch/powerpc-vsx.s: Likewise. * gdb.arch/powerpc-vsx2.exp: Likewise. * gdb.arch/powerpc-vsx2.s: Likewise. * gdb.arch/powerpc-vsx3.exp: Likewise. * gdb.arch/powerpc-vsx3.s: Likewise. * gdb.arch/arm-disassembler-options.exp: Likewise. * gdb.arch/powerpc-disassembler-options.exp: Likewise. * gdb.arch/s390-disassembler-options.exp: Likewise.
2017-02-28 19:32:07 +01:00
#include "dis-asm.h"
Introduce obstack_new, poison other "typed" obstack functions Since we use obstacks with objects that are not default constructible, we sometimes need to manually call the constructor by hand using placement new: foo *f = obstack_alloc (obstack, sizeof (foo)); f = new (f) foo; It's possible to use allocate_on_obstack instead, but there are types that we sometimes want to allocate on an obstack, and sometimes on the regular heap. This patch introduces a utility to make this pattern simpler if allocate_on_obstack is not an option: foo *f = obstack_new<foo> (obstack); Right now there's only one usage (in tdesc_data_init). To help catch places where we would forget to call new when allocating such an object on an obstack, this patch also poisons some other methods of allocating an instance of a type on an obstack: - OBSTACK_ZALLOC/OBSTACK_CALLOC - XOBNEW/XOBNEW - GDBARCH_OBSTACK_ZALLOC/GDBARCH_OBSTACK_CALLOC Unfortunately, there's no way to catch wrong usages of obstack_alloc. By pulling on that string though, it tripped on allocating struct template_symbol using OBSTACK_ZALLOC. The criterion currently used to know whether it's safe to "malloc" an instance of a struct is whether it is a POD. Because it inherits from struct symbol, template_symbol is not a POD. This criterion is a bit too strict however, it should still safe to allocate memory for a template_symbol and memset it to 0. We didn't use is_trivially_constructible as the criterion in the first place only because it is not available in gcc < 5. So here I considered two alternatives: 1. Relax that criterion to use std::is_trivially_constructible and add a bit more glue code to make it work with gcc < 5 2. Continue pulling on the string and change how the symbol structures are allocated and initialized I managed to do both, but I decided to go with #1 to keep this patch simpler and more focused. When building with a compiler that does not have is_trivially_constructible, the check will just not be enforced. gdb/ChangeLog: * common/traits.h (HAVE_IS_TRIVIALLY_COPYABLE): Define if compiler supports std::is_trivially_constructible. * common/poison.h: Include obstack.h. (IsMallocable): Define to is_trivially_constructible if the compiler supports it, define to true_type otherwise. (xobnew): New. (XOBNEW): Redefine. (xobnewvec): New. (XOBNEWVEC): Redefine. * gdb_obstack.h (obstack_zalloc): New. (OBSTACK_ZALLOC): Redefine. (obstack_calloc): New. (OBSTACK_CALLOC): Redefine. (obstack_new): New. * gdbarch.sh: Include gdb_obstack in gdbarch.h. (gdbarch_obstack): New declaration in gdbarch.h, definition in gdbarch.c. (GDBARCH_OBSTACK_CALLOC, GDBARCH_OBSTACK_ZALLOC): Use obstack_calloc/obstack_zalloc. (gdbarch_obstack_zalloc): Remove. * target-descriptions.c (tdesc_data_init): Use obstack_new.
2018-05-21 03:06:03 +02:00
#include "gdb_obstack.h"
struct floatformat;
struct ui_file;
1999-06-07 21:19:32 +02:00
struct value;
struct objfile;
struct obj_section;
struct minimal_symbol;
struct regcache;
struct reggroup;
struct regset;
2003-09-04 Andrew Cagney <cagney@redhat.com> * avr-tdep.c: Include "dis-asm.h". * cris-tdep.c: Include "dis-asm.h". (cris_delayed_get_disassembler): Use "struct disassemble_info" instead of corresponding typedef. * h8300-tdep.c: Include "dis-asm.h". * ia64-tdep.c: Include "dis-asm.h". * i386-tdep.c: Include "dis-asm.h". (i386_print_insn): Use "struct disassemble_info" instead of corresponding typedef. * m68k-tdep.c: Include "dis-asm.h". * mcore-tdep.c: Include "dis-asm.h". * mips-tdep.c: Include "dis-asm.h". (gdb_print_insn_mips): Make static, use "struct disassemble_info" instead of corresponding typedef. * ns32k-tdep.c: Include "dis-asm.h". * s390-tdep.c: Include "dis-asm.h". * sparc-tdep.c: Include "dis-asm.h". * vax-tdep.c: Include "dis-asm.h". * v850-tdep.c: Include "dis-asm.h". * mn10300-tdep.c: Include "dis-asm.h". * rs6000-tdep.c: Include "dis-asm.h". * xstormy16-tdep.c: Include "dis-asm.h". (_initialize_xstormy16_tdep): Delete "extern" declaration of print_insn_xstormy16. * Makefile.in (v850-tdep.o): Update dependencies. (vax-tdep.o, sparc-tdep.o, s390-tdep.o): Ditto. (ns32k-tdep.o, mips-tdep.o, mcore-tdep.o): Ditto. (m68k-tdep.o, ia64-tdep.o, i386-tdep.o): Ditto. (h8300-tdep.o, cris-tdep.o, avr-tdep.o): Ditto. (mn10300-tdep.o, xstormy16-tdep.o, disasm.o): Ditto. (gdbarch_h): Remove $(dis_asm_h). * disasm.c: Include "dis-asm.h". (dis_asm_read_memory): Use "struct disassemble_info" instead of corresponding typedef. (dis_asm_memory_error, dump_insns, do_assembly_only): Ditto. (gdb_disassemble_info, gdb_disassembly, gdb_print_insn): Ditto. * gdbarch.sh: Do not include "dis-asm.h". (struct disassemble_info): Declare opaque. (TARGET_PRINT_INSN): Update declaration. * gdbarch.h, gdbarch.c: Re-generate.
2003-09-09 06:41:32 +02:00
struct disassemble_info;
struct target_ops;
2004-03-15 Andrew Cagney <cagney@redhat.com> * gdbarch.sh (gdbarch_data_pre_init_fytpe) (gdbarch_data_register_pre_init, gdbarch_data_post_init_fytpe) (gdbarch_data_register_post_init): Replace gdbarch_data_init_ftype and register_gdbarch_data. (deprecated_set_gdbarch_data): Rename set_gdbarch_data. (struct gdbarch_data): Replace "init" by "pre_init" and "post_init". * gdbarch.h, gdbarch.c: Re-generate. * dwarf2-frame.c (dwarf2_frame_init): Replace "gdbarch" paramter with"obstack", use OBSTACK_ZALLOC. (dwarf2_frame_ops): Delete. (dwarf2_frame_set_init_reg): Use gdbarch_data. (dwarf2_frame_init_reg): Use gdbarch_data. (_initialize_dwarf2_frame): Use gdbarch_data_register_pre_init. * solib-svr4.c (set_solib_svr4_fetch_link_map_offsets) (_initialize_svr4_solib): Update. * user-regs.c (_initialize_user_regs): Update. * reggroups.c (_initialize_reggroup): Update. * regcache.c (_initialize_regcache): Update. * mips-linux-tdep.c (_initialize_mips_linux_tdep): Update. * libunwind-frame.c (_initialize_libunwind_frame): Update. * gnu-v3-abi.c (init_gnuv3_ops): Update. * frame-unwind.c (_initialize_frame_unwind): Update. * frame-base.c (_initialize_frame_base): Update. * user-regs.c (user_reg_add): Update. * reggroups.c (reggroup_add): Update. * mips-linux-tdep.c (set_mips_linux_register_addr): Update. * libunwind-frame.c (libunwind_frame_set_descr): Update. * frame-unwind.c (frame_unwind_append_sniffer): Update. * frame-base.c (frame_base_table): Update. * remote.c (_initialize_remote): Update. * gdb_obstack.h (OBSTACK_ZALLOC, OBSTACK_CALLOC): Define.
2004-03-15 21:38:08 +01:00
struct obstack;
gdb/ * breakpoint.c (deprecated_read_memory_nobpt): Update to use shadow_len. (insert_bp_location, reattach_breakpoints, remove_breakpoint) (delete_breakpoint): Update calls to changed methods. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (single_step_breakpoints, insert_single_step_breakpoint) (remove_single_step_breakpoints): New. * breakpoint.h (struct bp_target_info): New. (struct bp_location): Replace shadow_contents with target_info and overlay_target_info. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (insert_single_step_breakpoint, remove_single_step_breakpoints): New prototypes. * gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h. (memory_insert_breakpoint, memory_remove_breakpoint): Update second argument. * mem-break.c (default_memory_insert_breakpoint): Update. Set placed_address, placed_size, and shadow_len. (default_memory_remove_breakpoint): Update. Don't use BREAKPOINT_FROM_PC. (memory_insert_breakpoint, memory_remove_breakpoint): Update. * target.c (update_current_target): Update prototypes for changed functions. (debug_to_insert_breakpoint, debug_to_remove_breakpoint) (debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Update. * target.h: Forward declare struct bp_target_info. (struct target_ops): Use a bp_target_info argument for to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint. (target_insert_breakpoint, target_remove_breakpoint) (target_insert_hw_breakpoint, target_remove_hw_breakpoint) (memory_insert_breakpoint, memory_remove_breakpoint) (default_memory_insert_breakpoint, default_memory_remove_breakpoint): Update. * config/i386/nm-i386.h: Forward declare struct bp_target_info. (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. (target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise. * gdbarch.c, gdbarch.h: Regenerated. * alpha-tdep.c (alpha_software_single_step): Use insert_single_step_breakpoint and remove_single_step_breakpoints. Remove unused statics. * arm-tdep.c (arm_software_single_step): Likewise. Add a note. * cris-tdep.c (cris_software_single_step): Likewise. * mips-tdep.c (mips_software_single_step): Likewise. * rs6000-tdep.c (rs6000_software_single_step): Likewise. * sparc-tdep.c (sparc_software_single_step): Likewise. * wince.c (struct thread_info_struct): Remove step_prev. (undoSStep): Use remove_single_step_breakpoints. (wince_software_single_step): Use insert_single_step_breakpoint. * corelow.c (ignore): Remove unneeded prototype. Update arguments. * exec.c (ignore): Likewise. * sol-thread.c (ignore): Likewise. * procfs.c (dbx_link_shadow_contents): Delete. (dbx_link_bpt): New. (procfs_mourn_inferior): Remove it if necessary. (remove_dbx_link_breakpoint): Use it. (insert_dbx_link_bpt_in_file): Set it. (procfs_init_inferior): Don't update dbx_link_bpt_addr. * rs6000-nat.c (exec_one_dummy_insn): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * solib-irix.c (shadow_contents, breakpoint_addr): Delete. (base_breakpoint): New. (disable_break): Use it. (enable_break): Set it. * i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint) (ia64_memory_remove_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint) (m32r_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Likewise. Remove unnecessary prototypes. Use placed_address and placed_size. Removed useless read from memory. * nto-procfs.c (procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint): Update. * ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise. * remote-e7000.c (e7000_insert_breakpoint) (e7000_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint) (mips_remove_breakpoint): Likewise. * remote-rdp.c (remote_rdp_insert_breakpoint) (remote_rdp_remove_breakpoint): Likewise. (rdp_step): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint): Update. * remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint): Delete. (init_gdbsim_ops): Use memory_insert_breakpoint and memory_remove_breakpoint. * remote-st.c (st2000_insert_breakpoint) (st2000_remove_breakpoint): Update. Remove unused BREAKPOINT_FROM_PC. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Update. Use placed_address and placed_size. (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise. gdb/doc/ * gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert and remove breakpoint prototypes. (Watchpoints): Move description of target_insert_hw_breakpoint and target_remove_hw_breakpoint ... (Breakpoints): ... to here. Document target_insert_breakpoint and target_remove_breakpoint.
2006-04-18 21:20:08 +02:00
struct bp_target_info;
struct target_desc;
MIPS: Keep the ISA bit in compressed code addresses 1. Background information The MIPS architecture, as originally designed and implemented in mid-1980s has a uniform instruction word size that is 4 bytes, naturally aligned. As such all MIPS instructions are located at addresses that have their bits #1 and #0 set to zeroes, and any attempt to execute an instruction from an address that has any of the two bits set to one causes an address error exception. This may for example happen when a jump-register instruction is executed whose register value used as the jump target has any of these bits set. Then in mid 1990s LSI sought a way to improve code density for their TinyRISC family of MIPS cores and invented an alternatively encoded instruction set in a joint effort with MIPS Technologies (then a subsidiary of SGI). The new instruction set has been named the MIPS16 ASE (Application-Specific Extension) and uses a variable instruction word size, which is 2 bytes (as the name of the ASE suggests) for most, but there are a couple of exceptions that take 4 bytes, and then most of the 2-byte instructions can be treated with a 2-byte extension prefix to expand the range of the immediate operands used. As a result instructions are no longer 4-byte aligned, instead they are aligned to a multiple of 2. That left the bit #0 still unused for code references, be it for the standard MIPS (i.e. as originally invented) or for the MIPS16 instruction set, and based on that observation a clever trick was invented that on one hand allowed the processor to be seamlessly switched between the two instruction sets at any time at the run time while on the other avoided the introduction of any special control register to do that. So it is the bit #0 of the instruction address that was chosen as the selector and named the ISA bit. Any instruction executed at an even address is interpreted as a standard MIPS instruction (the address still has to have its bit #1 clear), any instruction executed at an odd address is interpreted as a MIPS16 instruction. To switch between modes ordinary jump instructions are used, such as used for function calls and returns, specifically the bit #0 of the source register used in jump-register instructions selects the execution (ISA) mode for the following piece of code to be interpreted in. Additionally new jump-immediate instructions were added that flipped the ISA bit to select the opposite mode upon execution. They were considered necessary to avoid the need to make register jumps in all cases as the original jump-immediate instructions provided no way to change the bit #0 at all. This was all important for cases where standard MIPS and MIPS16 code had to be mixed, either for compatibility with the existing binary code base or to access resources not reachable from MIPS16 code (the MIPS16 instruction set only provides access to general-purpose registers, and not for example floating-point unit registers or privileged coprocessor 0 registers) -- pieces of code in the opposite mode can be executed as ordinary subroutine calls. A similar approach has been more recently adopted for the MIPS16 replacement instruction set defined as the so called microMIPS ASE. This is another instruction set encoding introduced to the MIPS architecture. Just like the MIPS16 ASE, the microMIPS instruction set uses a variable-length encoding, where each instruction takes a multiple of 2 bytes. The ISA bit has been reused and for microMIPS-capable processors selects between the standard MIPS and the microMIPS mode instead. 2. Statement of the problem To put it shortly, MIPS16 and microMIPS code pointers used by GDB are different to these observed at the run time. This results in the same expressions being evaluated producing different results in GDB and in the program being debugged. Obviously it's the results obtained at the run time that are correct (they define how the program behaves) and therefore by definition the results obtained in GDB are incorrect. A bit longer description will record that obviously at the run time the ISA bit has to be set correctly (refer to background information above if unsure why so) or the program will not run as expected. This is recorded in all the executable file structures used at the run time: the dynamic symbol table (but not always the static one!), the GOT, and obviously in all the addresses embedded in code or data of the program itself, calculated by applying the appropriate relocations at the static link time. While a program is being processed by GDB, the ISA bit is stripped off from any code addresses, presumably to make them the same as the respective raw memory byte address used by the processor to access the instruction in the instruction fetch access cycle. This stripping is actually performed outside GDB proper, in BFD, specifically _bfd_mips_elf_symbol_processing (elfxx-mips.c, see the piece of code at the very bottom of that function, starting with an: "If this is an odd-valued function symbol, assume it's a MIPS16 or microMIPS one." comment). This function is also responsible for symbol table dumps made by `objdump' too, so you'll never see the ISA bit reported there by that tool, you need to use `readelf'. This is however unlike what is ever done at the run time, the ISA bit once present is never stripped off, for example a cast like this: (short *) main will not strip the ISA bit off and if the resulting pointer is intended to be used to access instructions as data, for example for software instruction decoding (like for fault recovery or emulation in a signal handler) or for self-modifying code then the bit still has to be stripped off by an explicit AND operation. This is probably best illustrated with a simple real program example. Let's consider the following simple program: $ cat foobar.c int __attribute__ ((mips16)) foo (void) { return 1; } int __attribute__ ((mips16)) bar (void) { return 2; } int __attribute__ ((nomips16)) foo32 (void) { return 3; } int (*foo32p) (void) = foo32; int (*foop) (void) = foo; int fooi = (int) foo; int main (void) { return foop (); } $ This is plain C with no odd tricks, except from the instruction mode attributes. They are not necessary to trigger this problem, I just put them here so that the program can be contained in a single source file and to make it obvious which function is MIPS16 code and which is not. Let's try it with Linux, so that everyone can repeat this experiment: $ mips-linux-gnu-gcc -mips16 -g -O2 -o foobar foobar.c $ Let's have a look at some interesting symbols: $ mips-linux-gnu-readelf -s foobar | egrep 'table|foo|bar' Symbol table '.dynsym' contains 7 entries: Symbol table '.symtab' contains 95 entries: 55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c 66: 0040068c 4 FUNC GLOBAL DEFAULT [MIPS16] 12 bar 68: 00410848 4 OBJECT GLOBAL DEFAULT 21 foo32p 70: 00410844 4 OBJECT GLOBAL DEFAULT 21 foop 78: 00400684 8 FUNC GLOBAL DEFAULT 12 foo32 80: 00400680 4 FUNC GLOBAL DEFAULT [MIPS16] 12 foo 88: 00410840 4 OBJECT GLOBAL DEFAULT 21 fooi $ Hmm, no sight of the ISA bit, but notice how foo and bar (but not foo32!) have been marked as MIPS16 functions (ELF symbol structure's `st_other' field is used for that). So let's try to run and poke at this program with GDB. I'll be using a native system for simplicity (I'll be using ellipses here and there to remove unrelated clutter): $ ./foobar $ echo $? 1 $ So far, so good. $ gdb ./foobar [...] (gdb) break main Breakpoint 1 at 0x400490: file foobar.c, line 23. (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) Yay, it worked! OK, so let's poke at it: (gdb) print main $1 = {int (void)} 0x400490 <main> (gdb) print foo32 $2 = {int (void)} 0x400684 <foo32> (gdb) print foo32p $3 = (int (*)(void)) 0x400684 <foo32> (gdb) print bar $4 = {int (void)} 0x40068c <bar> (gdb) print foo $5 = {int (void)} 0x400680 <foo> (gdb) print foop $6 = (int (*)(void)) 0x400681 <foo> (gdb) A-ha! Here's the difference and finally the ISA bit! (gdb) print /x fooi $7 = 0x400681 (gdb) p/x $pc p/x $pc $8 = 0x400491 (gdb) And here as well... (gdb) advance foo foo () at foobar.c:4 4 } (gdb) disassemble Dump of assembler code for function foo: 0x00400680 <+0>: jr ra 0x00400682 <+2>: li v0,1 End of assembler dump. (gdb) finish Run till exit from #0 foo () at foobar.c:4 main () at foobar.c:24 24 } Value returned is $9 = 1 (gdb) continue Continuing. [Inferior 1 (process 14103) exited with code 01] (gdb) So let's be a bit inquisitive... (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) Actually we do not like to run foo here at all. Let's run bar instead! (gdb) set foop = bar (gdb) print foop $10 = (int (*)(void)) 0x40068c <bar> (gdb) Hmm, no ISA bit. Is it going to work? (gdb) advance bar bar () at foobar.c:9 9 } (gdb) p/x $pc $11 = 0x40068c (gdb) disassemble Dump of assembler code for function bar: => 0x0040068c <+0>: jr ra 0x0040068e <+2>: li v0,2 End of assembler dump. (gdb) finish Run till exit from #0 bar () at foobar.c:9 Program received signal SIGILL, Illegal instruction. bar () at foobar.c:9 9 } (gdb) Oops! (gdb) p/x $pc $12 = 0x40068c (gdb) We're still there! (gdb) continue Continuing. Program terminated with signal SIGILL, Illegal instruction. The program no longer exists. (gdb) So let's try something else: (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) set foop = foo (gdb) advance foo foo () at foobar.c:4 4 } (gdb) disassemble Dump of assembler code for function foo: => 0x00400680 <+0>: jr ra 0x00400682 <+2>: li v0,1 End of assembler dump. (gdb) finish Run till exit from #0 foo () at foobar.c:4 Program received signal SIGILL, Illegal instruction. foo () at foobar.c:4 4 } (gdb) continue Continuing. Program terminated with signal SIGILL, Illegal instruction. The program no longer exists. (gdb) The same problem! (gdb) run Starting program: /net/build2-lucid-cs/scratch/macro/mips-linux-fsf-gcc/isa-bit/foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) set foop = foo32 (gdb) advance foo32 foo32 () at foobar.c:14 14 } (gdb) disassemble Dump of assembler code for function foo32: => 0x00400684 <+0>: jr ra 0x00400688 <+4>: li v0,3 End of assembler dump. (gdb) finish Run till exit from #0 foo32 () at foobar.c:14 main () at foobar.c:24 24 } Value returned is $14 = 3 (gdb) continue Continuing. [Inferior 1 (process 14113) exited with code 03] (gdb) That did work though, so it's the ISA bit only! (gdb) quit Enough! That's the tip of the iceberg only though. So let's rebuild the executable with some dynamic symbols: $ mips-linux-gnu-gcc -mips16 -Wl,--export-dynamic -g -O2 -o foobar-dyn foobar.c $ mips-linux-gnu-readelf -s foobar-dyn | egrep 'table|foo|bar' Symbol table '.dynsym' contains 32 entries: 6: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar 8: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p 9: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop 15: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32 17: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo 25: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi Symbol table '.symtab' contains 95 entries: 55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c 69: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar 71: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p 72: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop 79: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32 81: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo 89: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi $ OK, now the ISA bit is there for a change, but the MIPS16 `st_other' attribute gone, hmm... What does `objdump' do then: $ mips-linux-gnu-objdump -Tt foobar-dyn | egrep 'SYMBOL|foo|bar' foobar-dyn: file format elf32-tradbigmips SYMBOL TABLE: 00000000 l df *ABS* 00000000 foobar.c 004009cc g F .text 00000004 0xf0 bar 00410b88 g O .data 00000004 foo32p 00410b84 g O .data 00000004 foop 004009c4 g F .text 00000008 foo32 004009c0 g F .text 00000004 0xf0 foo 00410b80 g O .data 00000004 fooi DYNAMIC SYMBOL TABLE: 004009cc g DF .text 00000004 Base 0xf0 bar 00410b88 g DO .data 00000004 Base foo32p 00410b84 g DO .data 00000004 Base foop 004009c4 g DF .text 00000008 Base foo32 004009c0 g DF .text 00000004 Base 0xf0 foo 00410b80 g DO .data 00000004 Base fooi $ Hmm, the attribute (0xf0, printed raw) is back, and the ISA bit gone again. Let's have a look at some DWARF-2 records GDB uses (I'll be stripping off a lot here for brevity) -- debug info: $ mips-linux-gnu-readelf -wi foobar Contents of the .debug_info section: [...] Compilation Unit @ offset 0x88: Length: 0xbb (32-bit) Version: 4 Abbrev Offset: 62 Pointer Size: 4 <0><93>: Abbrev Number: 1 (DW_TAG_compile_unit) <94> DW_AT_producer : (indirect string, offset: 0x19e): GNU C 4.8.0 20120513 (experimental) -meb -mips16 -march=mips32r2 -mhard-float -mllsc -mplt -mno-synci -mno-shared -mabi=32 -g -O2 <98> DW_AT_language : 1 (ANSI C) <99> DW_AT_name : (indirect string, offset: 0x190): foobar.c <9d> DW_AT_comp_dir : (indirect string, offset: 0x225): [...] <a1> DW_AT_ranges : 0x0 <a5> DW_AT_low_pc : 0x0 <a9> DW_AT_stmt_list : 0x27 <1><ad>: Abbrev Number: 2 (DW_TAG_subprogram) <ae> DW_AT_external : 1 <ae> DW_AT_name : foo <b2> DW_AT_decl_file : 1 <b3> DW_AT_decl_line : 1 <b4> DW_AT_prototyped : 1 <b4> DW_AT_type : <0xc2> <b8> DW_AT_low_pc : 0x400680 <bc> DW_AT_high_pc : 0x400684 <c0> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <c2> DW_AT_GNU_all_call_sites: 1 <1><c2>: Abbrev Number: 3 (DW_TAG_base_type) <c3> DW_AT_byte_size : 4 <c4> DW_AT_encoding : 5 (signed) <c5> DW_AT_name : int <1><c9>: Abbrev Number: 4 (DW_TAG_subprogram) <ca> DW_AT_external : 1 <ca> DW_AT_name : (indirect string, offset: 0x18a): foo32 <ce> DW_AT_decl_file : 1 <cf> DW_AT_decl_line : 11 <d0> DW_AT_prototyped : 1 <d0> DW_AT_type : <0xc2> <d4> DW_AT_low_pc : 0x400684 <d8> DW_AT_high_pc : 0x40068c <dc> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <de> DW_AT_GNU_all_call_sites: 1 <1><de>: Abbrev Number: 2 (DW_TAG_subprogram) <df> DW_AT_external : 1 <df> DW_AT_name : bar <e3> DW_AT_decl_file : 1 <e4> DW_AT_decl_line : 6 <e5> DW_AT_prototyped : 1 <e5> DW_AT_type : <0xc2> <e9> DW_AT_low_pc : 0x40068c <ed> DW_AT_high_pc : 0x400690 <f1> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <f3> DW_AT_GNU_all_call_sites: 1 <1><f3>: Abbrev Number: 5 (DW_TAG_subprogram) <f4> DW_AT_external : 1 <f4> DW_AT_name : (indirect string, offset: 0x199): main <f8> DW_AT_decl_file : 1 <f9> DW_AT_decl_line : 21 <fa> DW_AT_prototyped : 1 <fa> DW_AT_type : <0xc2> <fe> DW_AT_low_pc : 0x400490 <102> DW_AT_high_pc : 0x4004a4 <106> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <108> DW_AT_GNU_all_tail_call_sites: 1 [...] $ -- no sign of the ISA bit anywhere -- frame info: $ mips-linux-gnu-readelf -wf foobar [...] Contents of the .debug_frame section: 00000000 0000000c ffffffff CIE Version: 1 Augmentation: "" Code alignment factor: 1 Data alignment factor: -4 Return address column: 31 DW_CFA_def_cfa_register: r29 DW_CFA_nop 00000010 0000000c 00000000 FDE cie=00000000 pc=00400680..00400684 00000020 0000000c 00000000 FDE cie=00000000 pc=00400684..0040068c 00000030 0000000c 00000000 FDE cie=00000000 pc=0040068c..00400690 00000040 00000018 00000000 FDE cie=00000000 pc=00400490..004004a4 DW_CFA_advance_loc: 6 to 00400496 DW_CFA_def_cfa_offset: 32 DW_CFA_offset: r31 at cfa-4 DW_CFA_advance_loc: 6 to 0040049c DW_CFA_restore: r31 DW_CFA_def_cfa_offset: 0 DW_CFA_nop DW_CFA_nop DW_CFA_nop [...] $ -- no sign of the ISA bit anywhere -- range info (GDB doesn't use arange): $ mips-linux-gnu-readelf -wR foobar Contents of the .debug_ranges section: Offset Begin End 00000000 00400680 00400690 00000000 00400490 004004a4 00000000 <End of list> $ -- no sign of the ISA bit anywhere -- line info: $ mips-linux-gnu-readelf -wl foobar Raw dump of debug contents of section .debug_line: [...] Offset: 0x27 Length: 78 DWARF Version: 2 Prologue Length: 31 Minimum Instruction Length: 1 Initial value of 'is_stmt': 1 Line Base: -5 Line Range: 14 Opcode Base: 13 Opcodes: Opcode 1 has 0 args Opcode 2 has 1 args Opcode 3 has 1 args Opcode 4 has 1 args Opcode 5 has 1 args Opcode 6 has 0 args Opcode 7 has 0 args Opcode 8 has 0 args Opcode 9 has 1 args Opcode 10 has 0 args Opcode 11 has 0 args Opcode 12 has 1 args The Directory Table is empty. The File Name Table: Entry Dir Time Size Name 1 0 0 0 foobar.c Line Number Statements: Extended opcode 2: set Address to 0x400681 Special opcode 6: advance Address by 0 to 0x400681 and Line by 1 to 2 Special opcode 7: advance Address by 0 to 0x400681 and Line by 2 to 4 Special opcode 55: advance Address by 3 to 0x400684 and Line by 8 to 12 Special opcode 7: advance Address by 0 to 0x400684 and Line by 2 to 14 Advance Line by -7 to 7 Special opcode 131: advance Address by 9 to 0x40068d and Line by 0 to 7 Special opcode 7: advance Address by 0 to 0x40068d and Line by 2 to 9 Advance PC by 3 to 0x400690 Extended opcode 1: End of Sequence Extended opcode 2: set Address to 0x400491 Advance Line by 21 to 22 Copy Special opcode 6: advance Address by 0 to 0x400491 and Line by 1 to 23 Special opcode 60: advance Address by 4 to 0x400495 and Line by -1 to 22 Special opcode 34: advance Address by 2 to 0x400497 and Line by 1 to 23 Special opcode 62: advance Address by 4 to 0x40049b and Line by 1 to 24 Special opcode 32: advance Address by 2 to 0x40049d and Line by -1 to 23 Special opcode 6: advance Address by 0 to 0x40049d and Line by 1 to 24 Advance PC by 7 to 0x4004a4 Extended opcode 1: End of Sequence [...] -- a-ha, the ISA bit is there! However it's not always right for some reason, I don't have a small test case to show it, but here's an excerpt from MIPS16 libc, a prologue of a function: 00019630 <__libc_init_first>: 19630: e8a0 jrc ra 19632: 6500 nop 00019634 <_init>: 19634: f000 6a11 li v0,17 19638: f7d8 0b08 la v1,15e00 <_DYNAMIC+0x15c54> 1963c: f400 3240 sll v0,16 19640: e269 addu v0,v1 19642: 659a move gp,v0 19644: 64f6 save 48,ra,s0-s1 19646: 671c move s0,gp 19648: d204 sw v0,16(sp) 1964a: f352 984c lw v0,-27828(s0) 1964e: 6724 move s1,a0 and the corresponding DWARF-2 line info: Line Number Statements: Extended opcode 2: set Address to 0x19631 Advance Line by 44 to 45 Copy Special opcode 8: advance Address by 0 to 0x19631 and Line by 3 to 48 Special opcode 66: advance Address by 4 to 0x19635 and Line by 5 to 53 Advance PC by constant 17 to 0x19646 Special opcode 25: advance Address by 1 to 0x19647 and Line by 6 to 59 Advance Line by -6 to 53 Special opcode 33: advance Address by 2 to 0x19649 and Line by 0 to 53 Special opcode 39: advance Address by 2 to 0x1964b and Line by 6 to 59 Advance Line by -6 to 53 Special opcode 61: advance Address by 4 to 0x1964f and Line by 0 to 53 -- see that "Advance PC by constant 17" there? It clears the ISA bit, however code at 0x19646 is not standard MIPS code at all. For some reason the constant is always 17, I've never seen DW_LNS_const_add_pc used with any other value -- is that a binutils bug or what? 3. Solution: I think we should retain the value of the ISA bit in code references, that is effectively treat them as cookies as they indeed are (although trivially calculated) rather than raw memory byte addresses. In a perfect world both the static symbol table and the respective DWARF-2 records should be fixed to include the ISA bit in all the cases. I think however that this is infeasible. All the uses of `_bfd_mips_elf_symbol_processing' can not necessarily be tracked down. This function is used by `elf_slurp_symbol_table' that in turn is used by `bfd_canonicalize_symtab' and `bfd_canonicalize_dynamic_symtab', which are public interfaces. Similarly DWARF-2 records are used outside GDB, one notable if a bit questionable is the exception unwinder (libgcc/unwind-dw2.c) -- I have identified at least bits in `execute_cfa_program' and `uw_frame_state_for', both around the calls to `_Unwind_IsSignalFrame', that would need an update as they effectively flip the ISA bit freely; see also the comment about MASK_RETURN_ADDR in gcc/config/mips/mips.h. But there may be more places. Any change in how DWARF-2 records are produced would require an update there and would cause compatibility problems with libgcc.a binaries already distributed; given that this is a static library a complex change involving function renames would likely be required. I propose therefore to accept the existing inconsistencies and deal with them entirely within GDB. I have figured out that the ISA bit lost in various places can still be recovered as long as we have symbol information -- that'll have the `st_other' attribute correctly set to one of standard MIPS/MIPS16/microMIPS encoding. Here's the resulting change. It adds a couple of new `gdbarch' hooks, one to update symbol information with the ISA bit lost in `_bfd_mips_elf_symbol_processing', and two other ones to adjust DWARF-2 records as they're processed. The ISA bit is set in each address handled according to information retrieved from the symbol table for the symbol spanning the address if any; limits are adjusted based on the address they point to related to the respective base address. Additionally minimal symbol information has to be adjusted accordingly in its gdbarch hook. With these changes in place some complications with ISA bit juggling in the PC that never fully worked can be removed from the MIPS backend. Conversely, the generic dynamic linker event special breakpoint symbol handler has to be updated to call the minimal symbol gdbarch hook to record that the symbol is a MIPS16 or microMIPS address if applicable or the breakpoint will be set at the wrong address and either fail to work or cause SIGTRAPs (this is because the symbol is handled early on and bypasses regular symbol processing). 4. Results obtained The change fixes the example above -- to repeat only the crucial steps: (gdb) break main Breakpoint 1 at 0x400491: file foobar.c, line 23. (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) print foo $1 = {int (void)} 0x400681 <foo> (gdb) set foop = bar (gdb) advance bar bar () at foobar.c:9 9 } (gdb) disassemble Dump of assembler code for function bar: => 0x0040068d <+0>: jr ra 0x0040068f <+2>: li v0,2 End of assembler dump. (gdb) finish Run till exit from #0 bar () at foobar.c:9 main () at foobar.c:24 24 } Value returned is $2 = 2 (gdb) continue Continuing. [Inferior 1 (process 14128) exited with code 02] (gdb) -- excellent! The change removes about 90 failures per MIPS16 multilib in mips-sde-elf testing too, results for MIPS16 are now similar to that for standard MIPS; microMIPS results are a bit worse because of host-I/O problems in QEMU used instead of MIPSsim for microMIPS testing only: === gdb Summary === # of expected passes 14299 # of unexpected failures 187 # of expected failures 56 # of known failures 58 # of unresolved testcases 11 # of untested testcases 52 # of unsupported tests 174 MIPS16: === gdb Summary === # of expected passes 14298 # of unexpected failures 187 # of unexpected successes 2 # of expected failures 54 # of known failures 58 # of unresolved testcases 12 # of untested testcases 52 # of unsupported tests 174 microMIPS: === gdb Summary === # of expected passes 14149 # of unexpected failures 201 # of unexpected successes 2 # of expected failures 54 # of known failures 58 # of unresolved testcases 7 # of untested testcases 53 # of unsupported tests 175 2014-12-12 Maciej W. Rozycki <macro@codesourcery.com> Maciej W. Rozycki <macro@mips.com> Pedro Alves <pedro@codesourcery.com> gdb/ * gdbarch.sh (elf_make_msymbol_special): Change type to `F', remove `predefault' and `invalid_p' initializers. (make_symbol_special): New architecture method. (adjust_dwarf2_addr, adjust_dwarf2_line): Likewise. (objfile, symbol): New declarations. * arch-utils.h (default_elf_make_msymbol_special): Remove prototype. (default_make_symbol_special): New prototype. (default_adjust_dwarf2_addr): Likewise. (default_adjust_dwarf2_line): Likewise. * mips-tdep.h (mips_unmake_compact_addr): New prototype. * arch-utils.c (default_elf_make_msymbol_special): Remove function. (default_make_symbol_special): New function. (default_adjust_dwarf2_addr): Likewise. (default_adjust_dwarf2_line): Likewise. * dwarf2-frame.c (decode_frame_entry_1): Call `gdbarch_adjust_dwarf2_addr'. * dwarf2loc.c (dwarf2_find_location_expression): Likewise. * dwarf2read.c (create_addrmap_from_index): Likewise. (process_psymtab_comp_unit_reader): Likewise. (add_partial_symbol): Likewise. (add_partial_subprogram): Likewise. (process_full_comp_unit): Likewise. (read_file_scope): Likewise. (read_func_scope): Likewise. Call `gdbarch_make_symbol_special'. (read_lexical_block_scope): Call `gdbarch_adjust_dwarf2_addr'. (read_call_site_scope): Likewise. (dwarf2_ranges_read): Likewise. (dwarf2_record_block_ranges): Likewise. (read_attribute_value): Likewise. (dwarf_decode_lines_1): Call `gdbarch_adjust_dwarf2_line'. (new_symbol_full): Call `gdbarch_adjust_dwarf2_addr'. * elfread.c (elf_symtab_read): Don't call `gdbarch_elf_make_msymbol_special' if unset. * mips-linux-tdep.c (micromips_linux_sigframe_validate): Strip the ISA bit from the PC. * mips-tdep.c (mips_unmake_compact_addr): New function. (mips_elf_make_msymbol_special): Set the ISA bit in the symbol's address appropriately. (mips_make_symbol_special): New function. (mips_pc_is_mips): Set the ISA bit before symbol lookup. (mips_pc_is_mips16): Likewise. (mips_pc_is_micromips): Likewise. (mips_pc_isa): Likewise. (mips_adjust_dwarf2_addr): New function. (mips_adjust_dwarf2_line): Likewise. (mips_read_pc, mips_unwind_pc): Keep the ISA bit. (mips_addr_bits_remove): Likewise. (mips_skip_trampoline_code): Likewise. (mips_write_pc): Don't set the ISA bit. (mips_eabi_push_dummy_call): Likewise. (mips_o64_push_dummy_call): Likewise. (mips_gdbarch_init): Install `mips_make_symbol_special', `mips_adjust_dwarf2_addr' and `mips_adjust_dwarf2_line' gdbarch handlers. * solib.c (gdb_bfd_lookup_symbol_from_symtab): Get target-specific symbol address adjustments. * gdbarch.h: Regenerate. * gdbarch.c: Regenerate. 2014-12-12 Maciej W. Rozycki <macro@codesourcery.com> gdb/testsuite/ * gdb.base/func-ptrs.c: New file. * gdb.base/func-ptrs.exp: New file.
2014-12-12 14:31:53 +01:00
struct symbol;
Implement displaced stepping. gdb/ * gdbarch.sh (max_insn_length): New 'variable'. (displaced_step_copy, displaced_step_fixup) (displaced_step_free_closure, displaced_step_location): New functions. (struct displaced_step_closure): Add forward declaration. * gdbarch.c, gdbarch.h: Regenerated. * arch-utils.c: #include "objfiles.h". (simple_displaced_step_copy_insn) (simple_displaced_step_free_closure) (displaced_step_at_entry_point): New functions. * arch-utils.h (simple_displaced_step_copy_insn) (simple_displaced_step_free_closure) (displaced_step_at_entry_point): New prototypes. * i386-tdep.c (I386_MAX_INSN_LEN): Rename to... (I386_MAX_MATCHED_INSN_LEN): ... this. (i386_absolute_jmp_p, i386_absolute_call_p) (i386_ret_p, i386_call_p, i386_breakpoint_p, i386_syscall_p) (i386_displaced_step_fixup): New functions. (struct i386_insn, i386_match_insn): Update. (i386_gdbarch_init): Set gdbarch_max_insn_length. * i386-tdep.h (I386_MAX_INSN_LEN): New. (i386_displaced_step_fixup): New prototype. * i386-linux-tdep.c (i386_linux_init_abi): Include "arch-utils.h". Register gdbarch_displaced_step_copy, gdbarch_displaced_step_fixup, gdbarch_displaced_step_free_closure, and gdbarch_displaced_step_location functions. * infrun.c (debug_displaced): New variable. (show_debug_displaced): New function. (struct displaced_step_request): New struct. (displaced_step_request_queue, displaced_step_ptid) (displaced_step_gdbarch, displaced_step_closure) (displaced_step_original, displaced_step_copy) (displaced_step_saved_copy, can_use_displaced_stepping): New variables. (show_can_use_displaced_stepping, use_displaced_stepping) (displaced_step_clear, cleanup_displaced_step_closure) (displaced_step_dump_bytes, displaced_step_prepare) (displaced_step_clear_cleanup, write_memory_ptid) (displaced_step_fixup): New functions. (resume): Call displaced_step_prepare. (proceed): Call read_pc once, and remember the value. If using displaced stepping, don't remove breakpoints. (handle_inferior_event): Call displaced_step_fixup. Add some debugging output. When we try to step over a breakpoint, but get a signal to deliver to the thread instead, ensure the step-resume breakpoint is actually inserted. If a thread hop is needed, and displaced stepping is enabled, don't remove breakpoints. (init_wait_for_inferior): Call displaced_step_clear. (_initialize_infrun): Add "set debug displaced" command. Add "maint set can-use-displaced-stepping" command. Clear displaced_step_ptid. * inferior.h (debug_displaced): Declare variable. (displaced_step_dump_bytes): Declare function. * Makefile.in (arch-utils.o, i386-linux-tdep.o): Update dependencies. gdb/testsuite/ * gdb.asm/asmsrc1.s: Add scratch space. gdb/doc/ * gdb.texinfo (Debugging Output): Document "set/show debug displaced". (Maintenance Commands): Document "maint set/show can-use-displaced-stepping".
2008-05-02 18:49:54 +02:00
struct displaced_step_closure;
Implementing catch syscall. * amd64-linux-tdep.c: Include xml-syscall.h header, define the XML syscall name for the architecture. (amd64_linux_get_syscall_number): New function. (amd64_linux_init_abi): Register the correct functions for syscall catchpoint; set the correct syscall file name. * breakpoint.c: New include: xml-syscall.h. (set_raw_breakpoint_without_location): Setting the parameters for the catch syscall feature. (insert_catch_syscall): New. (remove_catch_syscall): New. (breakpoint_hit_catch_syscall): New. (print_it_catch_syscall): New. (print_one_catch_syscall): New. (print_mention_catch_syscall): New. (catch_syscall_breakpoint_ops): New. (syscall_catchpoint_p): New. (create_catchpoint_without_mention): New. (create_catchpoint): Modified in order to use create_catchpoint_without_mention. (create_syscall_event_catchpoint): New. (clean_up_filters): New. (catch_syscall_split_args): New. (catch_syscall_command_1): New. (delete_breakpoint): Add cleanup for catch syscall. (is_syscall_catchpoint_enabled): New. (catch_syscall_enabled): New. (catching_syscall_number): New. (catch_syscall_completer): New completer function. (add_catch_command): Add the completer function for catchpoints. * breakpoint.h (syscalls_to_be_caught): New vector. (catch_syscall_enabled): New. (catching_syscall_number): New. * gdbarch.c: Regenerated. * gdbarch.h: Regenerated. * gdbarch.sh: Add syscall catchpoint functions and structures. (get_syscall_number): New. (UNKNOWN_SYSCALL): New definition. * i386-linux-nat.c (i386_linux_resume): Select the proper request to be made for ptrace() considering if we are catching syscalls or not. * i386-linux-tdep.c: Include xml-syscall.h header, define the XML syscall name for the architecture. (i386_linux_get_syscall_number): New. (i386_linux_init_abi): Register the correct functions for syscall catchpoint; set the correct syscall file name. * inf-child.c (inf_child_set_syscall_catchpoint): New. (inf_child_target): Assign default values to target_ops. * inf-ptrace.c (inf_ptrace_resume): Select the proper request to be made for ptrace() considering if we are catching syscalls or not. * inferior.h (struct inferior): Included new variables any_syscall_count, syscalls_counts and total_syscalls_count, used to keep track of requested syscall catchpoints. * infrun.c (resume): Add syscall catchpoint. (deal_with_syscall_event): New. (handle_inferior_event): Add syscall entry/return events. (inferior_has_called_syscall): New. * linux-nat.c: Define some helpful variables to track wether we have support for the needed ptrace option. (linux_test_for_tracesysgood): New. (linux_supports_tracesysgood): New. (linux_enable_tracesysgood): New. (linux_enable_event_reporting): Save the current used ptrace options. (linux_child_post_attach): Calling linux_enable_tracesysgood. (linux_child_post_startup_inferior): Likewise. (linux_child_set_syscall_catchpoint): New function. (linux_handle_extended_wait): Handle the case which the inferior stops because it has called or returned from a syscall. (linux_target_install_ops): Install the necessary functions to handle syscall catchpoints. * linux-nat.h (struct lwp_info): Include syscall_state into the structure, which indicates if we are in a syscall entry or return. * ppc-linux-tdep.c: Include xml-syscall.h header, define the XML syscall filename for the arch. (ppc_linux_get_syscall_number): New. (ppc_linux_init_abi): Register the correct functions for syscall catchpoint; setting the correct name for the XML syscall file. * target.c (update_current_target): Update/copy functions related to syscall catchpoint. (target_waitstatus_to_string): Add syscall catchpoint entry/return events. * target.h (struct target_waitstatus): Add syscall number. (struct syscall): New struct to hold information about syscalls in the system. (struct target_ops): Add ops for syscall catchpoint. (inferior_has_called_syscall): New. (target_set_syscall_catchpoint): New. * xml-support.c (xml_fetch_content_from_file): New function, transferred from xml-tdesc.c. * xml-support.h (xml_fetch_content_from_file): New. * xml-tdesc.c (fetch_xml_from_file): Function removed; transferred to xml-support.c. (file_read_description_xml): Updated to use the new xml_fetch_content_from_file function. * syscalls/gdb-syscalls.dtd: New definition file for syscall's XML support. * syscalls/amd64-linux.xml: New file containing information about syscalls for GNU/Linux systems that use amd64 architecture. * syscalls/i386-linux.xml: New file containing information about syscalls for GNU/Linux systems that use i386 architecture. * syscalls/ppc-linux.xml: New file containing information about syscalls for GNU/Linux systems that use PPC architecture. * syscalls/ppc64-linux.xml: New file containing information about syscalls for GNU/Linux systems that use PPC64 architecture. * xml-syscall.c: New file containing functions for manipulating syscall's XML files. * xml-syscall.h: New file, exporting the functions above mentioned. * Makefile.in: Support for relocatable GDB datadir and XML syscall. * NEWS: Added information about the catch syscall feature. * doc/gdb.texinfo (Set Catchpoints): Documentation about the new feature. * testsuite/Makefile.in: Inclusion of catch-syscall object. * testsuite/gdb.base/catch-syscall.c: New file. * testsuite/gdb.base/catch-syscall.exp: New file.
2009-09-15 05:30:08 +02:00
struct syscall;
struct agent_expr;
struct axs_value;
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02:00
struct stap_parse_info;
struct expr_builder;
struct ravenscar_arch_ops;
struct mem_range;
Partial fix for PR breakpoints/10737: Make syscall info be per-arch instead of global This patch intends to partially fix PR breakpoints/10737, which is about making the syscall information (for the "catch syscall" command) be per-arch, instead of global. This is not a full fix because of the other issues pointed by Pedro here: <https://sourceware.org/bugzilla/show_bug.cgi?id=10737#c5> However, I consider it a good step towards the real fix. It will also help me fix <https://sourceware.org/bugzilla/show_bug.cgi?id=17402>. What this patch does, basically, is move the "syscalls_info" struct to gdbarch. Currently, the syscall information is stored in a global variable inside gdb/xml-syscall.c, which means that there is no easy way to correlate this info with the current target or architecture being used, for example. This causes strange behaviors, because the syscall info is not re-read when the arch changes. For example, if you put a syscall catchpoint in syscall 5 on i386 (syscall open), and then load a x86_64 program on GDB and put the same syscall 5 there (fstat on x86_64), you will still see that GDB tells you that it is catching "open", even though it is not. With this patch, GDB correctly says that it will be catching fstat syscalls. (gdb) set architecture i386 The target architecture is assumed to be i386 (gdb) catch syscall 5 Catchpoint 1 (syscall 'open' [5]) (gdb) set architecture i386:x86-64 The target architecture is assumed to be i386:x86-64 (gdb) catch syscall 5 Catchpoint 2 (syscall 'open' [5]) But with the patch: (gdb) set architecture i386 The target architecture is assumed to be i386 (gdb) catch syscall 5 Catchpoint 1 (syscall 'open' [5]) (gdb) set architecture i386:x86-64 The target architecture is assumed to be i386:x86-64 (gdb) catch syscall 5 Catchpoint 2 (syscall 'fstat' [5]) As I said, there are still some problems on the "catch syscall" mechanism, because (for example) the user should be able to "catch syscall open" on i386, and then expect "open" to be caught also on x86_64. Currently, it doesn't work. I intend to work on this later. gdb/ 2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com> PR breakpoints/10737 * amd64-linux-tdep.c (amd64_linux_init_abi_common): Adjust call to set_xml_syscall_file_name to provide gdbarch. * arm-linux-tdep.c (arm_linux_init_abi): Likewise. * bfin-linux-tdep.c (bfin_linux_init_abi): Likewise. * breakpoint.c (print_it_catch_syscall): Adjust call to get_syscall_by_number to provide gdbarch. (print_one_catch_syscall): Likewise. (print_mention_catch_syscall): Likewise. (print_recreate_catch_syscall): Likewise. (catch_syscall_split_args): Adjust calls to get_syscall_by_number and get_syscall_by_name to provide gdbarch. (catch_syscall_completer): Adjust call to get_syscall_names to provide gdbarch. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * gdbarch.sh: Forward declare "struct syscalls_info". (xml_syscall_file): New variable. (syscalls_info): Likewise. * i386-linux-tdep.c (i386_linux_init_abi): Adjust call to set_xml_syscall_file_name to provide gdbarch. * mips-linux-tdep.c (mips_linux_init_abi): Likewise. * ppc-linux-tdep.c (ppc_linux_init_abi): Likewise. * s390-linux-tdep.c (s390_gdbarch_init): Likewise. * sparc-linux-tdep.c (sparc32_linux_init_abi): Likewise. * sparc64-linux-tdep.c (sparc64_linux_init_abi): Likewise. * xml-syscall.c: Include gdbarch.h. (set_xml_syscall_file_name): Accept gdbarch parameter. (get_syscall_by_number): Likewise. (get_syscall_by_name): Likewise. (get_syscall_names): Likewise. (my_gdb_datadir): Delete global variable. (struct syscalls_info) <my_gdb_datadir>: New variable. (struct syscalls_info) <sysinfo>: Rename variable to "syscalls_info". (sysinfo): Delete global variable. (have_initialized_sysinfo): Likewise. (xml_syscall_file): Likewise. (sysinfo_free_syscalls_desc): Rename to... (syscalls_info_free_syscalls_desc): ... this. (free_syscalls_info): Rename "sysinfo" to "syscalls_info". Adjust code to the new layout of "struct syscalls_info". (make_cleanup_free_syscalls_info): Rename parameter "sysinfo" to "syscalls_info". (syscall_create_syscall_desc): Likewise. (syscall_start_syscall): Likewise. (syscall_parse_xml): Likewise. (xml_init_syscalls_info): Likewise. Drop "const" from return value. (init_sysinfo): Rename to... (init_syscalls_info): ...this. Add gdbarch as a parameter. Adjust function to deal with gdbarch. (xml_get_syscall_number): Delete parameter sysinfo. Accept gdbarch as a parameter. Adjust code. (xml_get_syscall_name): Likewise. (xml_list_of_syscalls): Likewise. (set_xml_syscall_file_name): Accept gdbarch as parameter. (get_syscall_by_number): Likewise. (get_syscall_by_name): Likewise. (get_syscall_names): Likewise. * xml-syscall.h (set_xml_syscall_file_name): Likewise. (get_syscall_by_number): Likewise. (get_syscall_by_name): Likewise. (get_syscall_names): Likewise. gdb/testsuite/ 2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com> PR breakpoints/10737 * gdb.base/catch-syscall.exp (do_syscall_tests): Call test_catch_syscall_multi_arch. (test_catch_syscall_multi_arch): New function.
2014-11-20 18:28:18 +01:00
struct syscalls_info;
struct thread_info;
Intel MPX bound violation handling With Intel Memory Protection Extensions it was introduced the concept of boundary violation. A boundary violations is presented to the inferior as a segmentation fault having SIGCODE 3. This patch adds a handler for a boundary violation extending the information displayed when a bound violation is presented to the inferior. In the stop mode case the debugger will also display the kind of violation: "upper" or "lower", bounds and the address accessed. On no stop mode the information will still remain unchanged. Additional information about bound violations are not meaningful in that case user does not know the line in which violation occurred as well. When the segmentation fault handler is stop mode the out puts will be changed as exemplified below. The usual output of a segfault is: Program received signal SIGSEGV, Segmentation fault 0x0000000000400d7c in upper (p=0x603010, a=0x603030, b=0x603050, c=0x603070, d=0x603090, len=7) at i386-mpx-sigsegv.c:68 68 value = *(p + len); In case it is a bound violation it will be presented as: Program received signal SIGSEGV, Segmentation fault Upper bound violation while accessing address 0x7fffffffc3b3 Bounds: [lower = 0x7fffffffc390, upper = 0x7fffffffc3a3] 0x0000000000400d7c in upper (p=0x603010, a=0x603030, b=0x603050, c=0x603070, d=0x603090, len=7) at i386-mpx-sigsegv.c:68 68 value = *(p + len); In mi mode the output of a segfault is: *stopped,reason="signal-received",signal-name="SIGSEGV", signal-meaning="Segmentation fault", frame={addr="0x0000000000400d7c", func="upper",args=[{name="p", value="0x603010"},{name="a",value="0x603030"} ,{name="b",value="0x603050"}, {name="c",value="0x603070"}, {name="d",value="0x603090"},{name="len",value="7"}], file="i386-mpx-sigsegv.c",fullname="i386-mpx-sigsegv.c",line="68"}, thread-id="1",stopped-threads="all",core="6" in the case of a bound violation: *stopped,reason="signal-received",signal-name="SIGSEGV", signal-meaning="Segmentation fault", sigcode-meaning="Upper bound violation", lower-bound="0x603010",upper-bound="0x603023",bound-access="0x60302f", frame={addr="0x0000000000400d7c",func="upper",args=[{name="p", value="0x603010"},{name="a",value="0x603030"},{name="b",value="0x603050"}, {name="c",value="0x603070"},{name="d",value="0x603090"}, {name="len",value="7"}],file="i386-mpx-sigsegv.c", fullname="i386-mpx-sigsegv.c",line="68"},thread-id="1", stopped-threads="all",core="6" 2016-02-18 Walfred Tedeschi <walfred.tedeschi@intel.com> gdb/ChangeLog: * NEWS: Add entry for bound violation. * amd64-linux-tdep.c (amd64_linux_init_abi_common): Add handler for segmentation fault. * gdbarch.sh (handle_segmentation_fault): New. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * i386-linux-tdep.c (i386_linux_handle_segmentation_fault): New. (SIG_CODE_BONDARY_FAULT): New define. (i386_linux_init_abi): Use i386_mpx_bound_violation_handler. * i386-linux-tdep.h (i386_linux_handle_segmentation_fault) New. * i386-tdep.c (i386_mpx_enabled): Add as external. * i386-tdep.c (i386_mpx_enabled): Add as external. * infrun.c (handle_segmentation_fault): New function. (print_signal_received_reason): Use handle_segmentation_fault. gdb/testsuite/ChangeLog: * gdb.arch/i386-mpx-sigsegv.c: New file. * gdb.arch/i386-mpx-sigsegv.exp: New file. * gdb.arch/i386-mpx-simple_segv.c: New file. * gdb.arch/i386-mpx-simple_segv.exp: New file. gdb/doc/ChangeLog: * gdb.texinfo (Signals): Add bound violation display hints for a SIGSEGV.
2016-02-18 17:24:59 +01:00
struct ui_out;
1999-06-14 20:08:47 +02:00
#include "regcache.h"
gdb/ 2012-11-09 Pedro Alves <palves@redhat.com> * gdbarch.sh (target_gdbarch) <gdbarch.h>: Reimplement as macro. (get_target_gdbarch) <gdbarch.h>: New function. (startup_gdbarch) <gdbarch.h>: Declare. <gdbarch.c> (target_gdbarch): Delete. <gdbarch.c> (deprecated_target_gdbarch_select_hack): Set the current inferior's gdbarch. <gdbarch.c> (get_target_gdbarch): New function. * inferior.c: Include target-descriptions.h. (free_inferior): Free target description info. (add_inferior_with_spaces): Set the inferior's initial architecture. (clone_inferior_command): Copy the original inferior's target description if it was user specified. (initialize_inferiors): Add comment. * inferior.h (struct target_desc_info): Forward declare. (struct inferior) <gdbarch>: New field. * linux-nat.c: Include target-descriptions.h. (linux_child_follow_fork): Copy the parent's architecture and target description to the child. * target-descriptions.c: Include inferior.h. (struct target_desc_info): New structure, holding the equivalents of ... (target_desc_fetched, current_target_desc) (target_description_filename): ... these removed globals. (get_tdesc_info, target_desc_info_from_user_p) (copy_inferior_target_desc_info, target_desc_info_free): New. (target_desc_fetched, current_target_desc) (target_description_filename): Reimplemented as convenience macros. (tdesc_filename_cmd_string): New global. (set_tdesc_filename_cmd): Copy the string manipulated by the "set tdescs filename ..." commands to the per-inferior equivalent. (show_tdesc_filename_cmd): Get the value to show from the per-inferior description filename. (_initilize_target_descriptions): Change the "set/show tdesc filename" commands' variable. * target-descriptions.h (struct target_desc, struct target_desc_info) (struct inferior): Forward declare. (target_find_description, target_clear_description) (target_current_description): Adjust comments. (copy_inferior_target_desc_info, target_desc_info_free) (target_desc_info_from_user_p). Declare. gdb/testsuite/ 2012-11-09 Pedro Alves <palves@redhat.com> * gdb.multi/multi-arch.exp: New.
2012-11-09 02:47:20 +01:00
/* The architecture associated with the inferior through the
connection to the target.
The architecture vector provides some information that is really a
property of the inferior, accessed through a particular target:
ptrace operations; the layout of certain RSP packets; the solib_ops
vector; etc. To differentiate architecture accesses to
per-inferior/target properties from
per-thread/per-frame/per-objfile properties, accesses to
per-inferior/target properties should be made through this
gdbarch. */
/* This is a convenience wrapper for 'current_inferior ()->gdbarch'. */
extern struct gdbarch *target_gdbarch (void);
gdb/ 2012-11-09 Pedro Alves <palves@redhat.com> * gdbarch.sh (target_gdbarch) <gdbarch.h>: Reimplement as macro. (get_target_gdbarch) <gdbarch.h>: New function. (startup_gdbarch) <gdbarch.h>: Declare. <gdbarch.c> (target_gdbarch): Delete. <gdbarch.c> (deprecated_target_gdbarch_select_hack): Set the current inferior's gdbarch. <gdbarch.c> (get_target_gdbarch): New function. * inferior.c: Include target-descriptions.h. (free_inferior): Free target description info. (add_inferior_with_spaces): Set the inferior's initial architecture. (clone_inferior_command): Copy the original inferior's target description if it was user specified. (initialize_inferiors): Add comment. * inferior.h (struct target_desc_info): Forward declare. (struct inferior) <gdbarch>: New field. * linux-nat.c: Include target-descriptions.h. (linux_child_follow_fork): Copy the parent's architecture and target description to the child. * target-descriptions.c: Include inferior.h. (struct target_desc_info): New structure, holding the equivalents of ... (target_desc_fetched, current_target_desc) (target_description_filename): ... these removed globals. (get_tdesc_info, target_desc_info_from_user_p) (copy_inferior_target_desc_info, target_desc_info_free): New. (target_desc_fetched, current_target_desc) (target_description_filename): Reimplemented as convenience macros. (tdesc_filename_cmd_string): New global. (set_tdesc_filename_cmd): Copy the string manipulated by the "set tdescs filename ..." commands to the per-inferior equivalent. (show_tdesc_filename_cmd): Get the value to show from the per-inferior description filename. (_initilize_target_descriptions): Change the "set/show tdesc filename" commands' variable. * target-descriptions.h (struct target_desc, struct target_desc_info) (struct inferior): Forward declare. (target_find_description, target_clear_description) (target_current_description): Adjust comments. (copy_inferior_target_desc_info, target_desc_info_free) (target_desc_info_from_user_p). Declare. gdb/testsuite/ 2012-11-09 Pedro Alves <palves@redhat.com> * gdb.multi/multi-arch.exp: New.
2012-11-09 02:47:20 +01:00
New "iterate_over_objfiles_in_search_order" gdbarch method. This patch introduces the "iterate_over_objfiles_in_search_order" gdbarch method, as well as its default implementation, and converts the areas where it will matter to using this gdbarch method. The default method implementation is the only one installed, and the changes should have no functional impact in terms of behavior. This only paves the way for the architectures that will need their own version. gdb/ChangeLog: * gdbarch.sh: Add generation of "iterate_over_objfiles_in_search_order_cb_ftype" typedef in gdbarch.h. Add include of "objfiles.h" in gdbarch.c. (iterate_over_objfiles_in_search_order): New gdbarch method. * gdbarch.h, gdbarch.c: Regenerate. * objfiles.h (default_iterate_over_objfiles_in_search_order): Add declaration. * objfiles.c (default_iterate_over_objfiles_in_search_order): New function. * symtab.c (lookup_symbol_aux_objfile): New function, extracted out of lookup_symbol_aux_symtabs. (lookup_symbol_aux_symtabs): Replace extracted-out code by call to lookup_symbol_aux_objfile. (struct global_sym_lookup_data): New type. (lookup_symbol_global_iterator_cb): New function. (lookup_symbol_global): Search for symbol using gdbarch_iterate_over_objfiles_in_search_order and lookup_symbol_global_iterator_cb. * findvar.c (struct minsym_lookup_data): New type. (minsym_lookup_iterator_cb): New function. (default_read_var_value) [case LOC_UNRESOLVED]: Resolve the symbol's address via gdbarch_iterate_over_objfiles_in_search_order and minsym_lookup_iterator_cb.
2012-06-05 15:50:50 +02:00
/* Callback type for the 'iterate_over_objfiles_in_search_order'
gdbarch method. */
typedef int (iterate_over_objfiles_in_search_order_cb_ftype)
(struct objfile *objfile, void *cb_data);
Fix internal error when core file section is too big As reported in PR 17808, a test case with a forged (invalid) core file can crash GDB with an assertion failure. In that particular case the prstatus of an i386 core file looks like that from an AMD64 core file. Consequently the respective regset supply function i386_supply_gregset is invoked with a larger buffer than usual. But i386_supply_gregset asserts a specific buffer size, and this assertion fails. The patch relaxes all buffer size assertions in regset supply functions such that they merely check for a sufficiently large buffer. For consistency the regset collect functions are adjusted as well. gdb/ChangeLog: PR corefiles/17808: * gdbarch.sh (iterate_over_regset_sections_cb): Document this function type, particularly its SIZE parameter. * gdbarch.h: Regenerate. * amd64-tdep.c (amd64_supply_fpregset): In gdb_assert, compare actual against required size using ">=" instead of "==". (amd64_collect_fpregset): Likewise. * i386-tdep.c (i386_supply_gregset): Likewise. (i386_collect_gregset): Likewise. (i386_supply_fpregset): Likewise. (i386_collect_fpregset): Likewise. * mips-linux-tdep.c (mips_supply_gregset_wrapper): Likewise. (mips_fill_gregset_wrapper): Likewise. (mips_supply_fpregset_wrapper): Likewise. (mips_fill_fpregset_wrapper): Likewise. (mips64_supply_gregset_wrapper): Likewise. (mips64_fill_gregset_wrapper): Likewise. (mips64_supply_fpregset_wrapper): Likewise. (mips64_fill_fpregset_wrapper): Likewise. * mn10300-linux-tdep.c (am33_supply_gregset_method): Likewise. (am33_supply_fpregset_method): Likewise. (am33_collect_gregset_method): Likewise. (am33_collect_fpregset_method): Likewise.
2015-01-14 13:01:38 +01:00
/* Callback type for regset section iterators. The callback usually
invokes the REGSET's supply or collect method, to which it must
Split size in regset section iterators In the existing code, when using the regset section iteration functions, the size parameter is used in different ways. With collect, size is used to create the buffer in which to write the regset. (see linux-tdep.c::linux_collect_regset_section_cb). With supply, size is used to confirm the existing regset is the correct size. If REGSET_VARIABLE_SIZE is set then the regset can be bigger than size. Effectively, size is the minimum possible size of the regset. (see corelow.c::get_core_register_section). There are currently no targets with both REGSET_VARIABLE_SIZE and a collect function. In SVE, a corefile can contain one of two formats after the header, both of which are different sizes. However, when writing a core file, we always want to write out the full bigger size. To allow support of collects for REGSET_VARIABLE_SIZE we need two sizes. This is done by adding supply_size and collect_size. gdb/ * aarch64-fbsd-tdep.c (aarch64_fbsd_iterate_over_regset_sections): Add supply_size and collect_size. * aarch64-linux-tdep.c (aarch64_linux_iterate_over_regset_sections): Likewise. * alpha-linux-tdep.c (alpha_linux_iterate_over_regset_sections): * alpha-nbsd-tdep.c (alphanbsd_iterate_over_regset_sections): Likewise. * amd64-fbsd-tdep.c (amd64fbsd_iterate_over_regset_sections): Likewise. * amd64-linux-tdep.c (amd64_linux_iterate_over_regset_sections): Likewise. * arm-bsd-tdep.c (armbsd_iterate_over_regset_sections): Likewise. * arm-fbsd-tdep.c (arm_fbsd_iterate_over_regset_sections): Likewise. * arm-linux-tdep.c (arm_linux_iterate_over_regset_sections): Likewise. * corelow.c (get_core_registers_cb): Likewise. (core_target::fetch_registers): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * frv-linux-tdep.c (frv_linux_iterate_over_regset_sections): Likewise. * gdbarch.h (void): Regenerate. * gdbarch.sh: Add supply_size and collect_size. * hppa-linux-tdep.c (hppa_linux_iterate_over_regset_sections): Likewise. * hppa-nbsd-tdep.c (hppanbsd_iterate_over_regset_sections): Likewise. * hppa-obsd-tdep.c (hppaobsd_iterate_over_regset_sections): Likewise. * i386-fbsd-tdep.c (i386fbsd_iterate_over_regset_sections): Likewise. * i386-linux-tdep.c (i386_linux_iterate_over_regset_sections): Likewise. * i386-tdep.c (i386_iterate_over_regset_sections): Likewise. * ia64-linux-tdep.c (ia64_linux_iterate_over_regset_sections): Likewise. * linux-tdep.c (linux_collect_regset_section_cb): Likewise. * m32r-linux-tdep.c (m32r_linux_iterate_over_regset_sections): Likewise. * m68k-bsd-tdep.c (m68kbsd_iterate_over_regset_sections): Likewise. * m68k-linux-tdep.c (m68k_linux_iterate_over_regset_sections): Likewise. * mips-fbsd-tdep.c (mips_fbsd_iterate_over_regset_sections): Likewise. * mips-linux-tdep.c (mips_linux_iterate_over_regset_sections): Likewise. * mips-nbsd-tdep.c (mipsnbsd_iterate_over_regset_sections): Likewise. * mips64-obsd-tdep.c (mips64obsd_iterate_over_regset_sections): Likewise. * mn10300-linux-tdep.c (am33_iterate_over_regset_sections): Likewise. * nios2-linux-tdep.c (nios2_iterate_over_regset_sections): Likewise. * ppc-fbsd-tdep.c (ppcfbsd_iterate_over_regset_sections): Likewise. * ppc-linux-tdep.c (ppc_linux_iterate_over_regset_sections): Likewise. * ppc-nbsd-tdep.c (ppcnbsd_iterate_over_regset_sections): Likewise. * ppc-obsd-tdep.c (ppcobsd_iterate_over_regset_sections): Likewise. * riscv-linux-tdep.c (riscv_linux_iterate_over_regset_sections): Likewise. * rs6000-aix-tdep.c (rs6000_aix_iterate_over_regset_sections): Likewise. * s390-linux-tdep.c (s390_iterate_over_regset_sections): Likewise. * score-tdep.c (score7_linux_iterate_over_regset_sections): Likewise. * sh-tdep.c (sh_iterate_over_regset_sections): Likewise. * sparc-tdep.c (sparc_iterate_over_regset_sections): Likewise. * tilegx-linux-tdep.c (tilegx_iterate_over_regset_sections): Likewise. * vax-tdep.c (vax_iterate_over_regset_sections): Likewise. * xtensa-tdep.c (xtensa_iterate_over_regset_sections): Likewise.
2018-08-13 11:04:11 +02:00
pass a buffer - for collects this buffer will need to be created using
COLLECT_SIZE, for supply the existing buffer being read from should
be at least SUPPLY_SIZE. SECT_NAME is a BFD section name, and HUMAN_NAME
is used for diagnostic messages. CB_DATA should have been passed
unchanged through the iterator. */
Fix internal error when core file section is too big As reported in PR 17808, a test case with a forged (invalid) core file can crash GDB with an assertion failure. In that particular case the prstatus of an i386 core file looks like that from an AMD64 core file. Consequently the respective regset supply function i386_supply_gregset is invoked with a larger buffer than usual. But i386_supply_gregset asserts a specific buffer size, and this assertion fails. The patch relaxes all buffer size assertions in regset supply functions such that they merely check for a sufficiently large buffer. For consistency the regset collect functions are adjusted as well. gdb/ChangeLog: PR corefiles/17808: * gdbarch.sh (iterate_over_regset_sections_cb): Document this function type, particularly its SIZE parameter. * gdbarch.h: Regenerate. * amd64-tdep.c (amd64_supply_fpregset): In gdb_assert, compare actual against required size using ">=" instead of "==". (amd64_collect_fpregset): Likewise. * i386-tdep.c (i386_supply_gregset): Likewise. (i386_collect_gregset): Likewise. (i386_supply_fpregset): Likewise. (i386_collect_fpregset): Likewise. * mips-linux-tdep.c (mips_supply_gregset_wrapper): Likewise. (mips_fill_gregset_wrapper): Likewise. (mips_supply_fpregset_wrapper): Likewise. (mips_fill_fpregset_wrapper): Likewise. (mips64_supply_gregset_wrapper): Likewise. (mips64_fill_gregset_wrapper): Likewise. (mips64_supply_fpregset_wrapper): Likewise. (mips64_fill_fpregset_wrapper): Likewise. * mn10300-linux-tdep.c (am33_supply_gregset_method): Likewise. (am33_supply_fpregset_method): Likewise. (am33_collect_gregset_method): Likewise. (am33_collect_fpregset_method): Likewise.
2015-01-14 13:01:38 +01:00
Replace 'core_regset_sections' by iterator method The core_regset_sections list in gdbarch (needed for multi-arch capable core file generation support) is replaced by an iterator method. Overall, this reduces the code a bit, and it allows for more flexibility. gdb/ChangeLog: * amd64-linux-tdep.c (amd64_linux_regset_sections): Remove. (amd64_linux_iterate_over_regset_sections): New. (amd64_linux_init_abi_common): Don't install the regset section list, but the new iterator in gdbarch. * arm-linux-tdep.c (arm_linux_fpa_regset_sections) (arm_linux_vfp_regset_sections): Remove. Move combined logic... (arm_linux_iterate_over_regset_sections): ...here. New function. (arm_linux_init_abi): Set iterator instead of section list. * corelow.c (get_core_registers_cb): New function, logic moved from... (get_core_registers): ...loop body here. Use new iterator method instead of walking through the regset section list. * gdbarch.sh: Remove 'core_regset_sections'. New method 'iterate_over_regset_sections'. New typedef 'iterate_over_regset_sections_cb'. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * i386-linux-tdep.c (i386_linux_regset_sections) (i386_linux_sse_regset_sections, i386_linux_avx_regset_sections): Remove. (i386_linux_iterate_over_regset_sections): New. (i386_linux_init_abi): Don't choose a regset section list, but install new iterator in gdbarch. * linux-tdep.c (struct linux_collect_regset_section_cb_data): New. (linux_collect_regset_section_cb): New function, logic moved from... (linux_collect_thread_registers): ...loop body here. Use iterator method instead of walking through list. (linux_make_corefile_notes_1): Check for presence of iterator method instead of regset section list. * ppc-linux-tdep.c (ppc_linux_vsx_regset_sections) (ppc_linux_vmx_regset_sections, ppc_linux_fp_regset_sections) (ppc64_linux_vsx_regset_sections, ppc64_linux_vmx_regset_sections) (ppc64_linux_fp_regset_sections): Remove. Move combined logic... (ppc_linux_iterate_over_regset_sections): ...here. New function. (ppc_linux_init_abi): Don't choose from above regset section lists, but install new iterator in gdbarch. * regset.h (struct core_regset_section): Remove. * s390-linux-tdep.c (struct gdbarch_tdep): Add new fields have_linux_v1, have_linux_v2, and have_tdb. (s390_linux32_regset_sections, s390_linux32v1_regset_sections) (s390_linux32v2_regset_sections, s390_linux64_regset_sections) (s390_linux64v1_regset_sections, s390_linux64v2_regset_sections) (s390x_linux64_regset_sections, s390x_linux64v1_regset_sections) (s390x_linux64v2_regset_sections): Remove. Move combined logic... (s390_iterate_over_regset_sections): ...here. New function. Use new tdep fields. (s390_gdbarch_init): Set new tdep fields. Don't choose from above regset section lists, but install new iterator.
2014-09-04 17:26:43 +02:00
typedef void (iterate_over_regset_sections_cb)
Split size in regset section iterators In the existing code, when using the regset section iteration functions, the size parameter is used in different ways. With collect, size is used to create the buffer in which to write the regset. (see linux-tdep.c::linux_collect_regset_section_cb). With supply, size is used to confirm the existing regset is the correct size. If REGSET_VARIABLE_SIZE is set then the regset can be bigger than size. Effectively, size is the minimum possible size of the regset. (see corelow.c::get_core_register_section). There are currently no targets with both REGSET_VARIABLE_SIZE and a collect function. In SVE, a corefile can contain one of two formats after the header, both of which are different sizes. However, when writing a core file, we always want to write out the full bigger size. To allow support of collects for REGSET_VARIABLE_SIZE we need two sizes. This is done by adding supply_size and collect_size. gdb/ * aarch64-fbsd-tdep.c (aarch64_fbsd_iterate_over_regset_sections): Add supply_size and collect_size. * aarch64-linux-tdep.c (aarch64_linux_iterate_over_regset_sections): Likewise. * alpha-linux-tdep.c (alpha_linux_iterate_over_regset_sections): * alpha-nbsd-tdep.c (alphanbsd_iterate_over_regset_sections): Likewise. * amd64-fbsd-tdep.c (amd64fbsd_iterate_over_regset_sections): Likewise. * amd64-linux-tdep.c (amd64_linux_iterate_over_regset_sections): Likewise. * arm-bsd-tdep.c (armbsd_iterate_over_regset_sections): Likewise. * arm-fbsd-tdep.c (arm_fbsd_iterate_over_regset_sections): Likewise. * arm-linux-tdep.c (arm_linux_iterate_over_regset_sections): Likewise. * corelow.c (get_core_registers_cb): Likewise. (core_target::fetch_registers): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * frv-linux-tdep.c (frv_linux_iterate_over_regset_sections): Likewise. * gdbarch.h (void): Regenerate. * gdbarch.sh: Add supply_size and collect_size. * hppa-linux-tdep.c (hppa_linux_iterate_over_regset_sections): Likewise. * hppa-nbsd-tdep.c (hppanbsd_iterate_over_regset_sections): Likewise. * hppa-obsd-tdep.c (hppaobsd_iterate_over_regset_sections): Likewise. * i386-fbsd-tdep.c (i386fbsd_iterate_over_regset_sections): Likewise. * i386-linux-tdep.c (i386_linux_iterate_over_regset_sections): Likewise. * i386-tdep.c (i386_iterate_over_regset_sections): Likewise. * ia64-linux-tdep.c (ia64_linux_iterate_over_regset_sections): Likewise. * linux-tdep.c (linux_collect_regset_section_cb): Likewise. * m32r-linux-tdep.c (m32r_linux_iterate_over_regset_sections): Likewise. * m68k-bsd-tdep.c (m68kbsd_iterate_over_regset_sections): Likewise. * m68k-linux-tdep.c (m68k_linux_iterate_over_regset_sections): Likewise. * mips-fbsd-tdep.c (mips_fbsd_iterate_over_regset_sections): Likewise. * mips-linux-tdep.c (mips_linux_iterate_over_regset_sections): Likewise. * mips-nbsd-tdep.c (mipsnbsd_iterate_over_regset_sections): Likewise. * mips64-obsd-tdep.c (mips64obsd_iterate_over_regset_sections): Likewise. * mn10300-linux-tdep.c (am33_iterate_over_regset_sections): Likewise. * nios2-linux-tdep.c (nios2_iterate_over_regset_sections): Likewise. * ppc-fbsd-tdep.c (ppcfbsd_iterate_over_regset_sections): Likewise. * ppc-linux-tdep.c (ppc_linux_iterate_over_regset_sections): Likewise. * ppc-nbsd-tdep.c (ppcnbsd_iterate_over_regset_sections): Likewise. * ppc-obsd-tdep.c (ppcobsd_iterate_over_regset_sections): Likewise. * riscv-linux-tdep.c (riscv_linux_iterate_over_regset_sections): Likewise. * rs6000-aix-tdep.c (rs6000_aix_iterate_over_regset_sections): Likewise. * s390-linux-tdep.c (s390_iterate_over_regset_sections): Likewise. * score-tdep.c (score7_linux_iterate_over_regset_sections): Likewise. * sh-tdep.c (sh_iterate_over_regset_sections): Likewise. * sparc-tdep.c (sparc_iterate_over_regset_sections): Likewise. * tilegx-linux-tdep.c (tilegx_iterate_over_regset_sections): Likewise. * vax-tdep.c (vax_iterate_over_regset_sections): Likewise. * xtensa-tdep.c (xtensa_iterate_over_regset_sections): Likewise.
2018-08-13 11:04:11 +02:00
(const char *sect_name, int supply_size, int collect_size,
const struct regset *regset, const char *human_name, void *cb_data);
Replace 'core_regset_sections' by iterator method The core_regset_sections list in gdbarch (needed for multi-arch capable core file generation support) is replaced by an iterator method. Overall, this reduces the code a bit, and it allows for more flexibility. gdb/ChangeLog: * amd64-linux-tdep.c (amd64_linux_regset_sections): Remove. (amd64_linux_iterate_over_regset_sections): New. (amd64_linux_init_abi_common): Don't install the regset section list, but the new iterator in gdbarch. * arm-linux-tdep.c (arm_linux_fpa_regset_sections) (arm_linux_vfp_regset_sections): Remove. Move combined logic... (arm_linux_iterate_over_regset_sections): ...here. New function. (arm_linux_init_abi): Set iterator instead of section list. * corelow.c (get_core_registers_cb): New function, logic moved from... (get_core_registers): ...loop body here. Use new iterator method instead of walking through the regset section list. * gdbarch.sh: Remove 'core_regset_sections'. New method 'iterate_over_regset_sections'. New typedef 'iterate_over_regset_sections_cb'. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * i386-linux-tdep.c (i386_linux_regset_sections) (i386_linux_sse_regset_sections, i386_linux_avx_regset_sections): Remove. (i386_linux_iterate_over_regset_sections): New. (i386_linux_init_abi): Don't choose a regset section list, but install new iterator in gdbarch. * linux-tdep.c (struct linux_collect_regset_section_cb_data): New. (linux_collect_regset_section_cb): New function, logic moved from... (linux_collect_thread_registers): ...loop body here. Use iterator method instead of walking through list. (linux_make_corefile_notes_1): Check for presence of iterator method instead of regset section list. * ppc-linux-tdep.c (ppc_linux_vsx_regset_sections) (ppc_linux_vmx_regset_sections, ppc_linux_fp_regset_sections) (ppc64_linux_vsx_regset_sections, ppc64_linux_vmx_regset_sections) (ppc64_linux_fp_regset_sections): Remove. Move combined logic... (ppc_linux_iterate_over_regset_sections): ...here. New function. (ppc_linux_init_abi): Don't choose from above regset section lists, but install new iterator in gdbarch. * regset.h (struct core_regset_section): Remove. * s390-linux-tdep.c (struct gdbarch_tdep): Add new fields have_linux_v1, have_linux_v2, and have_tdb. (s390_linux32_regset_sections, s390_linux32v1_regset_sections) (s390_linux32v2_regset_sections, s390_linux64_regset_sections) (s390_linux64v1_regset_sections, s390_linux64v2_regset_sections) (s390x_linux64_regset_sections, s390x_linux64v1_regset_sections) (s390x_linux64v2_regset_sections): Remove. Move combined logic... (s390_iterate_over_regset_sections): ...here. New function. Use new tdep fields. (s390_gdbarch_init): Set new tdep fields. Don't choose from above regset section lists, but install new iterator.
2014-09-04 17:26:43 +02:00
/* For a function call, does the function return a value using a
normal value return or a structure return - passing a hidden
argument pointing to storage. For the latter, there are two
cases: language-mandated structure return and target ABI
structure return. */
enum function_call_return_method
{
/* Standard value return. */
return_method_normal = 0,
/* Language ABI structure return. This is handled
by passing the return location as the first parameter to
the function, even preceding "this". */
return_method_hidden_param,
/* Target ABI struct return. This is target-specific; for instance,
on ia64 the first argument is passed in out0 but the hidden
structure return pointer would normally be passed in r8. */
return_method_struct,
};
1999-06-14 20:08:47 +02:00
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
/* The following are pre-initialized by GDBARCH. */
1999-06-14 20:08:47 +02:00
1999-08-31 03:14:27 +02:00
extern const struct bfd_arch_info * gdbarch_bfd_arch_info (struct gdbarch *gdbarch);
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
/* set_gdbarch_bfd_arch_info() - not applicable - pre-initialized. */
1999-06-14 20:08:47 +02:00
extern enum bfd_endian gdbarch_byte_order (struct gdbarch *gdbarch);
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
/* set_gdbarch_byte_order() - not applicable - pre-initialized. */
1999-06-14 20:08:47 +02:00
extern enum bfd_endian gdbarch_byte_order_for_code (struct gdbarch *gdbarch);
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
/* set_gdbarch_byte_order_for_code() - not applicable - pre-initialized. */
extern enum gdb_osabi gdbarch_osabi (struct gdbarch *gdbarch);
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
/* set_gdbarch_osabi() - not applicable - pre-initialized. */
extern const struct target_desc * gdbarch_target_desc (struct gdbarch *gdbarch);
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
/* set_gdbarch_target_desc() - not applicable - pre-initialized. */
1999-06-14 20:08:47 +02:00
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
/* The following are initialized by the target dependent code. */
1999-06-14 20:08:47 +02:00
/* The bit byte-order has to do just with numbering of bits in debugging symbols
and such. Conceptually, it's quite separate from byte/word byte order. */
extern int gdbarch_bits_big_endian (struct gdbarch *gdbarch);
extern void set_gdbarch_bits_big_endian (struct gdbarch *gdbarch, int bits_big_endian);
/* Number of bits in a short or unsigned short for the target machine. */
1999-12-14 02:06:04 +01:00
1999-08-31 03:14:27 +02:00
extern int gdbarch_short_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_short_bit (struct gdbarch *gdbarch, int short_bit);
1999-06-14 20:08:47 +02:00
2000-08-11 04:55:38 +02:00
/* Number of bits in an int or unsigned int for the target machine. */
1999-08-31 03:14:27 +02:00
extern int gdbarch_int_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_int_bit (struct gdbarch *gdbarch, int int_bit);
1999-06-14 20:08:47 +02:00
2000-08-11 04:55:38 +02:00
/* Number of bits in a long or unsigned long for the target machine. */
1999-08-31 03:14:27 +02:00
extern int gdbarch_long_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_long_bit (struct gdbarch *gdbarch, int long_bit);
1999-06-14 20:08:47 +02:00
2000-08-11 04:55:38 +02:00
/* Number of bits in a long long or unsigned long long for the target
machine. */
1999-08-31 03:14:27 +02:00
extern int gdbarch_long_long_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_long_long_bit (struct gdbarch *gdbarch, int long_long_bit);
1999-06-14 20:08:47 +02:00
/* The ABI default bit-size and format for "half", "float", "double", and
"long double". These bit/format pairs should eventually be combined
into a single object. For the moment, just initialize them as a pair.
* doublest.c (floatformat_from_length): Use the right element from gdbarch floatformats. (floatformat_from_type, extract_typed_floating) (store_typed_floating): Likewise. * doublest.h: Remove declarations for undefined floatformat arrays. * gdbarch.sh (float_format, double_format, long_double_format): Change to pairs. (pformat): Update for pairs. * gdbarch.c, gdbarch.h: Regenerated. * gdbtypes.c (floatformats_ieee_single, floatformats_ieee_double) (floatformats_ieee_double_littlebyte_bigword) (floatformats_i387_ext, floatformats_m68881_ext, floatformats_arm_ext) (floatformats_ia64_spill, floatformats_ia64_quad, floatformats_vax_f) (floatformats_vax_d): New variables. (builtin_type_ieee_single, builtin_type_ieee_double) (builtin_type_arm_ext, builtin_type_ia64_spill) (builtin_type_ia64_quad): Replace arrays with individual types. (builtin_type_ieee_single_big, builtin_type_ieee_single_little) (builtin_type_ieee_double_big, builtin_type_ieee_double_little) (builtin_type_ieee_double_littlebyte_bigword, builtin_type_i960_ext) (builtin_type_m88110_ext, builtin_type_m88110_harris_ext) (builtin_type_arm_ext_big, builtin_type_arm_ext_littlebyte_bigword) (builtin_type_ia64_spill_big, builtin_type_ia64_spill_little) (builtin_type_ia64_quad_big, builtin_type_ia64_quad_little): Delete unused and endian-specific types. (recursive_dump_type): Update for floatformat pairs. (build_flt): Move higher. Handle bit == -1. Take a floatformat pair. (build_gdbtypes): Use build_flt. (_initialize_gdbtypes): Update set of initialized types. * gdbtypes.h: Update declarations to match gdbtypes.c. (struct main_type): Store a pointer to two floatformats. * arch-utils.c (default_float_format, default_double_format): Delete. * arch-utils.h (default_float_format, default_double_format): Delete. * arm-tdep.c, avr-tdep.c, hppa-tdep.c, hppabsd-tdep.c, i386-tdep.c, ia64-tdep.c, iq2000-tdep.c, m68k-tdep.c, m88k-tdep.c, mips-linux-tdep.c, mips-tdep.c, mt-tdep.c, ppcobsd-tdep.c, sparc-linux-tdep.c, sparc-tdep.c, sparcnbsd-tdep.c, spu-tdep.c, vax-tdep.c, alpha-tdep.c, ppc-sysv-tdep.c: Update.
2007-01-29 18:31:06 +01:00
Each format describes both the big and little endian layouts (if
useful). */
2000-08-11 04:55:38 +02:00
extern int gdbarch_half_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_half_bit (struct gdbarch *gdbarch, int half_bit);
extern const struct floatformat ** gdbarch_half_format (struct gdbarch *gdbarch);
extern void set_gdbarch_half_format (struct gdbarch *gdbarch, const struct floatformat ** half_format);
1999-08-31 03:14:27 +02:00
extern int gdbarch_float_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_float_bit (struct gdbarch *gdbarch, int float_bit);
1999-06-14 20:08:47 +02:00
* doublest.c (floatformat_from_length): Use the right element from gdbarch floatformats. (floatformat_from_type, extract_typed_floating) (store_typed_floating): Likewise. * doublest.h: Remove declarations for undefined floatformat arrays. * gdbarch.sh (float_format, double_format, long_double_format): Change to pairs. (pformat): Update for pairs. * gdbarch.c, gdbarch.h: Regenerated. * gdbtypes.c (floatformats_ieee_single, floatformats_ieee_double) (floatformats_ieee_double_littlebyte_bigword) (floatformats_i387_ext, floatformats_m68881_ext, floatformats_arm_ext) (floatformats_ia64_spill, floatformats_ia64_quad, floatformats_vax_f) (floatformats_vax_d): New variables. (builtin_type_ieee_single, builtin_type_ieee_double) (builtin_type_arm_ext, builtin_type_ia64_spill) (builtin_type_ia64_quad): Replace arrays with individual types. (builtin_type_ieee_single_big, builtin_type_ieee_single_little) (builtin_type_ieee_double_big, builtin_type_ieee_double_little) (builtin_type_ieee_double_littlebyte_bigword, builtin_type_i960_ext) (builtin_type_m88110_ext, builtin_type_m88110_harris_ext) (builtin_type_arm_ext_big, builtin_type_arm_ext_littlebyte_bigword) (builtin_type_ia64_spill_big, builtin_type_ia64_spill_little) (builtin_type_ia64_quad_big, builtin_type_ia64_quad_little): Delete unused and endian-specific types. (recursive_dump_type): Update for floatformat pairs. (build_flt): Move higher. Handle bit == -1. Take a floatformat pair. (build_gdbtypes): Use build_flt. (_initialize_gdbtypes): Update set of initialized types. * gdbtypes.h: Update declarations to match gdbtypes.c. (struct main_type): Store a pointer to two floatformats. * arch-utils.c (default_float_format, default_double_format): Delete. * arch-utils.h (default_float_format, default_double_format): Delete. * arm-tdep.c, avr-tdep.c, hppa-tdep.c, hppabsd-tdep.c, i386-tdep.c, ia64-tdep.c, iq2000-tdep.c, m68k-tdep.c, m88k-tdep.c, mips-linux-tdep.c, mips-tdep.c, mt-tdep.c, ppcobsd-tdep.c, sparc-linux-tdep.c, sparc-tdep.c, sparcnbsd-tdep.c, spu-tdep.c, vax-tdep.c, alpha-tdep.c, ppc-sysv-tdep.c: Update.
2007-01-29 18:31:06 +01:00
extern const struct floatformat ** gdbarch_float_format (struct gdbarch *gdbarch);
extern void set_gdbarch_float_format (struct gdbarch *gdbarch, const struct floatformat ** float_format);
2000-08-11 04:55:38 +02:00
1999-08-31 03:14:27 +02:00
extern int gdbarch_double_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_double_bit (struct gdbarch *gdbarch, int double_bit);
1999-06-14 20:08:47 +02:00
* doublest.c (floatformat_from_length): Use the right element from gdbarch floatformats. (floatformat_from_type, extract_typed_floating) (store_typed_floating): Likewise. * doublest.h: Remove declarations for undefined floatformat arrays. * gdbarch.sh (float_format, double_format, long_double_format): Change to pairs. (pformat): Update for pairs. * gdbarch.c, gdbarch.h: Regenerated. * gdbtypes.c (floatformats_ieee_single, floatformats_ieee_double) (floatformats_ieee_double_littlebyte_bigword) (floatformats_i387_ext, floatformats_m68881_ext, floatformats_arm_ext) (floatformats_ia64_spill, floatformats_ia64_quad, floatformats_vax_f) (floatformats_vax_d): New variables. (builtin_type_ieee_single, builtin_type_ieee_double) (builtin_type_arm_ext, builtin_type_ia64_spill) (builtin_type_ia64_quad): Replace arrays with individual types. (builtin_type_ieee_single_big, builtin_type_ieee_single_little) (builtin_type_ieee_double_big, builtin_type_ieee_double_little) (builtin_type_ieee_double_littlebyte_bigword, builtin_type_i960_ext) (builtin_type_m88110_ext, builtin_type_m88110_harris_ext) (builtin_type_arm_ext_big, builtin_type_arm_ext_littlebyte_bigword) (builtin_type_ia64_spill_big, builtin_type_ia64_spill_little) (builtin_type_ia64_quad_big, builtin_type_ia64_quad_little): Delete unused and endian-specific types. (recursive_dump_type): Update for floatformat pairs. (build_flt): Move higher. Handle bit == -1. Take a floatformat pair. (build_gdbtypes): Use build_flt. (_initialize_gdbtypes): Update set of initialized types. * gdbtypes.h: Update declarations to match gdbtypes.c. (struct main_type): Store a pointer to two floatformats. * arch-utils.c (default_float_format, default_double_format): Delete. * arch-utils.h (default_float_format, default_double_format): Delete. * arm-tdep.c, avr-tdep.c, hppa-tdep.c, hppabsd-tdep.c, i386-tdep.c, ia64-tdep.c, iq2000-tdep.c, m68k-tdep.c, m88k-tdep.c, mips-linux-tdep.c, mips-tdep.c, mt-tdep.c, ppcobsd-tdep.c, sparc-linux-tdep.c, sparc-tdep.c, sparcnbsd-tdep.c, spu-tdep.c, vax-tdep.c, alpha-tdep.c, ppc-sysv-tdep.c: Update.
2007-01-29 18:31:06 +01:00
extern const struct floatformat ** gdbarch_double_format (struct gdbarch *gdbarch);
extern void set_gdbarch_double_format (struct gdbarch *gdbarch, const struct floatformat ** double_format);
2000-08-11 04:55:38 +02:00
1999-08-31 03:14:27 +02:00
extern int gdbarch_long_double_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_long_double_bit (struct gdbarch *gdbarch, int long_double_bit);
1999-06-14 20:08:47 +02:00
* doublest.c (floatformat_from_length): Use the right element from gdbarch floatformats. (floatformat_from_type, extract_typed_floating) (store_typed_floating): Likewise. * doublest.h: Remove declarations for undefined floatformat arrays. * gdbarch.sh (float_format, double_format, long_double_format): Change to pairs. (pformat): Update for pairs. * gdbarch.c, gdbarch.h: Regenerated. * gdbtypes.c (floatformats_ieee_single, floatformats_ieee_double) (floatformats_ieee_double_littlebyte_bigword) (floatformats_i387_ext, floatformats_m68881_ext, floatformats_arm_ext) (floatformats_ia64_spill, floatformats_ia64_quad, floatformats_vax_f) (floatformats_vax_d): New variables. (builtin_type_ieee_single, builtin_type_ieee_double) (builtin_type_arm_ext, builtin_type_ia64_spill) (builtin_type_ia64_quad): Replace arrays with individual types. (builtin_type_ieee_single_big, builtin_type_ieee_single_little) (builtin_type_ieee_double_big, builtin_type_ieee_double_little) (builtin_type_ieee_double_littlebyte_bigword, builtin_type_i960_ext) (builtin_type_m88110_ext, builtin_type_m88110_harris_ext) (builtin_type_arm_ext_big, builtin_type_arm_ext_littlebyte_bigword) (builtin_type_ia64_spill_big, builtin_type_ia64_spill_little) (builtin_type_ia64_quad_big, builtin_type_ia64_quad_little): Delete unused and endian-specific types. (recursive_dump_type): Update for floatformat pairs. (build_flt): Move higher. Handle bit == -1. Take a floatformat pair. (build_gdbtypes): Use build_flt. (_initialize_gdbtypes): Update set of initialized types. * gdbtypes.h: Update declarations to match gdbtypes.c. (struct main_type): Store a pointer to two floatformats. * arch-utils.c (default_float_format, default_double_format): Delete. * arch-utils.h (default_float_format, default_double_format): Delete. * arm-tdep.c, avr-tdep.c, hppa-tdep.c, hppabsd-tdep.c, i386-tdep.c, ia64-tdep.c, iq2000-tdep.c, m68k-tdep.c, m88k-tdep.c, mips-linux-tdep.c, mips-tdep.c, mt-tdep.c, ppcobsd-tdep.c, sparc-linux-tdep.c, sparc-tdep.c, sparcnbsd-tdep.c, spu-tdep.c, vax-tdep.c, alpha-tdep.c, ppc-sysv-tdep.c: Update.
2007-01-29 18:31:06 +01:00
extern const struct floatformat ** gdbarch_long_double_format (struct gdbarch *gdbarch);
extern void set_gdbarch_long_double_format (struct gdbarch *gdbarch, const struct floatformat ** long_double_format);
Teach GDB that wchar_t is a built-in type in C++ mode GDB is currently not aware that wchar_t is a built-in type in C++ mode. This is usually not a problem because the debug info describes the type, so when you have a program loaded, you don't notice this. However, if you try expressions involving wchar_t before a program is loaded, gdb errors out: (gdb) p (wchar_t)-1 No symbol table is loaded. Use the "file" command. (gdb) p L"hello" No type named wchar_t. (gdb) ptype L"hello" No type named wchar_t. This commit teaches gdb about the type. After: (gdb) p (wchar_t)-1 $1 = -1 L'\xffffffff' (gdb) p L"hello" $2 = L"hello" (gdb) ptype L"hello" type = wchar_t [6] Unlike char16_t/char32_t, unfortunately, the underlying type of wchar_t is implementation dependent, both size and signness. So this requires adding a couple new gdbarch hooks. I grepped the GCC code base for WCHAR_TYPE and WCHAR_TYPE_SIZE, and it seems to me that the majority of the ABIs have a 4-byte signed wchar_t, so that's what I made the default for GDB too. And then I looked for which ports have a 16-bit and/or unsigned wchar_t, and made GDB follow suit. gdb/ChangeLog: 2017-04-12 Pedro Alves <palves@redhat.com> PR gdb/21323 * c-lang.c (cplus_primitive_types) <cplus_primitive_type_wchar_t>: New enum value. (cplus_language_arch_info): Register cplus_primitive_type_wchar_t. * gdbtypes.h (struct builtin_type) <builtin_wchar>: New field. * gdbtypes.c (gdbtypes_post_init): Create the "wchar_t" type. * gdbarch.sh (wchar_bit, wchar_signed): New per-arch values. * gdbarch.h, gdbarch.c: Regenerate. * aarch64-tdep.c (aarch64_gdbarch_init): Override gdbarch_wchar_bit and gdbarch_wchar_signed. * alpha-tdep.c (alpha_gdbarch_init): Likewise. * arm-tdep.c (arm_gdbarch_init): Likewise. * avr-tdep.c (avr_gdbarch_init): Likewise. * h8300-tdep.c (h8300_gdbarch_init): Likewise. * i386-nto-tdep.c (i386nto_init_abi): Likewise. * i386-tdep.c (i386_go32_init_abi): Likewise. * m32r-tdep.c (m32r_gdbarch_init): Likewise. * moxie-tdep.c (moxie_gdbarch_init): Likewise. * nds32-tdep.c (nds32_gdbarch_init): Likewise. * rs6000-aix-tdep.c (rs6000_aix_init_osabi): Likewise. * sh-tdep.c (sh_gdbarch_init): Likewise. * sparc-tdep.c (sparc32_gdbarch_init): Likewise. * sparc64-tdep.c (sparc64_init_abi): Likewise. * windows-tdep.c (windows_init_abi): Likewise. * xstormy16-tdep.c (xstormy16_gdbarch_init): Likewise. gdb/testsuite/ChangeLog: 2017-04-12 Pedro Alves <palves@redhat.com> PR gdb/21323 * gdb.cp/wide_char_types.c: Include <wchar.h>. (wchar): New global. * gdb.cp/wide_char_types.exp (wide_char_types_program) (do_test_wide_char, wide_char_types_no_program, top level): Add wchar_t testing.
2017-04-12 15:00:49 +02:00
/* The ABI default bit-size for "wchar_t". wchar_t is a built-in type
starting with C++11. */
extern int gdbarch_wchar_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_wchar_bit (struct gdbarch *gdbarch, int wchar_bit);
/* One if `wchar_t' is signed, zero if unsigned. */
extern int gdbarch_wchar_signed (struct gdbarch *gdbarch);
extern void set_gdbarch_wchar_signed (struct gdbarch *gdbarch, int wchar_signed);
Add gdbarch callback to provide formats for debug info float types At this point, all TYPE_CODE_FLT types carry their floating-point format, except for those creating from reading DWARF or stabs debug info. Those will be addressed by this commit. The main issue here is that we actually have to determine which floating- point format to use. Currently, we only have the type length as input to this decision. In the future, we may hopefully get --at least in DWARF-- additional information to help disambiguate multiple different formats of the same length. For now, we can still look at the type name as a hint. This decision logic is encapsulated in a gdbarch callback to allow platform-specific overrides. The default implementation use the same logic (compare type length against the various gdbarch_..._bit sizes) that is currently implemented in floatformat_from_length. With this commit, all platforms still use the default logic, so there should be no actual change in behavior. A follow-on commit will add support for __float128 on Intel and Power. Once dwarf2read.c and stabsread.c make use of the new callback to determine floating-point formats, we're now sure every TYPE_CODE_FLT type will always carry its format. The commit therefore adds asserts to verify_floatformat to ensure new code will continue to always provide formats, and removes the code in floatformat_from_type that used to handle types with a NULL TYPE_FLOATFORMAT. gdb/ChangeLog: * gdbarch.sh (floatformat_for_type): New gdbarch callback. * gdbarch.h, gdbarch.c: Re-generate. * arch-utils.h (default_floatformat_for_type): New prototype. * arch-utils.c (default_floatformat_for_type): New function. * doublest.c (floatformat_from_length): Remove. (floatformat_from_type): Assume TYPE_FLOATFORMAT is non-NULL. * gdbtypes.c (verify_floatformat): Require non-NULL format. * dwarf2read.c (dwarf2_init_float_type): New function. (read_base_type): Use it. * stabsread.c (dbx_init_float_type): New function. (read_sun_floating_type): Use it. (read_range_type): Likewise. Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2016-09-06 17:31:53 +02:00
/* Returns the floating-point format to be used for values of length LENGTH.
NAME, if non-NULL, is the type name, which may be used to distinguish
different target formats of the same length. */
typedef const struct floatformat ** (gdbarch_floatformat_for_type_ftype) (struct gdbarch *gdbarch, const char *name, int length);
extern const struct floatformat ** gdbarch_floatformat_for_type (struct gdbarch *gdbarch, const char *name, int length);
extern void set_gdbarch_floatformat_for_type (struct gdbarch *gdbarch, gdbarch_floatformat_for_type_ftype *floatformat_for_type);
/* For most targets, a pointer on the target and its representation as an
address in GDB have the same size and "look the same". For such a
target, you need only set gdbarch_ptr_bit and gdbarch_addr_bit
/ addr_bit will be set from it.
If gdbarch_ptr_bit and gdbarch_addr_bit are different, you'll probably
also need to set gdbarch_dwarf2_addr_size, gdbarch_pointer_to_address and
gdbarch_address_to_pointer as well.
ptr_bit is the size of a pointer on the target */
2000-08-11 04:55:38 +02:00
extern int gdbarch_ptr_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_ptr_bit (struct gdbarch *gdbarch, int ptr_bit);
/* addr_bit is the size of a target address as represented in gdb */
extern int gdbarch_addr_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_addr_bit (struct gdbarch *gdbarch, int addr_bit);
2000-08-11 04:55:38 +02:00
/* dwarf2_addr_size is the target address size as used in the Dwarf debug
info. For .debug_frame FDEs, this is supposed to be the target address
size from the associated CU header, and which is equivalent to the
DWARF2_ADDR_SIZE as defined by the target specific GCC back-end.
Unfortunately there is no good way to determine this value. Therefore
dwarf2_addr_size simply defaults to the target pointer size.
dwarf2_addr_size is not used for .eh_frame FDEs, which are generally
defined using the target's pointer size so far.
Note that dwarf2_addr_size only needs to be redefined by a target if the
GCC back-end defines a DWARF2_ADDR_SIZE other than the target pointer size,
and if Dwarf versions < 4 need to be supported. */
extern int gdbarch_dwarf2_addr_size (struct gdbarch *gdbarch);
extern void set_gdbarch_dwarf2_addr_size (struct gdbarch *gdbarch, int dwarf2_addr_size);
/* One if `char' acts like `signed char', zero if `unsigned char'. */
extern int gdbarch_char_signed (struct gdbarch *gdbarch);
extern void set_gdbarch_char_signed (struct gdbarch *gdbarch, int char_signed);
extern int gdbarch_read_pc_p (struct gdbarch *gdbarch);
* gdbarch.sh (read_pc): Add REGCACHE argument. Remove PTID argument. (write_pc): Likewise. Remove default implementation, add predicate. * gdbarch.c, gdbarch.h: Regenerate. * regcache.c (read_pc_pid): Use current regcache instead of calling read_register_pid. (write_pc_pid): Check gdbarch_write_pc predicate, implement default case inline. (generic_target_write_pc): Remove. * inferior.h (generic_target_write_pc): Remove. * frv-tdep.c (frv_gdbarch_init): Do not install it. * m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise. * rs6000-tdep.c (rs6000_gdbarch_init): Likewise. * sh64-tdep.c (sh64_gdbarch_init): Likewise. * sh-tdep.c (sh_gdbarch_init): Likewise. * xstormy16-tdep.c (xstormy16_gdbarch_init): Likewise. * avr-tdep.c (avr_read_pc): Add REGCACHE argument. Remove PTID argument. Use REGCACHE instead of calling read_register_pid. * hppa-hpux-tdep.c (hppa_hpux_read_pc): Likewise. * hppa-tdep.c (hppa_read_pc): Likewise. * hppa-tdep.h (hppa_read_pc): Likewise. * ia64-tdep.c (ia64_read_pc): Likewise. * m32r-tdep.c (m32r_read_pc): Likewise. * mep-tdep.c (mep_read_pc): Likewise. * mn10300-tdep.c (mn10300_read_pc): Likewise. * spu-tdep.c (spu_read_pc): Likewise. * arm-tdep.c (arm_write_pc): Add REGCACHE argument. Remove PTID argument. Use REGCACHE instead of calling write_register_pid. * avr-tdep.c (avr_write_pc): Likewise. * hppa-hpux-tdep.c (hppa_hpux_write_pc): Likewise. * hppa-tdep.c (hppa_write_pc): Likewise. * hppa-tdep.h (hppa_write_pc): Likewise. * i386-linux-tdep.c (i386_linux_write_pc): Likewise. * amd64-linux-tdep.c (amd64_linux_write_pc): Likewise. * ia64-linux-tdep.c (ia64_linux_write_pc): Likewise. * ia64-tdep.c (ia64_write_pc): Likewise. * ia64-tdep.h (ia64_write_pc): Likewise. * m32r-tdep.c (m32r_write_pc): Likewise. * m88k-tdep.c (m88k_write_pc): Likewise. * mep-tdep.c (mep_write_pc): Likewise. * mips-tdep.c (mips_write_pc): Likewise. * mips-linux-tdep.c (mips_linux_write_pc): Likewise. * mn10300-tdep.c (mn10300_write_pc): Likewise. * sparc-tdep.c (sparc_write_pc): Likewise. * spu-tdep.c (spu_write_pc): Likewise. * mips-tdep.c (read_signed_register): Remove. (read_signed_register_pid): Likewise. (mips_read_pc): Add REGCACHE argument. Remove PTID argument. Use REGCACHE instead of calling read_signed_register_pid.
2007-06-16 00:44:56 +02:00
typedef CORE_ADDR (gdbarch_read_pc_ftype) (readable_regcache *regcache);
extern CORE_ADDR gdbarch_read_pc (struct gdbarch *gdbarch, readable_regcache *regcache);
1999-08-31 03:14:27 +02:00
extern void set_gdbarch_read_pc (struct gdbarch *gdbarch, gdbarch_read_pc_ftype *read_pc);
* gdbarch.sh (read_pc): Add REGCACHE argument. Remove PTID argument. (write_pc): Likewise. Remove default implementation, add predicate. * gdbarch.c, gdbarch.h: Regenerate. * regcache.c (read_pc_pid): Use current regcache instead of calling read_register_pid. (write_pc_pid): Check gdbarch_write_pc predicate, implement default case inline. (generic_target_write_pc): Remove. * inferior.h (generic_target_write_pc): Remove. * frv-tdep.c (frv_gdbarch_init): Do not install it. * m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise. * rs6000-tdep.c (rs6000_gdbarch_init): Likewise. * sh64-tdep.c (sh64_gdbarch_init): Likewise. * sh-tdep.c (sh_gdbarch_init): Likewise. * xstormy16-tdep.c (xstormy16_gdbarch_init): Likewise. * avr-tdep.c (avr_read_pc): Add REGCACHE argument. Remove PTID argument. Use REGCACHE instead of calling read_register_pid. * hppa-hpux-tdep.c (hppa_hpux_read_pc): Likewise. * hppa-tdep.c (hppa_read_pc): Likewise. * hppa-tdep.h (hppa_read_pc): Likewise. * ia64-tdep.c (ia64_read_pc): Likewise. * m32r-tdep.c (m32r_read_pc): Likewise. * mep-tdep.c (mep_read_pc): Likewise. * mn10300-tdep.c (mn10300_read_pc): Likewise. * spu-tdep.c (spu_read_pc): Likewise. * arm-tdep.c (arm_write_pc): Add REGCACHE argument. Remove PTID argument. Use REGCACHE instead of calling write_register_pid. * avr-tdep.c (avr_write_pc): Likewise. * hppa-hpux-tdep.c (hppa_hpux_write_pc): Likewise. * hppa-tdep.c (hppa_write_pc): Likewise. * hppa-tdep.h (hppa_write_pc): Likewise. * i386-linux-tdep.c (i386_linux_write_pc): Likewise. * amd64-linux-tdep.c (amd64_linux_write_pc): Likewise. * ia64-linux-tdep.c (ia64_linux_write_pc): Likewise. * ia64-tdep.c (ia64_write_pc): Likewise. * ia64-tdep.h (ia64_write_pc): Likewise. * m32r-tdep.c (m32r_write_pc): Likewise. * m88k-tdep.c (m88k_write_pc): Likewise. * mep-tdep.c (mep_write_pc): Likewise. * mips-tdep.c (mips_write_pc): Likewise. * mips-linux-tdep.c (mips_linux_write_pc): Likewise. * mn10300-tdep.c (mn10300_write_pc): Likewise. * sparc-tdep.c (sparc_write_pc): Likewise. * spu-tdep.c (spu_write_pc): Likewise. * mips-tdep.c (read_signed_register): Remove. (read_signed_register_pid): Likewise. (mips_read_pc): Add REGCACHE argument. Remove PTID argument. Use REGCACHE instead of calling read_signed_register_pid.
2007-06-16 00:44:56 +02:00
extern int gdbarch_write_pc_p (struct gdbarch *gdbarch);
typedef void (gdbarch_write_pc_ftype) (struct regcache *regcache, CORE_ADDR val);
extern void gdbarch_write_pc (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR val);
1999-08-31 03:14:27 +02:00
extern void set_gdbarch_write_pc (struct gdbarch *gdbarch, gdbarch_write_pc_ftype *write_pc);
1999-06-14 20:08:47 +02:00
/* Function for getting target's idea of a frame pointer. FIXME: GDB's
whole scheme for dealing with "frames" and "frame pointers" needs a
serious shakedown. */
typedef void (gdbarch_virtual_frame_pointer_ftype) (struct gdbarch *gdbarch, CORE_ADDR pc, int *frame_regnum, LONGEST *frame_offset);
extern void gdbarch_virtual_frame_pointer (struct gdbarch *gdbarch, CORE_ADDR pc, int *frame_regnum, LONGEST *frame_offset);
extern void set_gdbarch_virtual_frame_pointer (struct gdbarch *gdbarch, gdbarch_virtual_frame_pointer_ftype *virtual_frame_pointer);
extern int gdbarch_pseudo_register_read_p (struct gdbarch *gdbarch);
class readable_regcache and pass readable_regcache to gdbarch pseudo_register_read and pseudo_register_read_value pseudo registers are either from raw registers or memory, so gdbarch methods pseudo_register_read and pseudo_register_read_value should have regcache object which only have read methods. In other words, we should disallow writing to regcache in these two gdbarch methods. In order to apply this restriction, this patch adds a new class readable_regcache, derived from reg_buffer, and it only has raw_read and cooked_read methods. regcache is derived from readable_regcache. This patch also passes readable_regcache instead of regcache to gdbarch methods pseudo_register_read and pseudo_register_read_value. This patch moves raw_read* and cooked_read* methods to readable_regcache, which is straightforward. One thing not straightforward is that I split regcache::xfer_part to readable_regcache::read_part and regcache::write_part, because readable_regcache can only have methods to read. readable_regcache is an abstract base class, and it has a pure virtual function raw_update, because I don't want readable_regcache know where these raw registers are from. They can be from either the target (readwrite regcache) or the regcache itself (readonly regcache). gdb: 2018-02-21 Yao Qi <yao.qi@linaro.org> * aarch64-tdep.c (aarch64_pseudo_register_read_value): Change parameter type to 'readable_regcache *'. * amd64-tdep.c (amd64_pseudo_register_read_value): Likewise. * arm-tdep.c (arm_neon_quad_read): Likewise. (arm_pseudo_read): Likewise. * avr-tdep.c (avr_pseudo_register_read): Likewise. * bfin-tdep.c (bfin_pseudo_register_read): Likewise. * frv-tdep.c (frv_pseudo_register_read): Likewise. * gdbarch.c: Re-generated. * gdbarch.h: Re-generated. * gdbarch.sh (pseudo_register_read): Change parameter type to 'readable_regcache *'. (pseudo_register_read_value): Likewise. * h8300-tdep.c (pseudo_from_raw_register): Likewise. (h8300_pseudo_register_read): Likewise. * hppa-tdep.c (hppa_pseudo_register_read): Likewise. * i386-tdep.c (i386_mmx_regnum_to_fp_regnum): Likewise. (i386_pseudo_register_read_into_value): Likewise. (i386_pseudo_register_read_value): Likewise. * i386-tdep.h (i386_pseudo_register_read_into_value): Update declaration. * ia64-tdep.c (ia64_pseudo_register_read): Likewise. * m32c-tdep.c (m32c_raw_read): Likewise. (m32c_read_flg): Likewise. (m32c_banked_register): Likewise. (m32c_banked_read): Likewise. (m32c_sb_read): Likewise. (m32c_part_read): Likewise. (m32c_cat_read): Likewise. (m32c_r3r2r1r0_read): Likewise. (m32c_pseudo_register_read): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_read): Likewise. * mep-tdep.c (mep_pseudo_cr32_read): Likewise. (mep_pseudo_cr64_read): Likewise. (mep_pseudo_register_read): Likewise. * mips-tdep.c (mips_pseudo_register_read): Likewise. * msp430-tdep.c (msp430_pseudo_register_read): Likewise. * nds32-tdep.c (nds32_pseudo_register_read): Likewise. * regcache.c (regcache::raw_read): Move it to readable_regcache. (regcache::cooked_read): Likewise. (regcache::cooked_read_value): Likewise. (regcache_cooked_read_signed): (regcache::cooked_read): Likewise. * regcache.h (readable_regcache): New class. (regcache): Inherit readable_regcache. Move some methods to readable_regcache. * rl78-tdep.c (rl78_pseudo_register_read): Change parameter type to 'readable_regcache *'. * rs6000-tdep.c (do_regcache_raw_read): Remove. (e500_pseudo_register_read): Change parameter type to 'readable_regcache *'. (dfp_pseudo_register_read): Likewise. (vsx_pseudo_register_read): Likewise. (efpr_pseudo_register_read): Likewise. * s390-tdep.c (s390_pseudo_register_read): Likewise. * sh-tdep.c (sh_pseudo_register_read): Likewise. * sh64-tdep.c (pseudo_register_read_portions): Likewise. (sh64_pseudo_register_read): Likewise. * sparc-tdep.c (sparc32_pseudo_register_read): Likewise. * sparc64-tdep.c (sparc64_pseudo_register_read): Likewise. * spu-tdep.c (spu_pseudo_register_read_spu): Likewise. (spu_pseudo_register_read): Likewise. * xtensa-tdep.c (xtensa_register_read_masked): Likewise. (xtensa_pseudo_register_read): Likewise.
2018-02-21 12:20:03 +01:00
typedef enum register_status (gdbarch_pseudo_register_read_ftype) (struct gdbarch *gdbarch, readable_regcache *regcache, int cookednum, gdb_byte *buf);
extern enum register_status gdbarch_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, int cookednum, gdb_byte *buf);
extern void set_gdbarch_pseudo_register_read (struct gdbarch *gdbarch, gdbarch_pseudo_register_read_ftype *pseudo_register_read);
/* Read a register into a new struct value. If the register is wholly
or partly unavailable, this should call mark_value_bytes_unavailable
as appropriate. If this is defined, then pseudo_register_read will
never be called. */
extern int gdbarch_pseudo_register_read_value_p (struct gdbarch *gdbarch);
class readable_regcache and pass readable_regcache to gdbarch pseudo_register_read and pseudo_register_read_value pseudo registers are either from raw registers or memory, so gdbarch methods pseudo_register_read and pseudo_register_read_value should have regcache object which only have read methods. In other words, we should disallow writing to regcache in these two gdbarch methods. In order to apply this restriction, this patch adds a new class readable_regcache, derived from reg_buffer, and it only has raw_read and cooked_read methods. regcache is derived from readable_regcache. This patch also passes readable_regcache instead of regcache to gdbarch methods pseudo_register_read and pseudo_register_read_value. This patch moves raw_read* and cooked_read* methods to readable_regcache, which is straightforward. One thing not straightforward is that I split regcache::xfer_part to readable_regcache::read_part and regcache::write_part, because readable_regcache can only have methods to read. readable_regcache is an abstract base class, and it has a pure virtual function raw_update, because I don't want readable_regcache know where these raw registers are from. They can be from either the target (readwrite regcache) or the regcache itself (readonly regcache). gdb: 2018-02-21 Yao Qi <yao.qi@linaro.org> * aarch64-tdep.c (aarch64_pseudo_register_read_value): Change parameter type to 'readable_regcache *'. * amd64-tdep.c (amd64_pseudo_register_read_value): Likewise. * arm-tdep.c (arm_neon_quad_read): Likewise. (arm_pseudo_read): Likewise. * avr-tdep.c (avr_pseudo_register_read): Likewise. * bfin-tdep.c (bfin_pseudo_register_read): Likewise. * frv-tdep.c (frv_pseudo_register_read): Likewise. * gdbarch.c: Re-generated. * gdbarch.h: Re-generated. * gdbarch.sh (pseudo_register_read): Change parameter type to 'readable_regcache *'. (pseudo_register_read_value): Likewise. * h8300-tdep.c (pseudo_from_raw_register): Likewise. (h8300_pseudo_register_read): Likewise. * hppa-tdep.c (hppa_pseudo_register_read): Likewise. * i386-tdep.c (i386_mmx_regnum_to_fp_regnum): Likewise. (i386_pseudo_register_read_into_value): Likewise. (i386_pseudo_register_read_value): Likewise. * i386-tdep.h (i386_pseudo_register_read_into_value): Update declaration. * ia64-tdep.c (ia64_pseudo_register_read): Likewise. * m32c-tdep.c (m32c_raw_read): Likewise. (m32c_read_flg): Likewise. (m32c_banked_register): Likewise. (m32c_banked_read): Likewise. (m32c_sb_read): Likewise. (m32c_part_read): Likewise. (m32c_cat_read): Likewise. (m32c_r3r2r1r0_read): Likewise. (m32c_pseudo_register_read): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_read): Likewise. * mep-tdep.c (mep_pseudo_cr32_read): Likewise. (mep_pseudo_cr64_read): Likewise. (mep_pseudo_register_read): Likewise. * mips-tdep.c (mips_pseudo_register_read): Likewise. * msp430-tdep.c (msp430_pseudo_register_read): Likewise. * nds32-tdep.c (nds32_pseudo_register_read): Likewise. * regcache.c (regcache::raw_read): Move it to readable_regcache. (regcache::cooked_read): Likewise. (regcache::cooked_read_value): Likewise. (regcache_cooked_read_signed): (regcache::cooked_read): Likewise. * regcache.h (readable_regcache): New class. (regcache): Inherit readable_regcache. Move some methods to readable_regcache. * rl78-tdep.c (rl78_pseudo_register_read): Change parameter type to 'readable_regcache *'. * rs6000-tdep.c (do_regcache_raw_read): Remove. (e500_pseudo_register_read): Change parameter type to 'readable_regcache *'. (dfp_pseudo_register_read): Likewise. (vsx_pseudo_register_read): Likewise. (efpr_pseudo_register_read): Likewise. * s390-tdep.c (s390_pseudo_register_read): Likewise. * sh-tdep.c (sh_pseudo_register_read): Likewise. * sh64-tdep.c (pseudo_register_read_portions): Likewise. (sh64_pseudo_register_read): Likewise. * sparc-tdep.c (sparc32_pseudo_register_read): Likewise. * sparc64-tdep.c (sparc64_pseudo_register_read): Likewise. * spu-tdep.c (spu_pseudo_register_read_spu): Likewise. (spu_pseudo_register_read): Likewise. * xtensa-tdep.c (xtensa_register_read_masked): Likewise. (xtensa_pseudo_register_read): Likewise.
2018-02-21 12:20:03 +01:00
typedef struct value * (gdbarch_pseudo_register_read_value_ftype) (struct gdbarch *gdbarch, readable_regcache *regcache, int cookednum);
extern struct value * gdbarch_pseudo_register_read_value (struct gdbarch *gdbarch, readable_regcache *regcache, int cookednum);
extern void set_gdbarch_pseudo_register_read_value (struct gdbarch *gdbarch, gdbarch_pseudo_register_read_value_ftype *pseudo_register_read_value);
extern int gdbarch_pseudo_register_write_p (struct gdbarch *gdbarch);
typedef void (gdbarch_pseudo_register_write_ftype) (struct gdbarch *gdbarch, struct regcache *regcache, int cookednum, const gdb_byte *buf);
extern void gdbarch_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, int cookednum, const gdb_byte *buf);
extern void set_gdbarch_pseudo_register_write (struct gdbarch *gdbarch, gdbarch_pseudo_register_write_ftype *pseudo_register_write);
1999-08-31 03:14:27 +02:00
extern int gdbarch_num_regs (struct gdbarch *gdbarch);
extern void set_gdbarch_num_regs (struct gdbarch *gdbarch, int num_regs);
1999-06-14 20:08:47 +02:00
/* This macro gives the number of pseudo-registers that live in the
register namespace but do not get fetched or stored on the target.
These pseudo-registers may be aliases for other registers,
combinations of other registers, or they may be computed by GDB. */
extern int gdbarch_num_pseudo_regs (struct gdbarch *gdbarch);
extern void set_gdbarch_num_pseudo_regs (struct gdbarch *gdbarch, int num_pseudo_regs);
/* Assemble agent expression bytecode to collect pseudo-register REG.
Return -1 if something goes wrong, 0 otherwise. */
extern int gdbarch_ax_pseudo_register_collect_p (struct gdbarch *gdbarch);
typedef int (gdbarch_ax_pseudo_register_collect_ftype) (struct gdbarch *gdbarch, struct agent_expr *ax, int reg);
extern int gdbarch_ax_pseudo_register_collect (struct gdbarch *gdbarch, struct agent_expr *ax, int reg);
extern void set_gdbarch_ax_pseudo_register_collect (struct gdbarch *gdbarch, gdbarch_ax_pseudo_register_collect_ftype *ax_pseudo_register_collect);
/* Assemble agent expression bytecode to push the value of pseudo-register
REG on the interpreter stack.
Return -1 if something goes wrong, 0 otherwise. */
extern int gdbarch_ax_pseudo_register_push_stack_p (struct gdbarch *gdbarch);
typedef int (gdbarch_ax_pseudo_register_push_stack_ftype) (struct gdbarch *gdbarch, struct agent_expr *ax, int reg);
extern int gdbarch_ax_pseudo_register_push_stack (struct gdbarch *gdbarch, struct agent_expr *ax, int reg);
extern void set_gdbarch_ax_pseudo_register_push_stack (struct gdbarch *gdbarch, gdbarch_ax_pseudo_register_push_stack_ftype *ax_pseudo_register_push_stack);
Intel MPX bound violation handling With Intel Memory Protection Extensions it was introduced the concept of boundary violation. A boundary violations is presented to the inferior as a segmentation fault having SIGCODE 3. This patch adds a handler for a boundary violation extending the information displayed when a bound violation is presented to the inferior. In the stop mode case the debugger will also display the kind of violation: "upper" or "lower", bounds and the address accessed. On no stop mode the information will still remain unchanged. Additional information about bound violations are not meaningful in that case user does not know the line in which violation occurred as well. When the segmentation fault handler is stop mode the out puts will be changed as exemplified below. The usual output of a segfault is: Program received signal SIGSEGV, Segmentation fault 0x0000000000400d7c in upper (p=0x603010, a=0x603030, b=0x603050, c=0x603070, d=0x603090, len=7) at i386-mpx-sigsegv.c:68 68 value = *(p + len); In case it is a bound violation it will be presented as: Program received signal SIGSEGV, Segmentation fault Upper bound violation while accessing address 0x7fffffffc3b3 Bounds: [lower = 0x7fffffffc390, upper = 0x7fffffffc3a3] 0x0000000000400d7c in upper (p=0x603010, a=0x603030, b=0x603050, c=0x603070, d=0x603090, len=7) at i386-mpx-sigsegv.c:68 68 value = *(p + len); In mi mode the output of a segfault is: *stopped,reason="signal-received",signal-name="SIGSEGV", signal-meaning="Segmentation fault", frame={addr="0x0000000000400d7c", func="upper",args=[{name="p", value="0x603010"},{name="a",value="0x603030"} ,{name="b",value="0x603050"}, {name="c",value="0x603070"}, {name="d",value="0x603090"},{name="len",value="7"}], file="i386-mpx-sigsegv.c",fullname="i386-mpx-sigsegv.c",line="68"}, thread-id="1",stopped-threads="all",core="6" in the case of a bound violation: *stopped,reason="signal-received",signal-name="SIGSEGV", signal-meaning="Segmentation fault", sigcode-meaning="Upper bound violation", lower-bound="0x603010",upper-bound="0x603023",bound-access="0x60302f", frame={addr="0x0000000000400d7c",func="upper",args=[{name="p", value="0x603010"},{name="a",value="0x603030"},{name="b",value="0x603050"}, {name="c",value="0x603070"},{name="d",value="0x603090"}, {name="len",value="7"}],file="i386-mpx-sigsegv.c", fullname="i386-mpx-sigsegv.c",line="68"},thread-id="1", stopped-threads="all",core="6" 2016-02-18 Walfred Tedeschi <walfred.tedeschi@intel.com> gdb/ChangeLog: * NEWS: Add entry for bound violation. * amd64-linux-tdep.c (amd64_linux_init_abi_common): Add handler for segmentation fault. * gdbarch.sh (handle_segmentation_fault): New. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * i386-linux-tdep.c (i386_linux_handle_segmentation_fault): New. (SIG_CODE_BONDARY_FAULT): New define. (i386_linux_init_abi): Use i386_mpx_bound_violation_handler. * i386-linux-tdep.h (i386_linux_handle_segmentation_fault) New. * i386-tdep.c (i386_mpx_enabled): Add as external. * i386-tdep.c (i386_mpx_enabled): Add as external. * infrun.c (handle_segmentation_fault): New function. (print_signal_received_reason): Use handle_segmentation_fault. gdb/testsuite/ChangeLog: * gdb.arch/i386-mpx-sigsegv.c: New file. * gdb.arch/i386-mpx-sigsegv.exp: New file. * gdb.arch/i386-mpx-simple_segv.c: New file. * gdb.arch/i386-mpx-simple_segv.exp: New file. gdb/doc/ChangeLog: * gdb.texinfo (Signals): Add bound violation display hints for a SIGSEGV.
2016-02-18 17:24:59 +01:00
/* Some targets/architectures can do extra processing/display of
segmentation faults. E.g., Intel MPX boundary faults.
Call the architecture dependent function to handle the fault.
UIOUT is the output stream where the handler will place information. */
extern int gdbarch_handle_segmentation_fault_p (struct gdbarch *gdbarch);
typedef void (gdbarch_handle_segmentation_fault_ftype) (struct gdbarch *gdbarch, struct ui_out *uiout);
extern void gdbarch_handle_segmentation_fault (struct gdbarch *gdbarch, struct ui_out *uiout);
extern void set_gdbarch_handle_segmentation_fault (struct gdbarch *gdbarch, gdbarch_handle_segmentation_fault_ftype *handle_segmentation_fault);
/* GDB's standard (or well known) register numbers. These can map onto
a real register or a pseudo (computed) register or not be defined at
all (-1).
2007-06-18 Markus Deuling <deuling@de.ibm.com> * gdbarch.sh (SP_REGNUM): Replace by gdbarch_sp_regnum. * v850-tdep.c (v850_unwind_sp): Likewise. * std-regs.c (value_of_builtin_frame_sp_reg): Likewise. * stack.c (frame_info): Likewise. * stabsread.c (define_symbol): Likewise. * sh-tdep.c (sh_push_dummy_call_fpu, sh_push_dummy_call_nofpu) (sh_dwarf2_frame_init_reg, sh_frame_cache, sh_frame_prev_register) (sh_unwind_sp): Likewise. * sh64-tdep.c (sh64_push_dummy_call, sh64_frame_cache) (sh64_frame_prev_register, sh64_unwind_sp): Likewise. * rs6000-tdep.c (rs6000_push_dummy_call, rs6000_unwind_dummy_id) (rs6000_frame_cache): Likewise. * rs6000-nat.c (store_register): Likewise. * remote-mips.c (mips_wait): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) (ppc64_sysv_abi_push_dummy_call): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache): Likewise. * m32r-rom.c (m32r_supply_register): Likewise. * frame.c (frame_sp_unwind): Likewise. * mips-tdep.c (mips_insn16_frame_cache) (mips_insn32_frame_cache): Likewise (comment). * m68klinux-nat.c (supply_gregset): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * ia64-tdep.c (ia64_frame_prev_register): Likewise. * i386-tdep.c (i386_get_longjmp_target): Likewise. * dwarf2-frame.c (dwarf2_frame_default_init_reg): Likewise. * cris-tdep.c (cris_regnums, cris_sigcontext_addr) (cris_sigtramp_frame_unwind_cache, cris_push_dummy_call) (cris_scan_prologue, crisv32_scan_prologue, cris_unwind_sp) (cris_register_type, crisv32_register_type) (cris_dwarf2_frame_init_reg): Likewise. * arch-utils.c (legacy_virtual_frame_pointer): Likewise. * amd64-tdep.c (amd64_frame_prev_register): Likewise. * amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Likewise. * libunwind-frame.c (libunwind_frame_cache): Likewise. * gdbarch.sh (PC_REGNUM): Replace by gdbarch_pc_regnum. * regcache.c (read_pc_pid, generic_target_write_pc): Likewise. * xtensa-tdep.c (xtensa_register_type, xtensa_supply_gregset) (xtensa_unwind_pc, xtensa_frame_cache, xtensa_frame_prev_register) (xtensa_extract_return_value, xtensa_store_return_value): Likewise. * v850-tdep.c (v850_unwind_pc): Likewise. * stack.c (frame_info): Likewise. * sh-tdep.c (sh_generic_show_regs, sh3_show_regs, sh2e_show_regs) (sh2a_show_regs, sh2a_nofpu_show_regs, sh3e_show_regs) (sh3_dsp_show_regs, sh4_show_regs, sh4_nofpu_show_regs) (sh_dwarf2_frame_init_reg, sh_frame_prev_register, sh_unwind_pc) (sh_dsp_show_regs): Likewise. * shnbsd-tdep.c (shnbsd_supply_gregset) (shnbsd_collect_gregset): Likewise. * shnbsd-nat.c (GETREGS_SUPPLIES): Likewise. * sh64-tdep.c (sh64_compact_reg_base_num, sh64_show_media_regs) (sh64_frame_prev_register, sh64_unwind_pc): Likewise. * rs6000-tdep.c (ppc_supply_gregset, ppc_collect_gregset) (6000_register_reggroup_p, rs6000_unwind_pc) (rs6000_frame_cache): Likewise. * rs6000-nat.c (regmap, rs6000_fetch_inferior_registers) (rs6000_store_inferior_registers): Likewise. * remote-mips.c (mips_wait, mips_load): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. * ppcnbsd-nat.c (getregs_supplies, ppcnbsd_supply_pcb): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache): Likewise. * ppc-linux-nat.c (ppc_register_u_addr, fetch_ppc_registers) (store_ppc_registers, fill_gregset): Likewise. * mips-tdep.c (mips_stub_frame_cache, mips_gdbarch_init): Likewise. * mipsnbsd-tdep.c (mipsnbsd_supply_reg, mipsnbsd_fill_reg): Likewise. * mipsnbsd-nat.c (getregs_supplies): Likewise. * m68k-tdep.c (m68k_register_type, m68k_unwind_pc): Likewise. * m68klinux-nat.c (supply_gregset): Likewise. * irix5-nat.c (fill_gregset): Likewise. * i386-tdep.c (i386_unwind_pc): Likewise. * i386-linux-nat.c (i386_linux_resume): Likewise. * frame.c (get_prev_frame_1): Likewise. * dwarf2-frame.c (dwarf2_frame_default_init_reg): Likewise. * dbug-rom.c (dbug_supply_register): Likewise. * cris-tdep.c (cris_sigtramp_frame_unwind_cache, cris_scan_prologue) (crisv32_scan_prologue, cris_unwind_pc, cris_register_size) (cris_register_type, crisv32_register_type, crisv32_register_name) (cris_dwarf2_frame_init_reg, find_step_target) (cris_software_single_step, cris_supply_gregset) (cris_regnums): Likewise. * alpha-linux-nat.c (alpha_linux_register_u_offset): Likewise. * aix-thread.c (special_register_p, supply_sprs64, supply_sprs32) (fill_sprs64, fill_sprs32, store_regs_user_thread): Likewise. * mips-linux-tdep.c (mips_linux_write_pc): Likewise. * gdbarch.sh (PS_REGNUM): Replace by gdbarch_ps_regnum. * dbug-rom.c (dbug_supply_register): Likewise. * xtensa-tdep.c (xtensa_supply_gregset, xtensa_frame_cache) (xtensa_frame_prev_register, xtensa_push_dummy_call): Likewise. * win32-nat.c (win32_resume): Likewise. * std-regs.c (value_of_builtin_frame_ps_reg) (value_of_builtin_frame_pc_reg): Likewise. * m68k-tdep.c (m68k_register_type): Likewise. * m68klinux-nat.c (supply_gregset): Likewise. * gdbarch.sh (FP0_REGNUM): Replace by gdbarch_fp0_regnum. * sh-tdep.c (sh_extract_return_value_fpu, sh_store_return_value_fpu) (sh2e_show_regs, sh2a_show_regs, sh3e_show_regs, sh4_show_regs) (sh_sh2a_register_type, sh_sh3e_register_type, sh_sh4_register_type) (fv_reg_base_num, dr_reg_base_num): Likewise. * sh64-tdep.c (sh64_fv_reg_base_num, sh64_dr_reg_base_num) (sh64_fpp_reg_base_num, sh64_compact_reg_base_num, sh64_push_dummy_call) (sh64_extract_return_value, sh64_store_return_value) (sh64_show_media_regs, sh64_show_compact_regs, sh64_register_type) (sh64_do_fp_register, sh64_media_print_registers_info): Likewise. * procfs.c (procfs_fetch_registers, procfs_store_registers) (invalidate_cache): Likewise. * ppc-linux-tdep.c (ppc_linux_sigtramp_cache): Likewise. * mipsnbsd-tdep.c (mipsnbsd_supply_fpreg) (mipsnbsd_fill_fpreg): Likewise. * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Likewise. * mips-linux-tdep.c (mips_supply_fpregset, mips_fill_fpregset) (mips64_supply_fpregset, mips64_fill_fpregset): Likewise. * mips-linux-nat.c (mips64_linux_register_addr): Likewise. * m68k-tdep.c (m68k_register_type, m68k_convert_register_p): Likewise. * m68klinux-nat.c (getfpregs_supplies, supply_fpregset) (fill_fpregset): Likewise. * irix5-nat.c (supply_fpregset, fill_fpregset): Likewise. * i386-tdep.h (struct_return): Likewise (comment). * i386-nto-tdep.c (i386nto_register_area): Likewise. * go32-nat.c (fetch_register, go32_fetch_registers, store_register) (go32_store_registers): Likewise. * alpha-tdep.c (alpha_next_pc): Likewise. * alpha-linux-nat.c (alpha_linux_register_u_offset): Likewise. * alphabsd-nat.c (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Likewise. * core-regset.c (fetch_core_registers): Likewise. * i386v4-nat.c (supply_fpregset, fill_fpregset): Likewise. * gdbarch.c, gdbarch.h: Regenerate.
2007-06-18 19:45:26 +02:00
gdbarch_sp_regnum will hopefully be replaced by UNWIND_SP. */
1999-08-31 03:14:27 +02:00
extern int gdbarch_sp_regnum (struct gdbarch *gdbarch);
extern void set_gdbarch_sp_regnum (struct gdbarch *gdbarch, int sp_regnum);
1999-06-14 20:08:47 +02:00
1999-08-31 03:14:27 +02:00
extern int gdbarch_pc_regnum (struct gdbarch *gdbarch);
extern void set_gdbarch_pc_regnum (struct gdbarch *gdbarch, int pc_regnum);
1999-06-14 20:08:47 +02:00
extern int gdbarch_ps_regnum (struct gdbarch *gdbarch);
extern void set_gdbarch_ps_regnum (struct gdbarch *gdbarch, int ps_regnum);
extern int gdbarch_fp0_regnum (struct gdbarch *gdbarch);
extern void set_gdbarch_fp0_regnum (struct gdbarch *gdbarch, int fp0_regnum);
/* Convert stab register number (from `r' declaration) to a gdb REGNUM. */
typedef int (gdbarch_stab_reg_to_regnum_ftype) (struct gdbarch *gdbarch, int stab_regnr);
extern int gdbarch_stab_reg_to_regnum (struct gdbarch *gdbarch, int stab_regnr);
extern void set_gdbarch_stab_reg_to_regnum (struct gdbarch *gdbarch, gdbarch_stab_reg_to_regnum_ftype *stab_reg_to_regnum);
/* Provide a default mapping from a ecoff register number to a gdb REGNUM. */
typedef int (gdbarch_ecoff_reg_to_regnum_ftype) (struct gdbarch *gdbarch, int ecoff_regnr);
extern int gdbarch_ecoff_reg_to_regnum (struct gdbarch *gdbarch, int ecoff_regnr);
extern void set_gdbarch_ecoff_reg_to_regnum (struct gdbarch *gdbarch, gdbarch_ecoff_reg_to_regnum_ftype *ecoff_reg_to_regnum);
/* Convert from an sdb register number to an internal gdb register number. */
typedef int (gdbarch_sdb_reg_to_regnum_ftype) (struct gdbarch *gdbarch, int sdb_regnr);
extern int gdbarch_sdb_reg_to_regnum (struct gdbarch *gdbarch, int sdb_regnr);
extern void set_gdbarch_sdb_reg_to_regnum (struct gdbarch *gdbarch, gdbarch_sdb_reg_to_regnum_ftype *sdb_reg_to_regnum);
PR symtab/17391 gdb internal error: assertion fails in regcache.c:178 gdb/ChangeLog: * dwarf2-frame.c (dwarf2_restore_rule): Call dwarf_reg_to_regnum instead of gdbarch_dwarf2_reg_to_regnum. (dwarf2_frame_cache): Ditto. (read_addr_from_reg): Call dwarf_reg_to_regnum_or_error instead of gdbarch_dwarf2_reg_to_regnum. (get_reg_value): Ditto. (dwarf2_fetch_cfa_info): Ditto. (dwarf2_frame_prev_register): Ditto. * dwarf2loc.c: #include "complaints.h". (dwarf_expr_read_addr_from_reg): Call dwarf_reg_to_regnum_or_error instead of gdbarch_dwarf2_reg_to_regnum. (dwarf_expr_get_reg_value): Ditto. (read_pieced_value): Ditto. (write_pieced_value): Ditto. (dwarf2_evaluate_loc_desc_full): Ditto. (dwarf_reg_to_regnum): New function. (throw_bad_regnum_error): New function. (dwarf_reg_to_regnum_or_error): Renamed from dwarf2_reg_to_regnum_or_errorChange to take a ULONGEST regnum. All callers updated. Call throw_bad_regnum_error. (locexpr_regname): Improve text of bad register number. * dwarf2loc.h (dwarf_reg_to_regnum): Declare. (dwarf_reg_to_regnum_or_error): Update prototype. * dwarf2expr.c: #include "dwarf2loc.h". (dwarf_block_to_sp_offset): Call dwarf_reg_to_regnum instead of gdbarch_dwarf2_reg_to_regnum. * gdbarch.sh (dwarf2_reg_to_regnum): Add comment. * gdbarch.h: Regenerate. * amd64-tdep.c (amd64_dwarf_reg_to_regnum): Remove warning for bad register. * avr-tdep.c (avr_dwarf_reg_to_regnum): Ditto. * cris-tdep.c (cris_dwarf2_reg_to_regnum): Ditto. * bfin-tdep.c (bfin_reg_to_regnum): Fix error checking. * hppa-linux-tdep.c (hppa_dwarf_reg_to_regnum): Improve error checking. Remove warning for bad register. * hppa-tdep.c (hppa64_dwarf_reg_to_regnum): Ditto. * i386-tdep.c (i386_svr4_dwarf_reg_to_regnum): Renamed from i386_svr4_reg_to_regnum. Return -1 for bad registers. (i386_svr4_reg_to_regnum): New function. (i386_gdbarch_init): Update call to set_gdbarch_dwarf2_reg_to_regnum. * microblaze-tdep.c (microblaze_dwarf2_reg_to_regnum): Don't assert on bad registers, return -1. * msp430-tdep.c (msp430_dwarf2_reg_to_regnum): Improve error checking. Remove warning for bad register. * nios2-tdep.c: Add static assert for NIOS2_NUM_REGS. (nios2_dwarf_reg_to_regnum): Fix off-by-one error. Remove warning for bad register. Return -1 for bad register. * rl78-tdep.c (rl78_dwarf_reg_to_regnum): Don't flag an internal error for bad register, return -1. * rx-tdep.c (rx_dwarf_reg_to_regnum): Ditto. * m68k-tdep.c (m68k_dwarf_reg_to_regnum): Fix error result. * mep-tdep.c (mep_debug_reg_to_regnum): Ditto. * mips-tdep.c (mips_stab_reg_to_regnum): Ditto. (mips_dwarf_dwarf2_ecoff_reg_to_regnum): Ditto. * mn10300-tdep.c (mn10300_dwarf2_reg_to_regnum): Remove warning for bad regs. * xtensa-tdep.c (xtensa_reg_to_regnum): Remove internal error for bad regs. Fix error result. * stabsread.c (stab_reg_to_regnum): Watch for negative regno. (reg_value_complaint): Update complaint text. * mdebugread.c (reg_value_complaint): New function. (mdebug_reg_to_regnum): Rewrite to watch for bad reg numbers. gdb/testsuite/ChangeLog: * lib/dwarf.exp (_location): Add support for DW_OP_regx. * gdb.dwarf2/bad-regnum.c: New file. * gdb.dwarf2/bad-regnum.exp: New file.
2015-10-27 00:05:21 +01:00
/* Provide a default mapping from a DWARF2 register number to a gdb REGNUM.
Return -1 for bad REGNUM. Note: Several targets get this wrong. */
typedef int (gdbarch_dwarf2_reg_to_regnum_ftype) (struct gdbarch *gdbarch, int dwarf2_regnr);
extern int gdbarch_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int dwarf2_regnr);
extern void set_gdbarch_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, gdbarch_dwarf2_reg_to_regnum_ftype *dwarf2_reg_to_regnum);
2007-11-02 Markus Deuling <deuling@de.ibm.com> * gdbarch.sh (register_name): Add gdbarch parameter. * gdbarch.{c,h}: Regenerate. * target-descriptions.c (tdesc_register_name): Add gdbarch parameter. (tdesc_register_name): Replace current_gdbarch by gdbarch. * target-descriptions.h (tdesc_register_name): Add gdbarch parameter. * xstormy16-tdep.c (xstormy16_register_name): Add gdbarch parameter. * vax-tdep.c (vax_register_name): Add gdbarch parameter. * spu-tdep.c (spu_register_name): Add gdbarch parameter. * s390-tdep.c (s390_register_name): Add gdbarch parameter. * mt-tdep.c (mt_register_name): Add gdbarch parameter. (mt_registers_info): Replace current_gdbarch by gdbarch. (mt_register_reggroup_p): Add gdbarch to mt_register_name call. * mips-tdep.c (mips_register_name): Add gdbarch parameter. Replace current_gdbarch by gdbarch. (mips_register_name): Add gdbarch to tdesc_register_name call. * mep-tdep.c (mep_register_name): Add gdbarch parameter. Replace current_gdbarch by gdbarch. (mep_register_reggroup_p): Add gdbarch to mep_register_name call. * m32c-tdep.c (m32c_register_name): Add gdbarch parameter. Replace current_gdbarch by gdbarch. * m88k-tdep.c (m88k_register_name): Add gdbarch parameter. * m68k-tdep.c (m68k_register_name): Add gdbarch parameter. * m32r-tdep.c (m32r_register_name): Add gdbarch parameter. (m32r_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. * iq2000-tdep.c (iq2000_register_name): Add gdbarch parameter. * ia64-tdep.c (ia64_register_name): Add gdbarch parameter. * hppa-tdep.c (hppa32_register_name, hppa64_register_name): Add gdbarch parameter. * h8300-tdep.c (h8300_register_name, h8300s_register_name) (h8300sx_register_name): Add gdbarch parameter. * cris-tdep.c (cris_register_name, crisv32_register_name): Add gdbarch parameter. Replace current_gdbarch by gdbarch. (cris_gdbarch_init): Replace current_gdbarch by gdbarch (comment). * avr-tdep.c (avr_register_name): Add gdbarch parameter. * arm-tdep.c (arm_register_name): Add gdbarch paramete * amd64-tdep.c (amd64_register_name): Add gdbarch parameter. Update caller. * amd64-tdep.h (amd64_register_name): Add gdbarch parameter. * amd64-linux-tdep.c (amd64_linux_register_name): Add gdbarch parameter. * alpha-tdep.c (alpha_register_name): Add gdbarch parameter. (alpha_cannot_fetch_register, alpha_cannot_store_register): Update call of alpha_register_name. * frv-tdep.c (frv_register_name): Add gdbarch parameter. * i386-tdep.c (i386_register_name): Add gdbarch parameter. Replace current_gdbarch by gdbarch. (i386_register_type): Replace ?current_gdbarch by gdbarch. * i386-tdep.h (i386_register_name): Add gdbarch parameter. * i386-linux-tdep.c (i386_linux_register_name): Add gdbarch parameter. * m68hc11-tdep.c (m68hc11_register_name): Add gdbarch parameter. (m68hc11_register_reggroup_p): Add gdbarch to call of m68hc11_register_name. * mn10300-tdep.c (mn10300_generic_register_name, am33_register_name) (am33_2_register_name): Add gdbarch parameter. (mn10300_frame_unwind_cache): Use get_frame_arch to get at the current architecture by frame_info. (mn10300_dump_tdep): Replace current_gdbarch by gdbarch. * rs6000-tdep.c (rs6000_register_name): Add gdbarch parameter. Replace current_gdbarch by gdbarch. * score-tdep.c (score_register_name): Add gdbarch parameter. (score_return_value, score_push_dummy_call): Replace current_gdbarch by gdbarch. * sh64-tdep.c (sh64_register_name): Add gdbarch parameter. (sh64_compact_reg_base_num, sh64_register_convert_to_virtual) (sh64_register_convert_to_raw, sh64_fv_reg_base_num) (sh64_dr_reg_base_num, sh64_fpp_reg_base_num): Add gdbarch parameter and update caller. Replace current_gdbarch by gdbarch. (sh64_extract_return_value, sh64_store_return_value): Use get_regcache_arch to get at the current architecture by regcache. * sh-tdep.c (sh_sh_register_name, sh_sh3_register_name) (sh_sh3e_register_name, sh_sh2e_register_name, sh_sh2a_register_name) (sh_sh2a_nofpu_register_name, sh_sh_dsp_register_name) (sh_sh3_dsp_register_name, sh_sh4_register_name) (sh_sh4_nofpu_register_name, sh_sh4al_dsp_register_name): Add gdbarch parameter. (fv_reg_base_num, dr_reg_base_num, sh_justify_value_in_reg) (sh_next_flt_argreg): Add gdbarch parameter and update caller. Replace current_gdbarch by gdbarch. (sh_extract_return_value_fpu, sh_store_return_value_fpu): Use get_regcache_arch to get at the current architecture by regcache. * sparc-tdep.c (sparc32_register_name): Add gdbarch parameter. * sparc64-tdep.c (sparc64_register_name): Add gdbarch parameter. * v850-tdep.c (v850_register_name, v850e_register_name): Add gdbarch parameter. (v850_unwind_sp, v850_unwind_pc): Replace current_gdbarch by gdbarch. * xtensa-tdep.c (xtensa_register_name): Add gdbarch parameter. Replace current_gdbarch by gdbarch. (xtensa_pseudo_register_read, xtensa_pseudo_register_write) (xtensa_frame_prev_register): Add gdbarch parameter to xtensa_register_name call.
2007-11-02 15:27:15 +01:00
typedef const char * (gdbarch_register_name_ftype) (struct gdbarch *gdbarch, int regnr);
2002-06-18 01:32:36 +02:00
extern const char * gdbarch_register_name (struct gdbarch *gdbarch, int regnr);
1999-08-31 03:14:27 +02:00
extern void set_gdbarch_register_name (struct gdbarch *gdbarch, gdbarch_register_name_ftype *register_name);
1999-06-14 20:08:47 +02:00
/* Return the type of a register specified by the architecture. Only
the register cache should call this function directly; others should
use "register_type". */
extern int gdbarch_register_type_p (struct gdbarch *gdbarch);
typedef struct type * (gdbarch_register_type_ftype) (struct gdbarch *gdbarch, int reg_nr);
extern struct type * gdbarch_register_type (struct gdbarch *gdbarch, int reg_nr);
extern void set_gdbarch_register_type (struct gdbarch *gdbarch, gdbarch_register_type_ftype *register_type);
gdb: Add default frame methods to gdbarch Supply default gdbarch methods for gdbarch_dummy_id, gdbarch_unwind_pc, and gdbarch_unwind_sp. This patch doesn't actually convert any targets to use these methods, and so, there will be no user visible changes after this commit. The implementations for default_dummy_id and default_unwind_sp are fairly straight forward, these just take on the pattern used by most targets. Once these default methods are in place then most targets will be able to switch over. The implementation for default_unwind_pc is also fairly straight forward, but maybe needs some explanation. This patch has gone through a number of iterations: https://sourceware.org/ml/gdb-patches/2018-03/msg00165.html https://sourceware.org/ml/gdb-patches/2018-03/msg00306.html https://sourceware.org/ml/gdb-patches/2018-06/msg00090.html https://sourceware.org/ml/gdb-patches/2018-09/msg00127.html and the implementation of default_unwind_pc has changed over this time. Originally, I took an implementation like this: CORE_ADDR default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { int pc_regnum = gdbarch_pc_regnum (gdbarch); return frame_unwind_register_unsigned (next_frame, pc_regnum); } This is basically a clone of default_unwind_sp, but using $pc. It was pointed out that we could potentially do better, and in version 2 the implementation became: CORE_ADDR default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { struct type *type; int pc_regnum; CORE_ADDR addr; struct value *value; pc_regnum = gdbarch_pc_regnum (gdbarch); value = frame_unwind_register_value (next_frame, pc_regnum); type = builtin_type (gdbarch)->builtin_func_ptr; addr = extract_typed_address (value_contents_all (value), type); addr = gdbarch_addr_bits_remove (gdbarch, addr); release_value (value); value_free (value); return addr; } The idea was to try split out some of the steps of unwinding the $pc, steps that are on some (or many) targets no-ops, and so allow targets that do override these methods, to make use of default_unwind_pc. This implementation remained in place for version 2, 3, and 4. However, I realised that I'd made a mistake, most targets simply use frame_unwind_register_unsigned to unwind the $pc, and this throws an error if the register value is optimized out or unavailable. My new proposed implementation doesn't do this, I was going to end up breaking many targets. I considered duplicating the code from frame_unwind_register_unsigned that throws the errors into my new default_unwind_pc, however, this felt really overly complex. So, what I instead went with was to simply revert back to using frame_unwind_register_unsigned. Almost all existing targets already use this. Some of the ones that don't can be converted to, which means almost all targets could end up using the default. One addition I have made over the version 1 implementation is to add a call to gdbarch_addr_bits_remove. For most targets this is a no-op, but for a handful, having this call in place will mean that they can use the default method. After all this, the new default_unwind_pc now looks like this: CORE_ADDR default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { int pc_regnum = gdbarch_pc_regnum (gdbarch); CORE_ADDR pc = frame_unwind_register_unsigned (next_frame, pc_regnum); pc = gdbarch_addr_bits_remove (gdbarch, pc); return pc; } gdb/ChangeLog: * gdb/dummy-frame.c (default_dummy_id): Defined new function. * gdb/dummy-frame.h (default_dummy_id): Declare new function. * gdb/frame-unwind.c (default_unwind_pc): Define new function. (default_unwind_sp): Define new function. * gdb/frame-unwind.h (default_unwind_pc): Declare new function. (default_unwind_sp): Declare new function. * gdb/frame.c (frame_unwind_pc): Assume gdbarch_unwind_pc is available. (get_frame_sp): Assume that gdbarch_unwind_sp is available. * gdb/gdbarch.c: Regenerate. * gdb/gdbarch.h: Regenerate. * gdb/gdbarch.sh: Update definition of dummy_id, unwind_pc, and unwind_sp. Add additional header files to be included in generated file.
2018-09-07 21:04:44 +02:00
/* Generate a dummy frame_id for THIS_FRAME assuming that the frame is
a dummy frame. A dummy frame is created before an inferior call,
the frame_id returned here must match the frame_id that was built
for the inferior call. Usually this means the returned frame_id's
stack address should match the address returned by
gdbarch_push_dummy_call, and the returned frame_id's code address
should match the address at which the breakpoint was set in the dummy
frame. */
Convert frame unwinders to use the current frame and "struct value". * frame.c (frame_debug): Make global. (get_frame_id): Pass this frame to unwinder routines. (frame_pc_unwind): Remove unused unwind->prev_pc support. (do_frame_register_read): Do not discard the return value of frame_register_read. (frame_register_unwind): Remove debug messages. Use frame_unwind_register_value. (frame_unwind_register_value, get_frame_register_value): New functions. (create_new_frame, get_frame_base_address, get_frame_locals_address) (get_frame_args_address, get_frame_type): Pass this frame to unwinder routines. (frame_cleanup_after_sniffer, frame_prepare_for_sniffer): New functions. * frame.h: Update comments. (frame_debug, frame_unwind_register_value, get_frame_register_value) (frame_prepare_for_sniffer): Declare. * frame-unwind.h: Update comments and parameter names. (default_frame_sniffer): Declare. (frame_prev_register_ftype): Return a struct value *. (struct frame_unwind): Remove prev_pc member. (frame_unwind_sniffer_ftype, frame_unwind_append_sniffer): Delete. (frame_unwind_append_unwinder, frame_unwind_got_optimized) (frame_unwind_got_register, frame_unwind_got_memory) (frame_unwind_got_constant, frame_unwind_got_address): Declare. * frame-base.h: Update comments and parameter names. * valops.c (value_fetch_lazy): Use get_frame_register_value. Iterate if necessary. Add debugging output. * sentinel-frame.c (sentinel_frame_prev_register) (sentinel_frame_this_id): Update for new signature. (sentinel_frame_prev_pc): Delete. (sentinel_frame_unwinder): Remove prev_pc. * ia64-tdep.c (ia64_libunwind_frame_unwind): Do not initialize prev_pc. * libunwind-frame.c (libunwind_frame_unwind): Likewise. * frame-unwind.c (struct frame_unwind_table_entry): Remove sniffer. (frame_unwind_append_sniffer): Delete. (frame_unwind_append_unwinder): New function. (frame_unwind_find_by_frame): Take this frame. Only use sniffers from unwinders. Use frame_prepare_for_sniffer. (default_frame_sniffer, frame_unwind_got_optimized) (frame_unwind_got_register, frame_unwind_got_memory) (frame_unwind_got_constant, frame_unwind_got_address): New functions. * dummy-frame.c (dummy_frame_sniffer): Use gdbarch_dummy_id. (dummy_frame_prev_register, dummy_frame_this_id): Update for new signature. * gdbarch.sh: Replace unwind_dummy_id with dummy_id. * gdbarch.c, gdbarch.c: Regenerated. * frame-base.c (default_frame_base_address) (default_frame_locals_address, default_frame_args_address): Update for new signature. (frame_base_find_by_frame): Pass this frame to unwinder routines. * infcall.c (call_function_by_hand): Update comments. * Makefile.in (frame-unwind.o): Update dependencies. * gdbint.texinfo (Stack Frames): New chapter. (Algorithms): Move Frames text to the new chapter. (Target Conditionals): Delete SAVE_DUMMY_FRAME_TOS. Document gdbarch_dummy_id instead of gdbarch_unwind_dummy_id.
2008-04-30 23:16:46 +02:00
typedef struct frame_id (gdbarch_dummy_id_ftype) (struct gdbarch *gdbarch, struct frame_info *this_frame);
extern struct frame_id gdbarch_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame);
extern void set_gdbarch_dummy_id (struct gdbarch *gdbarch, gdbarch_dummy_id_ftype *dummy_id);
Convert frame unwinders to use the current frame and "struct value". * frame.c (frame_debug): Make global. (get_frame_id): Pass this frame to unwinder routines. (frame_pc_unwind): Remove unused unwind->prev_pc support. (do_frame_register_read): Do not discard the return value of frame_register_read. (frame_register_unwind): Remove debug messages. Use frame_unwind_register_value. (frame_unwind_register_value, get_frame_register_value): New functions. (create_new_frame, get_frame_base_address, get_frame_locals_address) (get_frame_args_address, get_frame_type): Pass this frame to unwinder routines. (frame_cleanup_after_sniffer, frame_prepare_for_sniffer): New functions. * frame.h: Update comments. (frame_debug, frame_unwind_register_value, get_frame_register_value) (frame_prepare_for_sniffer): Declare. * frame-unwind.h: Update comments and parameter names. (default_frame_sniffer): Declare. (frame_prev_register_ftype): Return a struct value *. (struct frame_unwind): Remove prev_pc member. (frame_unwind_sniffer_ftype, frame_unwind_append_sniffer): Delete. (frame_unwind_append_unwinder, frame_unwind_got_optimized) (frame_unwind_got_register, frame_unwind_got_memory) (frame_unwind_got_constant, frame_unwind_got_address): Declare. * frame-base.h: Update comments and parameter names. * valops.c (value_fetch_lazy): Use get_frame_register_value. Iterate if necessary. Add debugging output. * sentinel-frame.c (sentinel_frame_prev_register) (sentinel_frame_this_id): Update for new signature. (sentinel_frame_prev_pc): Delete. (sentinel_frame_unwinder): Remove prev_pc. * ia64-tdep.c (ia64_libunwind_frame_unwind): Do not initialize prev_pc. * libunwind-frame.c (libunwind_frame_unwind): Likewise. * frame-unwind.c (struct frame_unwind_table_entry): Remove sniffer. (frame_unwind_append_sniffer): Delete. (frame_unwind_append_unwinder): New function. (frame_unwind_find_by_frame): Take this frame. Only use sniffers from unwinders. Use frame_prepare_for_sniffer. (default_frame_sniffer, frame_unwind_got_optimized) (frame_unwind_got_register, frame_unwind_got_memory) (frame_unwind_got_constant, frame_unwind_got_address): New functions. * dummy-frame.c (dummy_frame_sniffer): Use gdbarch_dummy_id. (dummy_frame_prev_register, dummy_frame_this_id): Update for new signature. * gdbarch.sh: Replace unwind_dummy_id with dummy_id. * gdbarch.c, gdbarch.c: Regenerated. * frame-base.c (default_frame_base_address) (default_frame_locals_address, default_frame_args_address): Update for new signature. (frame_base_find_by_frame): Pass this frame to unwinder routines. * infcall.c (call_function_by_hand): Update comments. * Makefile.in (frame-unwind.o): Update dependencies. * gdbint.texinfo (Stack Frames): New chapter. (Algorithms): Move Frames text to the new chapter. (Target Conditionals): Delete SAVE_DUMMY_FRAME_TOS. Document gdbarch_dummy_id instead of gdbarch_unwind_dummy_id.
2008-04-30 23:16:46 +02:00
/* Implement DUMMY_ID and PUSH_DUMMY_CALL, then delete
deprecated_fp_regnum. */
extern int gdbarch_deprecated_fp_regnum (struct gdbarch *gdbarch);
extern void set_gdbarch_deprecated_fp_regnum (struct gdbarch *gdbarch, int deprecated_fp_regnum);
extern int gdbarch_push_dummy_call_p (struct gdbarch *gdbarch);
Pass return_method to _push_dummy_call gdb/ChangeLog: * aarch64-tdep.c (aarch64_push_dummy_call): Replace arg with return_method. * alpha-tdep.c (alpha_push_dummy_call): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_push_dummy_call): Likewise. * amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise. * arc-tdep.c (arc_push_dummy_call): Likewise. * arm-tdep.c (arm_push_dummy_call): Likewise. * avr-tdep.c (avr_push_dummy_call): Likewise. * bfin-tdep.c (bfin_push_dummy_call): Likewise. * cris-tdep.c (cris_push_dummy_call): Likewise. * csky-tdep.c (csky_push_dummy_call): Likewise. * frv-tdep.c (frv_push_dummy_call): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (gdbarch_push_dummy_call): Replace arg with return_method. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (hppa32_push_dummy_call): Likewise. (hppa64_push_dummy_call): Likewise. * i386-darwin-tdep.c (i386_darwin_push_dummy_call): Likewise. * i386-tdep.c (i386_push_dummy_call): Likewise. * ia64-tdep.c (ia64_push_dummy_call): Likewise. * infcall.c (call_function_by_hand_dummy): Likewise. * iq2000-tdep.c (iq2000_push_dummy_call): Likewise. * lm32-tdep.c (lm32_push_dummy_call): Likewise. * m32c-tdep.c (m32c_push_dummy_call): Likewise. * m32r-tdep.c (m32r_push_dummy_call): Likewise. * m68hc11-tdep.c (m68hc11_push_dummy_call): Likewise. * m68k-tdep.c (m68k_push_dummy_call): Likewise. * mep-tdep.c (mep_push_dummy_call): Likewise. * mips-tdep.c (mips_eabi_push_dummy_call): Likewise. (mips_n32n64_push_dummy_call): Likewise. (mips_o32_push_dummy_call): Likewise. (mips_o64_push_dummy_call): Likewise. * mn10300-tdep.c (mn10300_push_dummy_call): Likewise. * msp430-tdep.c (msp430_push_dummy_call): Likewise. * nds32-tdep.c (nds32_push_dummy_call): Likewise. * nios2-tdep.c (nios2_push_dummy_call): Likewise. * or1k-tdep.c (or1k_push_dummy_call): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call): Likewise. (ppc64_sysv_abi_push_dummy_call): Likewise. * ppc-tdep.h (ppc_sysv_abi_push_dummy_call): Likewise. (ppc64_sysv_abi_push_dummy_call): Likewise. * riscv-tdep.c (riscv_push_dummy_call): Likewise. * rl78-tdep.c (rl78_push_dummy_call): Likewise. * rs6000-aix-tdep.c (rs6000_push_dummy_call): Likewise. * rs6000-lynx178-tdep.c (rs6000_lynx178_push_dummy_call): Likewise. * rx-tdep.c (rx_push_dummy_call): Likewise. * s390-tdep.c (s390_push_dummy_call): Likewise. * score-tdep.c (score_push_dummy_call): Likewise. * sh-tdep.c (sh_push_dummy_call_fpu): Likewise. (sh_push_dummy_call_nofpu): Likewise. * sparc-tdep.c (sparc32_store_arguments): Likewise. (sparc32_push_dummy_call): Likewise. * sparc64-tdep.c (sparc64_store_arguments): Likewise. (sparc64_push_dummy_call): Likewise. * spu-tdep.c (spu_push_dummy_call): Likewise. * tic6x-tdep.c (tic6x_push_dummy_call): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * v850-tdep.c (v850_push_dummy_call): Likewise. * vax-tdep.c (vax_push_dummy_call): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. * xtensa-tdep.c (xtensa_push_dummy_call): Likewise.
2018-11-16 12:21:04 +01:00
typedef CORE_ADDR (gdbarch_push_dummy_call_ftype) (struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, function_call_return_method return_method, CORE_ADDR struct_addr);
extern CORE_ADDR gdbarch_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, function_call_return_method return_method, CORE_ADDR struct_addr);
extern void set_gdbarch_push_dummy_call (struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype *push_dummy_call);
extern int gdbarch_call_dummy_location (struct gdbarch *gdbarch);
extern void set_gdbarch_call_dummy_location (struct gdbarch *gdbarch, int call_dummy_location);
extern int gdbarch_push_dummy_code_p (struct gdbarch *gdbarch);
typedef CORE_ADDR (gdbarch_push_dummy_code_ftype) (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache);
extern CORE_ADDR gdbarch_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache);
extern void set_gdbarch_push_dummy_code (struct gdbarch *gdbarch, gdbarch_push_dummy_code_ftype *push_dummy_code);
Skip unwritable frames in command "finish" Nowadays, GDB can't insert breakpoint on the return address of the exception handler on ARM M-profile, because the address is a magic one 0xfffffff9, (gdb) bt #0 CT32B1_IRQHandler () at ../src/timer.c:67 #1 <signal handler called> #2 main () at ../src/timer.c:127 (gdb) info frame Stack level 0, frame at 0x200ffa8: pc = 0x4ec in CT32B1_IRQHandler (../src/timer.c:67); saved pc = 0xfffffff9 called by frame at 0x200ffc8 source language c. Arglist at 0x200ffa0, args: Locals at 0x200ffa0, Previous frame's sp is 0x200ffa8 Saved registers: r7 at 0x200ffa0, lr at 0x200ffa4 (gdb) x/x 0xfffffff9 0xfffffff9: Cannot access memory at address 0xfffffff9 (gdb) finish Run till exit from #0 CT32B1_IRQHandler () at ../src/timer.c:67 Ed:15: Target error from Set break/watch: Et:96: Pseudo-address (0xFFFFFFxx) for EXC_RETURN is invalid (GDB error?) Warning: Cannot insert hardware breakpoint 0. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. even some debug probe can't set hardware breakpoint on the magic address too, (gdb) hbreak *0xfffffff9 Hardware assisted breakpoint 2 at 0xfffffff9 (gdb) c Continuing. Ed:15: Target error from Set break/watch: Et:96: Pseudo-address (0xFFFFFFxx) for EXC_RETURN is invalid (GDB error?) Warning: Cannot insert hardware breakpoint 2. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints. Command aborted. The problem described above is quite similar to PR 8841, in which GDB can't set breakpoint on signal trampoline, which is mapped to a read-only page by kernel. The rationale of this patch is to skip "unwritable" frames when looking for caller frames in command "finish", and a new gdbarch method code_of_frame_writable is added. This patch fixes the problem on ARM cortex-m target, but it can be used to fix PR 8841 too. gdb: 2016-05-10 Yao Qi <yao.qi@arm.com> * arch-utils.c (default_code_of_frame_writable): New function. * arch-utils.h (default_code_of_frame_writable): Declare. * arm-tdep.c (arm_code_of_frame_writable): New function. (arm_gdbarch_init): Install gdbarch method code_of_frame_writable if the target is M-profile. * frame.c (skip_unwritable_frames): New function. * frame.h (skip_unwritable_frames): Declare. * gdbarch.sh (code_of_frame_writable): New. * gdbarch.c, gdbarch.h: Re-generated. * infcmd.c (finish_command): Call skip_unwritable_frames.
2016-05-23 18:32:56 +02:00
/* Return true if the code of FRAME is writable. */
typedef int (gdbarch_code_of_frame_writable_ftype) (struct gdbarch *gdbarch, struct frame_info *frame);
extern int gdbarch_code_of_frame_writable (struct gdbarch *gdbarch, struct frame_info *frame);
extern void set_gdbarch_code_of_frame_writable (struct gdbarch *gdbarch, gdbarch_code_of_frame_writable_ftype *code_of_frame_writable);
typedef void (gdbarch_print_registers_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, int regnum, int all);
extern void gdbarch_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, int regnum, int all);
extern void set_gdbarch_print_registers_info (struct gdbarch *gdbarch, gdbarch_print_registers_info_ftype *print_registers_info);
typedef void (gdbarch_print_float_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args);
extern void gdbarch_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args);
extern void set_gdbarch_print_float_info (struct gdbarch *gdbarch, gdbarch_print_float_info_ftype *print_float_info);
extern int gdbarch_print_vector_info_p (struct gdbarch *gdbarch);
typedef void (gdbarch_print_vector_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args);
extern void gdbarch_print_vector_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args);
extern void set_gdbarch_print_vector_info (struct gdbarch *gdbarch, gdbarch_print_vector_info_ftype *print_vector_info);
/* MAP a GDB RAW register number onto a simulator register number. See
also include/...-sim.h. */
typedef int (gdbarch_register_sim_regno_ftype) (struct gdbarch *gdbarch, int reg_nr);
extern int gdbarch_register_sim_regno (struct gdbarch *gdbarch, int reg_nr);
extern void set_gdbarch_register_sim_regno (struct gdbarch *gdbarch, gdbarch_register_sim_regno_ftype *register_sim_regno);
typedef int (gdbarch_cannot_fetch_register_ftype) (struct gdbarch *gdbarch, int regnum);
extern int gdbarch_cannot_fetch_register (struct gdbarch *gdbarch, int regnum);
extern void set_gdbarch_cannot_fetch_register (struct gdbarch *gdbarch, gdbarch_cannot_fetch_register_ftype *cannot_fetch_register);
typedef int (gdbarch_cannot_store_register_ftype) (struct gdbarch *gdbarch, int regnum);
extern int gdbarch_cannot_store_register (struct gdbarch *gdbarch, int regnum);
extern void set_gdbarch_cannot_store_register (struct gdbarch *gdbarch, gdbarch_cannot_store_register_ftype *cannot_store_register);
/* Determine the address where a longjmp will land and save this address
in PC. Return nonzero on success.
FRAME corresponds to the longjmp frame. */
extern int gdbarch_get_longjmp_target_p (struct gdbarch *gdbarch);
1999-06-14 20:08:47 +02:00
typedef int (gdbarch_get_longjmp_target_ftype) (struct frame_info *frame, CORE_ADDR *pc);
extern int gdbarch_get_longjmp_target (struct gdbarch *gdbarch, struct frame_info *frame, CORE_ADDR *pc);
extern void set_gdbarch_get_longjmp_target (struct gdbarch *gdbarch, gdbarch_get_longjmp_target_ftype *get_longjmp_target);
1999-06-14 20:08:47 +02:00
1999-08-31 03:14:27 +02:00
extern int gdbarch_believe_pcc_promotion (struct gdbarch *gdbarch);
extern void set_gdbarch_believe_pcc_promotion (struct gdbarch *gdbarch, int believe_pcc_promotion);
1999-06-14 20:08:47 +02:00
typedef int (gdbarch_convert_register_p_ftype) (struct gdbarch *gdbarch, int regnum, struct type *type);
2003-06-14 Andrew Cagney <cagney@redhat.com> Mark Kettenis <kettenis@gnu.org> * gdbarch.sh (CONVERT_REGISTER_P): Add "type" parameter. (REGISTER_TO_VALUE, VALUE_TO_REGISTER): Replace raw buffer parameter with "frame". * gdbarch.h, gdbarch.c: Re-generate. * frame.h (put_frame_register): Declare. * frame.c (put_frame_register): New function. * arch-utils.c (legacy_convert_register_p): Add "type" parameter. (legacy_register_to_value): Rewrite, use "frame" to get the register value. (legacy_value_to_register): Rewrite, use "frame" to find the register's location before storing. * arch-utils.h (legacy_convert_register_p): Update. (legacy_register_to_value, legacy_value_to_register): Update. * findvar.c (value_from_register): Rewrite, eliminate use of REGISTER_CONVERT_TO_TYPE, pass "type" to CONVERT_REGISTER_P, pass "frame" to REGISTER_TO_VALUE. * valops.c (value_assign): Move the CONVERT_REGISTER code to the lval_reg_frame_relative + lval_register branch of the switch. Do not use REGISTER_CONVERT_FROM_TYPE. Use put_frame_register. * i386-tdep.c (I386_EBX_REGNUM, I386_ECX_REGNUM, I386_ESI_REGNUM, I386_EDI_REGNUM): New defines. (i386_next_regnum, i386_convert_register_p, i386_register_to_value, i386_value_to_register): New functions. (i386_register_convertible, i386_register_convert_to_virtual, i386_convert_to_raw): Remove functions. (i386_gdbarch_init): Set convert_register_p, register_to_value and value_to_register instead of register_convertible, register_convert_to_virtual and register_convert_to_raw. * mips-tdep.c (mips_convert_register_p): New function. (mips_value_to_register): Replace mips_register_convert_from_type. (mips_register_to_value): Replace mips_register_convert_to_type. (mips_gdbarch_init): Set conver_register_p, value_to_register and register_to_value. * alpha-tdep.c (alpha_convert_register_p): Update. (alpha_value_to_register): Update, store the register. (alpha_register_to_value): Update, fetch the register.
2003-06-15 00:35:25 +02:00
extern int gdbarch_convert_register_p (struct gdbarch *gdbarch, int regnum, struct type *type);
extern void set_gdbarch_convert_register_p (struct gdbarch *gdbarch, gdbarch_convert_register_p_ftype *convert_register_p);
gdb/ * dwarf2loc.c (read_pieced_value): Handle get_frame_register_bytes returning that the register piece is unavailable/optimized out. (write_pieced_value): Handle get_frame_register_bytes returning that the register piece is unavailable/optimized out when doing a read-modify write of a bitfield. * findvar.c (value_from_register): Handle get_frame_register_bytes returning that the register piece is unavailable/optimized out. * frame.c (get_frame_register_bytes): New parameters `optimizedp' and `unavailablep'. Throw error on bad debug info. Use frame_register instead of frame_register_read, to fill in the new arguments. * frame.h (get_frame_register_bytes): New parameters `optimizedp' and `unavailablep'. * valops.c: (value_assign): Adjust, and handle get_frame_register_bytes failing. * spu-tdep.c: Include exceptions.h. (spu_software_single_step): Adjust, and handle get_frame_register_bytes failing. (spu_get_longjmp_target): Ditto. * gdbarch.sh (register_to_value): Change to return int. New parameters `optimizedp' and `unavailablep'. * gdbarch.h, gdbarch.c: Regenerate. * i386-tdep.c (i386_register_to_value): Adjust to new gdbarch_register_to_value interface. * i387-tdep.c (i387_register_to_value): Ditto. * i387-tdep.h (i387_register_to_value): Ditto. * alpha-tdep.c (alpha_register_to_value): Ditto. * ia64-tdep.c (ia64_register_to_value): Ditto. * m68k-tdep.c (m68k_register_to_value): Ditto. * mips-tdep.c (mips_register_to_value): Ditto. * rs6000-tdep.c (rs6000_register_to_value): Ditto.
2011-03-18 19:42:41 +01:00
typedef int (gdbarch_register_to_value_ftype) (struct frame_info *frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep);
extern int gdbarch_register_to_value (struct gdbarch *gdbarch, struct frame_info *frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep);
extern void set_gdbarch_register_to_value (struct gdbarch *gdbarch, gdbarch_register_to_value_ftype *register_to_value);
typedef void (gdbarch_value_to_register_ftype) (struct frame_info *frame, int regnum, struct type *type, const gdb_byte *buf);
extern void gdbarch_value_to_register (struct gdbarch *gdbarch, struct frame_info *frame, int regnum, struct type *type, const gdb_byte *buf);
extern void set_gdbarch_value_to_register (struct gdbarch *gdbarch, gdbarch_value_to_register_ftype *value_to_register);
/* Construct a value representing the contents of register REGNUM in
Use address_from_register in dwarf2-frame.c:read_addr_from_reg This patch fixes a problem that prevented use of the Dwarf unwinders on SPU, because dwarf2-frame.c common code did not support the situation where the stack and/or frame pointer is maintained in a *vector* register. This is because read_addr_from_reg is hard-coded to assume that such pointers can be read from registers via a simple get_frame_register / unpack_pointer operation. Now, there *is* a routine address_from_register that calls into the appropriate tdep routines to handle pointer values in "weird" registers like on SPU, but it turns out I cannot simply change dwarf2-frame.c to use address_from_register. This is because address_from_register uses value_from_register to create a (temporary) value, and that routine at some point calls get_frame_id in order to set up that value's VALUE_FRAME_ID entry. However, the dwarf2-frame.c read_addr_from_reg routine will be called during early unwinding (to unwind the frame's CFA), at which point the frame's ID is not actually known yet! This would cause an assert. On the other hand, we may notice that VALUE_FRAME_ID is only needed in the value returned by value_from_register if that value is later used as an lvalue. But this is obviously never done to the temporary value used in address_from_register. So, if we could change address_from_register to not call value_from_register but instead accept constructing a value that doesn't have VALUE_FRAME_ID set, things should be fine. To do that, we can change the value_from_register callback to accept a FRAME_ID instead of a FRAME; the only existing uses of the FRAME argument were either to extract its frame ID, or its gdbarch. (To keep a way of getting at the latter, we also change the callback's type from "f" to "m".) Together with the required follow-on changes in the existing value_from_register implementations (including the default one), this seems to fix the problem. As another minor interface cleanup, I've removed the explicit TYPE argument from address_from_register. This routine really always uses a default pointer type, and in the new implementation it -to some extent- relies on that fact, in that it will now no longer handle types that require gdbarch_convert_register_p handling. gdb: 2014-04-17 Ulrich Weigand  <uweigand@de.ibm.com> * gdbarch.sh (value_from_register): Make class "m" instead of "f". Replace FRAME argument with FRAME_ID. * gdbarch.c, gdbarch.h: Regenerate. * findvar.c (default_value_from_register): Add GDBARCH argument; replace FRAME by FRAME_ID. No longer call get_frame_id. (value_from_register): Update call to gdbarch_value_from_register. * value.h (default_value_from_register): Update prototype. * s390-linux-tdep.c (s390_value_from_register): Update interface and call to default_value_from_register. * spu-tdep.c (spu_value_from_register): Likewise. * findvar.c (address_from_register): Remove TYPE argument. Do not call value_from_register; use gdbarch_value_from_register with null_frame_id instead. * value.h (address_from_register): Update prototype. * dwarf2-frame.c (read_addr_from_reg): Use address_from_register. * dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for address_from_register interface change.
2014-04-17 14:01:39 +02:00
frame FRAME_ID, interpreted as type TYPE. The routine needs to
allocate and return a struct value with all value attributes
(but not the value contents) filled in. */
Use address_from_register in dwarf2-frame.c:read_addr_from_reg This patch fixes a problem that prevented use of the Dwarf unwinders on SPU, because dwarf2-frame.c common code did not support the situation where the stack and/or frame pointer is maintained in a *vector* register. This is because read_addr_from_reg is hard-coded to assume that such pointers can be read from registers via a simple get_frame_register / unpack_pointer operation. Now, there *is* a routine address_from_register that calls into the appropriate tdep routines to handle pointer values in "weird" registers like on SPU, but it turns out I cannot simply change dwarf2-frame.c to use address_from_register. This is because address_from_register uses value_from_register to create a (temporary) value, and that routine at some point calls get_frame_id in order to set up that value's VALUE_FRAME_ID entry. However, the dwarf2-frame.c read_addr_from_reg routine will be called during early unwinding (to unwind the frame's CFA), at which point the frame's ID is not actually known yet! This would cause an assert. On the other hand, we may notice that VALUE_FRAME_ID is only needed in the value returned by value_from_register if that value is later used as an lvalue. But this is obviously never done to the temporary value used in address_from_register. So, if we could change address_from_register to not call value_from_register but instead accept constructing a value that doesn't have VALUE_FRAME_ID set, things should be fine. To do that, we can change the value_from_register callback to accept a FRAME_ID instead of a FRAME; the only existing uses of the FRAME argument were either to extract its frame ID, or its gdbarch. (To keep a way of getting at the latter, we also change the callback's type from "f" to "m".) Together with the required follow-on changes in the existing value_from_register implementations (including the default one), this seems to fix the problem. As another minor interface cleanup, I've removed the explicit TYPE argument from address_from_register. This routine really always uses a default pointer type, and in the new implementation it -to some extent- relies on that fact, in that it will now no longer handle types that require gdbarch_convert_register_p handling. gdb: 2014-04-17 Ulrich Weigand  <uweigand@de.ibm.com> * gdbarch.sh (value_from_register): Make class "m" instead of "f". Replace FRAME argument with FRAME_ID. * gdbarch.c, gdbarch.h: Regenerate. * findvar.c (default_value_from_register): Add GDBARCH argument; replace FRAME by FRAME_ID. No longer call get_frame_id. (value_from_register): Update call to gdbarch_value_from_register. * value.h (default_value_from_register): Update prototype. * s390-linux-tdep.c (s390_value_from_register): Update interface and call to default_value_from_register. * spu-tdep.c (spu_value_from_register): Likewise. * findvar.c (address_from_register): Remove TYPE argument. Do not call value_from_register; use gdbarch_value_from_register with null_frame_id instead. * value.h (address_from_register): Update prototype. * dwarf2-frame.c (read_addr_from_reg): Use address_from_register. * dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for address_from_register interface change.
2014-04-17 14:01:39 +02:00
typedef struct value * (gdbarch_value_from_register_ftype) (struct gdbarch *gdbarch, struct type *type, int regnum, struct frame_id frame_id);
extern struct value * gdbarch_value_from_register (struct gdbarch *gdbarch, struct type *type, int regnum, struct frame_id frame_id);
extern void set_gdbarch_value_from_register (struct gdbarch *gdbarch, gdbarch_value_from_register_ftype *value_from_register);
typedef CORE_ADDR (gdbarch_pointer_to_address_ftype) (struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf);
extern CORE_ADDR gdbarch_pointer_to_address (struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf);
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
extern void set_gdbarch_pointer_to_address (struct gdbarch *gdbarch, gdbarch_pointer_to_address_ftype *pointer_to_address);
typedef void (gdbarch_address_to_pointer_ftype) (struct gdbarch *gdbarch, struct type *type, gdb_byte *buf, CORE_ADDR addr);
extern void gdbarch_address_to_pointer (struct gdbarch *gdbarch, struct type *type, gdb_byte *buf, CORE_ADDR addr);
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new functions which architectures can redefine, defaulting to generic_pointer_to_address and generic_address_to_pointer. * findvar.c (extract_typed_address, store_typed_address, generic_pointer_to_address, generic_address_to_pointer): New functions. (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default definitions. (extract_address, store_address): Doc fixes. * values.c (value_as_pointer): Doc fix. (value_from_pointer): New function. * defs.h (extract_typed_address, store_typed_address): New declarations. * inferior.h (generic_address_to_pointer, generic_pointer_to_address): New declarations. * value.h (value_from_pointer): New declaration. * ax-gdb.c (const_var_ref): Use value_from_pointer, not value_from_longest. * blockframe.c (generic_push_dummy_frame): Use read_pc and read_sp, not read_register. * c-valprint.c (c_val_print): Use extract_typed_address instead of extract_address to extract vtable entries and references. * cp-valprint.c (cp_print_value_fields): Use value_from_pointer instead of value_from_longest to extract the vtable's address. * eval.c (evaluate_subexp_standard): Use value_from_pointer instead of value_from_longest to compute `this', and for doing pointer-to-member dereferencing. * findvar.c (read_register): Use extract_unsigned_integer, not extract_address. (read_var_value): Use store_typed_address instead of store_address for building label values. (locate_var_value): Use value_from_pointer instead of value_from_longest. * hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer, instead of value_from_longest, to build arguments to __d_shl_get. * printcmd.c (set_next_address): Use value_from_pointer, not value_from_longest. (x_command): Use value_from_pointer, not value_from_longest. * tracepoint.c (set_traceframe_context): Use value_from_pointer, not value_from_longest. * valarith.c (value_add, value_sub): Use value_from_pointer, not value_from_longest. * valops.c (find_function_in_inferior, value_coerce_array, value_coerce_function, value_addr, hand_function_call): Same. * value.h (COERCE_REF): Use unpack_pointer, not unpack_long. * values.c (unpack_long): Use extract_typed_address to produce addresses from pointers and references, not extract_address. (value_from_longest): Use store_typed_address instead of store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
extern void set_gdbarch_address_to_pointer (struct gdbarch *gdbarch, gdbarch_address_to_pointer_ftype *address_to_pointer);
extern int gdbarch_integer_to_address_p (struct gdbarch *gdbarch);
typedef CORE_ADDR (gdbarch_integer_to_address_ftype) (struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf);
extern CORE_ADDR gdbarch_integer_to_address (struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf);
extern void set_gdbarch_integer_to_address (struct gdbarch *gdbarch, gdbarch_integer_to_address_ftype *integer_to_address);
gdb/ * breakpoint.h (bp_location): Add related_address member. * inferior.h (get_return_value): Take a pointer to struct value instead of struct type for the function requested. * value.h (using_struct_return): Likewise. * gdbarch.sh (return_value): Take a pointer to struct value instead of struct type for the function requested. * breakpoint.c (set_breakpoint_location_function): Initialize related_address for bp_gnu_ifunc_resolver breakpoints. * elfread.c (elf_gnu_ifunc_resolver_return_stop): Pass the requested function's address to gdbarch_return_value. * eval.c (evaluate_subexp_standard): Pass the requested function's address to using_struct_return. * infcall.c (call_function_by_hand): Pass the requested function's address to using_struct_return and gdbarch_return_value. * infcmd.c (get_return_value): Take a pointer to struct value instead of struct type for the function requested. (print_return_value): Update accordingly. (finish_command_continuation): Likewise. * stack.c (return_command): Pass the requested function's address to using_struct_return and gdbarch_return_value. * value.c (using_struct_return): Take a pointer to struct value instead of struct type for the function requested. Pass the requested function's address to gdbarch_return_value. * python/py-finishbreakpoint.c (finish_breakpoint_object): New function_value member, replacing function_type. (bpfinishpy_dealloc): Update accordingly. (bpfinishpy_pre_stop_hook): Likewise. (bpfinishpy_init): Likewise. Record the requested function's address. * mips-tdep.c (mips_fval_reg): New enum. (mips_o32_push_dummy_call): For MIPS16 FP doubles do not swap words put in GP registers. (mips_o64_push_dummy_call): Update a comment. (mips_o32_return_value): Take a pointer to struct value instead of struct type for the function requested and use it to check if using the MIPS16 calling convention. Return the designated general purpose registers for floating-point values returned in MIPS16 mode. (mips_o64_return_value): Likewise. * ppc-tdep.h (ppc_sysv_abi_return_value): Update prototype. (ppc_sysv_abi_broken_return_value): Likewise. (ppc64_sysv_abi_return_value): Likewise. * alpha-tdep.c (alpha_return_value): Take a pointer to struct value instead of struct type for the function requested. * amd64-tdep.c (amd64_return_value): Likewise. * amd64-windows-tdep.c (amd64_windows_return_value): Likewise. * arm-tdep.c (arm_return_value): Likewise. * avr-tdep.c (avr_return_value): Likewise. * bfin-tdep.c (bfin_return_value): Likewise. * cris-tdep.c (cris_return_value): Likewise. * frv-tdep.c (frv_return_value): Likewise. * h8300-tdep.c (h8300_return_value): Likewise. (h8300h_return_value): Likewise. * hppa-tdep.c (hppa32_return_value): Likewise. (hppa64_return_value): Likewise. * i386-tdep.c (i386_return_value): Likewise. * ia64-tdep.c (ia64_return_value): Likewise. * iq2000-tdep.c (iq2000_return_value): Likewise. * lm32-tdep.c (lm32_return_value): Likewise. * m32c-tdep.c (m32c_return_value): Likewise. * m32r-tdep.c (m32r_return_value): Likewise. * m68hc11-tdep.c (m68hc11_return_value): Likewise. * m68k-tdep.c (m68k_return_value): Likewise. (m68k_svr4_return_value): Likewise. * m88k-tdep.c (m88k_return_value): Likewise. * mep-tdep.c (mep_return_value): Likewise. * microblaze-tdep.c (microblaze_return_value): Likewise. * mn10300-tdep.c (mn10300_return_value): Likewise. * moxie-tdep.c (moxie_return_value): Likewise. * mt-tdep.c (mt_return_value): Likewise. * ppc-linux-tdep.c (ppc_linux_return_value): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_return_value): Likewise. (ppc_sysv_abi_broken_return_value): Likewise. (ppc64_sysv_abi_return_value): Likewise. * ppcnbsd-tdep.c (ppcnbsd_return_value): Likewise. * rl78-tdep.c (rl78_return_value): Likewise. * rs6000-aix-tdep.c (rs6000_return_value): Likewise. * rx-tdep.c (rx_return_value): Likewise. * s390-tdep.c (s390_return_value): Likewise. * score-tdep.c (score_return_value): Likewise. * sh-tdep.c (sh_return_value_nofpu): Likewise. (sh_return_value_fpu): Likewise. * sh64-tdep.c (sh64_return_value): Likewise. * sparc-tdep.c (sparc32_return_value): Likewise. * sparc64-tdep.c (sparc64_return_value): Likewise. * spu-tdep.c (spu_return_value): Likewise. * tic6x-tdep.c (tic6x_return_value): Likewise. * v850-tdep.c (v850_return_value): Likewise. * vax-tdep.c (vax_return_value): Likewise. * xstormy16-tdep.c (xstormy16_return_value): Likewise. * xtensa-tdep.c (xtensa_return_value): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. gdb/testsuite/ * gdb.base/return-nodebug.exp: Also test float and double types.
2012-05-16 16:35:09 +02:00
/* Return the return-value convention that will be used by FUNCTION
to return a value of type VALTYPE. FUNCTION may be NULL in which
case the return convention is computed based only on VALTYPE.
If READBUF is not NULL, extract the return value and save it in this buffer.
If WRITEBUF is not NULL, it contains a return value which will be
stored into the appropriate register. This can be used when we want
to force the value returned by a function (see the "return" command
for instance). */
extern int gdbarch_return_value_p (struct gdbarch *gdbarch);
gdb/ * breakpoint.h (bp_location): Add related_address member. * inferior.h (get_return_value): Take a pointer to struct value instead of struct type for the function requested. * value.h (using_struct_return): Likewise. * gdbarch.sh (return_value): Take a pointer to struct value instead of struct type for the function requested. * breakpoint.c (set_breakpoint_location_function): Initialize related_address for bp_gnu_ifunc_resolver breakpoints. * elfread.c (elf_gnu_ifunc_resolver_return_stop): Pass the requested function's address to gdbarch_return_value. * eval.c (evaluate_subexp_standard): Pass the requested function's address to using_struct_return. * infcall.c (call_function_by_hand): Pass the requested function's address to using_struct_return and gdbarch_return_value. * infcmd.c (get_return_value): Take a pointer to struct value instead of struct type for the function requested. (print_return_value): Update accordingly. (finish_command_continuation): Likewise. * stack.c (return_command): Pass the requested function's address to using_struct_return and gdbarch_return_value. * value.c (using_struct_return): Take a pointer to struct value instead of struct type for the function requested. Pass the requested function's address to gdbarch_return_value. * python/py-finishbreakpoint.c (finish_breakpoint_object): New function_value member, replacing function_type. (bpfinishpy_dealloc): Update accordingly. (bpfinishpy_pre_stop_hook): Likewise. (bpfinishpy_init): Likewise. Record the requested function's address. * mips-tdep.c (mips_fval_reg): New enum. (mips_o32_push_dummy_call): For MIPS16 FP doubles do not swap words put in GP registers. (mips_o64_push_dummy_call): Update a comment. (mips_o32_return_value): Take a pointer to struct value instead of struct type for the function requested and use it to check if using the MIPS16 calling convention. Return the designated general purpose registers for floating-point values returned in MIPS16 mode. (mips_o64_return_value): Likewise. * ppc-tdep.h (ppc_sysv_abi_return_value): Update prototype. (ppc_sysv_abi_broken_return_value): Likewise. (ppc64_sysv_abi_return_value): Likewise. * alpha-tdep.c (alpha_return_value): Take a pointer to struct value instead of struct type for the function requested. * amd64-tdep.c (amd64_return_value): Likewise. * amd64-windows-tdep.c (amd64_windows_return_value): Likewise. * arm-tdep.c (arm_return_value): Likewise. * avr-tdep.c (avr_return_value): Likewise. * bfin-tdep.c (bfin_return_value): Likewise. * cris-tdep.c (cris_return_value): Likewise. * frv-tdep.c (frv_return_value): Likewise. * h8300-tdep.c (h8300_return_value): Likewise. (h8300h_return_value): Likewise. * hppa-tdep.c (hppa32_return_value): Likewise. (hppa64_return_value): Likewise. * i386-tdep.c (i386_return_value): Likewise. * ia64-tdep.c (ia64_return_value): Likewise. * iq2000-tdep.c (iq2000_return_value): Likewise. * lm32-tdep.c (lm32_return_value): Likewise. * m32c-tdep.c (m32c_return_value): Likewise. * m32r-tdep.c (m32r_return_value): Likewise. * m68hc11-tdep.c (m68hc11_return_value): Likewise. * m68k-tdep.c (m68k_return_value): Likewise. (m68k_svr4_return_value): Likewise. * m88k-tdep.c (m88k_return_value): Likewise. * mep-tdep.c (mep_return_value): Likewise. * microblaze-tdep.c (microblaze_return_value): Likewise. * mn10300-tdep.c (mn10300_return_value): Likewise. * moxie-tdep.c (moxie_return_value): Likewise. * mt-tdep.c (mt_return_value): Likewise. * ppc-linux-tdep.c (ppc_linux_return_value): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_return_value): Likewise. (ppc_sysv_abi_broken_return_value): Likewise. (ppc64_sysv_abi_return_value): Likewise. * ppcnbsd-tdep.c (ppcnbsd_return_value): Likewise. * rl78-tdep.c (rl78_return_value): Likewise. * rs6000-aix-tdep.c (rs6000_return_value): Likewise. * rx-tdep.c (rx_return_value): Likewise. * s390-tdep.c (s390_return_value): Likewise. * score-tdep.c (score_return_value): Likewise. * sh-tdep.c (sh_return_value_nofpu): Likewise. (sh_return_value_fpu): Likewise. * sh64-tdep.c (sh64_return_value): Likewise. * sparc-tdep.c (sparc32_return_value): Likewise. * sparc64-tdep.c (sparc64_return_value): Likewise. * spu-tdep.c (spu_return_value): Likewise. * tic6x-tdep.c (tic6x_return_value): Likewise. * v850-tdep.c (v850_return_value): Likewise. * vax-tdep.c (vax_return_value): Likewise. * xstormy16-tdep.c (xstormy16_return_value): Likewise. * xtensa-tdep.c (xtensa_return_value): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. gdb/testsuite/ * gdb.base/return-nodebug.exp: Also test float and double types.
2012-05-16 16:35:09 +02:00
typedef enum return_value_convention (gdbarch_return_value_ftype) (struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf);
extern enum return_value_convention gdbarch_return_value (struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf);
extern void set_gdbarch_return_value (struct gdbarch *gdbarch, gdbarch_return_value_ftype *return_value);
/* Return true if the return value of function is stored in the first hidden
parameter. In theory, this feature should be language-dependent, specified
by language and its ABI, such as C++. Unfortunately, compiler may
implement it to a target-dependent feature. So that we need such hook here
to be aware of this in GDB. */
typedef int (gdbarch_return_in_first_hidden_param_p_ftype) (struct gdbarch *gdbarch, struct type *type);
extern int gdbarch_return_in_first_hidden_param_p (struct gdbarch *gdbarch, struct type *type);
extern void set_gdbarch_return_in_first_hidden_param_p (struct gdbarch *gdbarch, gdbarch_return_in_first_hidden_param_p_ftype *return_in_first_hidden_param_p);
* gdbarch.sh (skip_prologue): Add gdbarch as parameter. * gdbarch.{c,h}: Regenerate. * alpha-tdep.c (alpha_skip_prologue): Add gdbarch as parameter. * amd64-tdep.c (amd64_skip_prologue): Likewise. * avr-tdep.c (avr_skip_prologue): Likewise. * cris-tdep.c (cris_skip_prologue): Likewise. * frv-tdep.c (frv_skip_prologue): Likewise. * h8300-tdep.c (h8300_skip_prologue): Likewise. * hppa-tdep.c (hppa_skip_prologue): Likewise. * i386-tdep.c (i386_skip_prologue): Likewise. * ia64-tdep.c (ia64_skip_prologue): Likewise. * iq2000-tdep.c (iq2000_skip_prologue): Likewise. * m32r-tdep.c (m32r_skip_prologue): Likewise. * m68hc11-tdep.c (m68hc11_skip_prologue): Likewise. * m68k-tdep.c (m68k_skip_prologue): Likewise. * m88k-tdep.c (m88k_skip_prologue): Likewise. * mep-tdep.c (mep_skip_prologue): Likewise. * mips-tdep.c (mips_skip_prologue): Likewise. * mn10300-tdep.c (mn10300_skip_prologue): Likewise. * mt-tdep.c (mt_skip_prologue): Likewise. * rs6000-tdep.c (rs6000_skip_prologue): Likewise. * score-tdep.c (score_skip_prologue): Likewise. * sh64-tdep.c (sh64_skip_prologue): Likewise. * sh-tdep.c (sh_skip_prologue): Likewise. * sparc64-tdep.c (sparc64_skip_prologue): Likewise. * sparc-tdep.c (sparc32_skip_prologue): Likewise. * spu-tdep.c (spu_skip_prologue): Likewise. * v850-tdep.c (v850_skip_prologue): Likewise. * vax-tdep.c (vax_skip_prologue): Likewise. * xstormy16-tdep.c (xstormy16_skip_prologue): Likewise. * xtensa-tdep.c (xtensa_skip_prologue): Likewise. * arm-tdep.c (arm_skip_prologue): Add gdbarch as parameter. Replace current_gdbarch by gdbarch. * m32c-tdep.c (m32c_skip_prologue): Likewise. * s390-tdep.c (s390_skip_prologue): Likewise.
2008-01-11 14:20:02 +01:00
typedef CORE_ADDR (gdbarch_skip_prologue_ftype) (struct gdbarch *gdbarch, CORE_ADDR ip);
1999-08-31 03:14:27 +02:00
extern CORE_ADDR gdbarch_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR ip);
extern void set_gdbarch_skip_prologue (struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype *skip_prologue);
1999-06-14 20:08:47 +02:00
extern int gdbarch_skip_main_prologue_p (struct gdbarch *gdbarch);
typedef CORE_ADDR (gdbarch_skip_main_prologue_ftype) (struct gdbarch *gdbarch, CORE_ADDR ip);
extern CORE_ADDR gdbarch_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR ip);
extern void set_gdbarch_skip_main_prologue (struct gdbarch *gdbarch, gdbarch_skip_main_prologue_ftype *skip_main_prologue);
PowerPC64 ELFv2 ABI: skip global entry point code This patch handles another aspect of the ELFv2 ABI, which unfortunately requires common code changes. In ELFv2, functions may provide both a global and a local entry point. The global entry point (where the function symbol points to) is intended to be used for function-pointer or cross-module (PLT) calls, and requires r12 to be set up to the entry point address itself. The local entry point (which is found at a fixed offset after the global entry point, as defined by bits in the symbol table entries' st_other field), instead expects r2 to be set up to the current TOC. Now, when setting a breakpoint on a function by name, you really want that breakpoint to trigger either way, no matter whether the function is called via its local or global entry point. Since the global entry point will always fall through into the local entry point, the way to achieve that is to simply set the breakpoint at the local entry point. One way to do that would be to have prologue parsing skip the code sequence that makes up the global entry point. Unfortunately, this does not work reliably, since -for optimized code- GDB these days will not actuall invoke the prologue parsing code but instead just set the breakpoint at the symbol address and rely on DWARF being correct at any point throughout the function ... Unfortunately, I don't really see any way to express the notion of local entry points with the current set of gdbarch callbacks. Thus this patch adds a new callback, skip_entrypoint, that is somewhat analogous to skip_prologue, but is called every time GDB needs to determine a function start address, even in those cases where GDB decides to not call skip_prologue. As a side effect, the skip_entrypoint implementation on ppc64 does not need to perform any instruction parsing; it can simply rely on the local entry point flags in the symbol table entry. With this implemented, two test cases would still fail to set the breakpoint correctly, but that's because they use the construct: gdb_test "break *hello" Now, using "*hello" explicitly instructs GDB to set the breakpoint at the numerical value of "hello" treated as function pointer, so it will by definition only hit the global entry point. I think this behaviour is unavoidable, but acceptable -- most people do not use this construct, and if they do, they get what they asked for ... In one of those two test cases, use of this construct is really not appropriate. I think this was added way back when as a means to work around prologue skipping problems on some platforms. These days that shouldn't really be necessary any more ... For the other (step-bt), we really want to make sure backtracing works on the very first instruction of the routine. To enable that test also on powerpc64le-linux, we can modify the code to call the test function via function pointer (which makes it use the global entry point in the ELFv2 ABI). gdb/ChangeLog: * gdbarch.sh (skip_entrypoint): New callback. * gdbarch.c, gdbarch.h: Regenerate. * symtab.c (skip_prologue_sal): Call gdbarch_skip_entrypoint. * infrun.c (fill_in_stop_func): Likewise. * ppc-linux-tdep.c: Include "elf/ppc64.h". (ppc_elfv2_elf_make_msymbol_special): New function. (ppc_elfv2_skip_entrypoint): Likewise. (ppc_linux_init_abi): Install them for ELFv2. gdb/testsuite/ChangeLog: * gdb.base/sigbpt.exp: Do not use "*" when setting breakpoint on a function. * gdb.base/step-bt.c: Call hello via function pointer to make sure its first instruction is executed on powerpc64le-linux.
2014-02-04 18:44:14 +01:00
/* On some platforms, a single function may provide multiple entry points,
e.g. one that is used for function-pointer calls and a different one
that is used for direct function calls.
In order to ensure that breakpoints set on the function will trigger
no matter via which entry point the function is entered, a platform
may provide the skip_entrypoint callback. It is called with IP set
to the main entry point of a function (as determined by the symbol table),
and should return the address of the innermost entry point, where the
actual breakpoint needs to be set. Note that skip_entrypoint is used
by GDB common code even when debugging optimized code, where skip_prologue
is not used. */
extern int gdbarch_skip_entrypoint_p (struct gdbarch *gdbarch);
typedef CORE_ADDR (gdbarch_skip_entrypoint_ftype) (struct gdbarch *gdbarch, CORE_ADDR ip);
extern CORE_ADDR gdbarch_skip_entrypoint (struct gdbarch *gdbarch, CORE_ADDR ip);
extern void set_gdbarch_skip_entrypoint (struct gdbarch *gdbarch, gdbarch_skip_entrypoint_ftype *skip_entrypoint);
1999-08-31 03:14:27 +02:00
typedef int (gdbarch_inner_than_ftype) (CORE_ADDR lhs, CORE_ADDR rhs);
extern int gdbarch_inner_than (struct gdbarch *gdbarch, CORE_ADDR lhs, CORE_ADDR rhs);
extern void set_gdbarch_inner_than (struct gdbarch *gdbarch, gdbarch_inner_than_ftype *inner_than);
1999-06-14 20:08:47 +02:00
2007-11-07 07:33:01 +01:00
typedef const gdb_byte * (gdbarch_breakpoint_from_pc_ftype) (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr);
extern const gdb_byte * gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr);
1999-08-31 03:14:27 +02:00
extern void set_gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc);
New gdbarch methods breakpoint_kind_from_pc and sw_breakpoint_from_kind This patch adds two gdbarch methods breakpoint_kind_from_pc and sw_breakpoint_from_kind, and uses target_info.placed_size as "kind" of the breakpoint. This patch updates the usages of target_info.placed_size. The "kind" of a breakpoint is determined by gdbarch rather than target, so we have gdbarch method breakpoint_kind_from_pc, and we should set target_info.placed_size out of each implementation of target to_insert_breakpoint. In this way, each target doesn't have to set target_info.placed_size any more. This patch also sets target_info.placed_address before target_insert_breakpoint too, so that target to_insert_breakpoint can use it, see record_full_insert_breakpoint. Before we call target_insert_breakpoint, we set target_info.placed_address and target_info.placed_size like this, CORE_ADDR addr = bl->target_info.reqstd_address; bl->target_info.placed_size = gdbarch_breakpoint_kind_from_pc (bl->gdbarch, &addr); bl->target_info.placed_address = addr; return target_insert_breakpoint (bl->gdbarch, &bl->target_info); target_insert_breakpoint may fail, but it doesn't matter to the "kind" and "placed_address" of a breakpoint. They should be determined by gdbarch. gdb: 2016-11-03 Yao Qi <yao.qi@linaro.org> * arch-utils.h (GDBARCH_BREAKPOINT_MANIPULATION): Define breakpoint_kind_from_pc and sw_breakpoint_from_kind. (GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN): Likewise. (SET_GDBARCH_BREAKPOINT_MANIPULATION): Call set_gdbarch_breakpoint_kind_from_pc and set_gdbarch_sw_breakpoint_from_kind. * arm-tdep.c: Add comments. * bfin-tdep.c: Likewise. * breakpoint.c (breakpoint_kind): New function. (insert_bp_location): Set target_info.placed_size and target_info.placed_address. (bkpt_insert_location): Likewise. * cris-tdep.c: Add comments. * gdbarch.sh (breakpoint_kind_from_pc): New. (sw_breakpoint_from_kind): New. * gdbarch.c, gdbarch.h: Regenerated. * ia64-tdep.c (ia64_memory_insert_breakpoint): Don't set bp_tgt->placed_size. (ia64_memory_remove_breakpoint): Don't assert bp_tgt->placed_size. (ia64_breakpoint_kind_from_pc): New function. (ia64_gdbarch_init): Install ia64_breakpoint_kind_from_pc. * m32r-tdep.c (m32r_memory_insert_breakpoint): Don't set bp_tgt->placed_size. * mem-break.c (default_memory_insert_breakpoint): Don't set bp_tgt->placed_size. Call gdbarch_sw_breakpoint_from_kind. (default_memory_remove_breakpoint): Call gdbarch_sw_breakpoint_from_kind. (memory_validate_breakpoint): Don't check bp_tgt->placed_size. * mips-tdep.c: Add comments. * mt-tdep.c: Likewise. * nios2-tdep.c: Likewise. * record-full.c (record_full_insert_breakpoint): Don't call gdbarch_breakpoint_from_pc. Don't set bp_tgt->placed_address and bp_tgt->placed_size. * remote.c (remote_insert_breakpoint): Don't call gdbarch_remote_breakpoint_from_pc. Use bp_tgt->placed_size. Don't set bp_tgt->placed_address and bp_tgt->placed_size. (remote_insert_hw_breakpoint): Likewise. * score-tdep.c: Likewise. * sh-tdep.c: Likewise. * tic6x-tdep.c: Likewise. * v850-tdep.c: Likewise. * xtensa-tdep.c: Likewise.
2016-11-03 15:35:13 +01:00
/* Return the breakpoint kind for this target based on *PCPTR. */
typedef int (gdbarch_breakpoint_kind_from_pc_ftype) (struct gdbarch *gdbarch, CORE_ADDR *pcptr);
extern int gdbarch_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr);
extern void set_gdbarch_breakpoint_kind_from_pc (struct gdbarch *gdbarch, gdbarch_breakpoint_kind_from_pc_ftype *breakpoint_kind_from_pc);
/* Return the software breakpoint from KIND. KIND can have target
specific meaning like the Z0 kind parameter.
SIZE is set to the software breakpoint's length in memory. */
typedef const gdb_byte * (gdbarch_sw_breakpoint_from_kind_ftype) (struct gdbarch *gdbarch, int kind, int *size);
extern const gdb_byte * gdbarch_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size);
extern void set_gdbarch_sw_breakpoint_from_kind (struct gdbarch *gdbarch, gdbarch_sw_breakpoint_from_kind_ftype *sw_breakpoint_from_kind);
/* Return the breakpoint kind for this target based on the current
processor state (e.g. the current instruction mode on ARM) and the
*PCPTR. In default, it is gdbarch->breakpoint_kind_from_pc. */
typedef int (gdbarch_breakpoint_kind_from_current_state_ftype) (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR *pcptr);
extern int gdbarch_breakpoint_kind_from_current_state (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR *pcptr);
extern void set_gdbarch_breakpoint_kind_from_current_state (struct gdbarch *gdbarch, gdbarch_breakpoint_kind_from_current_state_ftype *breakpoint_kind_from_current_state);
extern int gdbarch_adjust_breakpoint_address_p (struct gdbarch *gdbarch);
typedef CORE_ADDR (gdbarch_adjust_breakpoint_address_ftype) (struct gdbarch *gdbarch, CORE_ADDR bpaddr);
extern CORE_ADDR gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr);
extern void set_gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, gdbarch_adjust_breakpoint_address_ftype *adjust_breakpoint_address);
typedef int (gdbarch_memory_insert_breakpoint_ftype) (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt);
gdb/ * breakpoint.c (deprecated_read_memory_nobpt): Update to use shadow_len. (insert_bp_location, reattach_breakpoints, remove_breakpoint) (delete_breakpoint): Update calls to changed methods. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (single_step_breakpoints, insert_single_step_breakpoint) (remove_single_step_breakpoints): New. * breakpoint.h (struct bp_target_info): New. (struct bp_location): Replace shadow_contents with target_info and overlay_target_info. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (insert_single_step_breakpoint, remove_single_step_breakpoints): New prototypes. * gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h. (memory_insert_breakpoint, memory_remove_breakpoint): Update second argument. * mem-break.c (default_memory_insert_breakpoint): Update. Set placed_address, placed_size, and shadow_len. (default_memory_remove_breakpoint): Update. Don't use BREAKPOINT_FROM_PC. (memory_insert_breakpoint, memory_remove_breakpoint): Update. * target.c (update_current_target): Update prototypes for changed functions. (debug_to_insert_breakpoint, debug_to_remove_breakpoint) (debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Update. * target.h: Forward declare struct bp_target_info. (struct target_ops): Use a bp_target_info argument for to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint. (target_insert_breakpoint, target_remove_breakpoint) (target_insert_hw_breakpoint, target_remove_hw_breakpoint) (memory_insert_breakpoint, memory_remove_breakpoint) (default_memory_insert_breakpoint, default_memory_remove_breakpoint): Update. * config/i386/nm-i386.h: Forward declare struct bp_target_info. (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. (target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise. * gdbarch.c, gdbarch.h: Regenerated. * alpha-tdep.c (alpha_software_single_step): Use insert_single_step_breakpoint and remove_single_step_breakpoints. Remove unused statics. * arm-tdep.c (arm_software_single_step): Likewise. Add a note. * cris-tdep.c (cris_software_single_step): Likewise. * mips-tdep.c (mips_software_single_step): Likewise. * rs6000-tdep.c (rs6000_software_single_step): Likewise. * sparc-tdep.c (sparc_software_single_step): Likewise. * wince.c (struct thread_info_struct): Remove step_prev. (undoSStep): Use remove_single_step_breakpoints. (wince_software_single_step): Use insert_single_step_breakpoint. * corelow.c (ignore): Remove unneeded prototype. Update arguments. * exec.c (ignore): Likewise. * sol-thread.c (ignore): Likewise. * procfs.c (dbx_link_shadow_contents): Delete. (dbx_link_bpt): New. (procfs_mourn_inferior): Remove it if necessary. (remove_dbx_link_breakpoint): Use it. (insert_dbx_link_bpt_in_file): Set it. (procfs_init_inferior): Don't update dbx_link_bpt_addr. * rs6000-nat.c (exec_one_dummy_insn): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * solib-irix.c (shadow_contents, breakpoint_addr): Delete. (base_breakpoint): New. (disable_break): Use it. (enable_break): Set it. * i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint) (ia64_memory_remove_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint) (m32r_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Likewise. Remove unnecessary prototypes. Use placed_address and placed_size. Removed useless read from memory. * nto-procfs.c (procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint): Update. * ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise. * remote-e7000.c (e7000_insert_breakpoint) (e7000_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint) (mips_remove_breakpoint): Likewise. * remote-rdp.c (remote_rdp_insert_breakpoint) (remote_rdp_remove_breakpoint): Likewise. (rdp_step): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint): Update. * remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint): Delete. (init_gdbsim_ops): Use memory_insert_breakpoint and memory_remove_breakpoint. * remote-st.c (st2000_insert_breakpoint) (st2000_remove_breakpoint): Update. Remove unused BREAKPOINT_FROM_PC. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Update. Use placed_address and placed_size. (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise. gdb/doc/ * gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert and remove breakpoint prototypes. (Watchpoints): Move description of target_insert_hw_breakpoint and target_remove_hw_breakpoint ... (Breakpoints): ... to here. Document target_insert_breakpoint and target_remove_breakpoint.
2006-04-18 21:20:08 +02:00
extern int gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt);
1999-10-19 04:47:02 +02:00
extern void set_gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint);
typedef int (gdbarch_memory_remove_breakpoint_ftype) (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt);
gdb/ * breakpoint.c (deprecated_read_memory_nobpt): Update to use shadow_len. (insert_bp_location, reattach_breakpoints, remove_breakpoint) (delete_breakpoint): Update calls to changed methods. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (single_step_breakpoints, insert_single_step_breakpoint) (remove_single_step_breakpoints): New. * breakpoint.h (struct bp_target_info): New. (struct bp_location): Replace shadow_contents with target_info and overlay_target_info. (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint) (insert_single_step_breakpoint, remove_single_step_breakpoints): New prototypes. * gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h. (memory_insert_breakpoint, memory_remove_breakpoint): Update second argument. * mem-break.c (default_memory_insert_breakpoint): Update. Set placed_address, placed_size, and shadow_len. (default_memory_remove_breakpoint): Update. Don't use BREAKPOINT_FROM_PC. (memory_insert_breakpoint, memory_remove_breakpoint): Update. * target.c (update_current_target): Update prototypes for changed functions. (debug_to_insert_breakpoint, debug_to_remove_breakpoint) (debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint): Update. * target.h: Forward declare struct bp_target_info. (struct target_ops): Use a bp_target_info argument for to_insert_breakpoint, to_remove_breakpoint, to_insert_hw_breakpoint, and to_remove_hw_breakpoint. (target_insert_breakpoint, target_remove_breakpoint) (target_insert_hw_breakpoint, target_remove_hw_breakpoint) (memory_insert_breakpoint, memory_remove_breakpoint) (default_memory_insert_breakpoint, default_memory_remove_breakpoint): Update. * config/i386/nm-i386.h: Forward declare struct bp_target_info. (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. (target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise. * gdbarch.c, gdbarch.h: Regenerated. * alpha-tdep.c (alpha_software_single_step): Use insert_single_step_breakpoint and remove_single_step_breakpoints. Remove unused statics. * arm-tdep.c (arm_software_single_step): Likewise. Add a note. * cris-tdep.c (cris_software_single_step): Likewise. * mips-tdep.c (mips_software_single_step): Likewise. * rs6000-tdep.c (rs6000_software_single_step): Likewise. * sparc-tdep.c (sparc_software_single_step): Likewise. * wince.c (struct thread_info_struct): Remove step_prev. (undoSStep): Use remove_single_step_breakpoints. (wince_software_single_step): Use insert_single_step_breakpoint. * corelow.c (ignore): Remove unneeded prototype. Update arguments. * exec.c (ignore): Likewise. * sol-thread.c (ignore): Likewise. * procfs.c (dbx_link_shadow_contents): Delete. (dbx_link_bpt): New. (procfs_mourn_inferior): Remove it if necessary. (remove_dbx_link_breakpoint): Use it. (insert_dbx_link_bpt_in_file): Set it. (procfs_init_inferior): Don't update dbx_link_bpt_addr. * rs6000-nat.c (exec_one_dummy_insn): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * solib-irix.c (shadow_contents, breakpoint_addr): Delete. (base_breakpoint): New. (disable_break): Use it. (enable_break): Set it. * i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint) (ia64_memory_remove_breakpoint): Likewise. * m32r-tdep.c (m32r_memory_insert_breakpoint) (m32r_memory_remove_breakpoint): Likewise. * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint): Likewise. Remove unnecessary prototypes. Use placed_address and placed_size. Removed useless read from memory. * nto-procfs.c (procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint): Update. * ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise. * ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise. * remote-e7000.c (e7000_insert_breakpoint) (e7000_remove_breakpoint): Likewise. * remote-m32r-sdi.c (m32r_insert_breakpoint) (m32r_remove_breakpoint): Likewise. * remote-mips.c (mips_insert_breakpoint) (mips_remove_breakpoint): Likewise. * remote-rdp.c (remote_rdp_insert_breakpoint) (remote_rdp_remove_breakpoint): Likewise. (rdp_step): Use deprecated_insert_raw_breakpoint and deprecated_remove_raw_breakpoint. * remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint): Update. * remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint): Delete. (init_gdbsim_ops): Use memory_insert_breakpoint and memory_remove_breakpoint. * remote-st.c (st2000_insert_breakpoint) (st2000_remove_breakpoint): Update. Remove unused BREAKPOINT_FROM_PC. * remote.c (remote_insert_breakpoint, remote_remove_breakpoint): Update. Use placed_address and placed_size. (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise. gdb/doc/ * gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert and remove breakpoint prototypes. (Watchpoints): Move description of target_insert_hw_breakpoint and target_remove_hw_breakpoint ... (Breakpoints): ... to here. Document target_insert_breakpoint and target_remove_breakpoint.
2006-04-18 21:20:08 +02:00
extern int gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt);
1999-10-19 04:47:02 +02:00
extern void set_gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint);
1999-08-31 03:14:27 +02:00
extern CORE_ADDR gdbarch_decr_pc_after_break (struct gdbarch *gdbarch);
extern void set_gdbarch_decr_pc_after_break (struct gdbarch *gdbarch, CORE_ADDR decr_pc_after_break);
1999-06-14 20:08:47 +02:00
/* A function can be addressed by either it's "pointer" (possibly a
descriptor address) or "entry point" (first executable instruction).
The method "convert_from_func_ptr_addr" converting the former to the
latter. gdbarch_deprecated_function_start_offset is being used to implement
a simplified subset of that functionality - the function's address
corresponds to the "function pointer" and the function's start
corresponds to the "function entry point" - and hence is redundant. */
extern CORE_ADDR gdbarch_deprecated_function_start_offset (struct gdbarch *gdbarch);
extern void set_gdbarch_deprecated_function_start_offset (struct gdbarch *gdbarch, CORE_ADDR deprecated_function_start_offset);
1999-06-14 20:08:47 +02:00
* Makefile.in (arm-tdep.o, eval.o, target-descriptions.o) (xml-tdesc.o): Update. * xml-support.c: Add a comment. (gdb_xml_enums_boolean): New variable. (gdb_xml_parse_attr_enum): Use strcasecmp. * xml-support.h (gdb_xml_enums_boolean): Declare. * xml-tdesc.c (struct tdesc_parsing_data): Record current_feature, next_regnum, and current_union. (tdesc_start_feature, tdesc_start_reg, tdesc_start_union) (tdesc_end_union, tdesc_start_field, tdesc_start_vector) (field_attributes, union_children, reg_attributes, union_attributes) (vector_attributes, feature_attributes, feature_children): New. (target_children): Make static. Add <feature>. (tdesc_elements): Make static. * target-descriptions.c (struct tdesc_reg, tdesc_reg_p, type_p) (struct tdesc_feature, tdesc_feature_p): New types. (struct target_desc): Add features member. (struct tdesc_arch_data, tdesc_data): New. (target_find_description): Clarify error message. Warn about ignored register descriptions. (tdesc_has_registers, tdesc_find_feature, tdesc_feature_name) (tdesc_named_type, tdesc_data_init, tdesc_data_alloc) (tdesc_data_cleanup, tdesc_numbered_register) (tdesc_numbered_register_choices, tdesc_find_register) (tdesc_register_name, tdesc_register_type) (tdesc_remote_register_number, tdesc_register_reggroup_p) (set_tdesc_pseudo_register_name, set_tdesc_pseudo_register_type) (set_tdesc_pseudo_register_reggroup_p, tdesc_use_registers) (tdesc_free_reg, tdesc_create_reg, tdesc_free_feature) (tdesc_create_feature, tdesc_record_type): New. (free_target_description): Free features. (_initialize_target_descriptions): Initialize tdesc_data. * arch-utils.c (default_remote_register_number): New. * arch-utils.h (default_remote_register_number): New prototype. * target-descriptions.h (set_tdesc_pseudo_register_name) (set_tdesc_pseudo_register_type, set_tdesc_pseudo_register_reggroup_p) (tdesc_use_registers, tdesc_data_alloc, tdesc_data_cleanup) (tdesc_numbered_register, tdesc_numbered_register_choices) (tdesc_has_registers, tdesc_find_feature, tdesc_feature_name) (tdesc_named_type, tdesc_create_feature, tdesc_record_type) (tdesc_create_reg): Declare. * gdbarch.sh (remote_register_number): New entry. * gdbarch.c, gdbarch.h: Regenerate. * remote.c (init_remote_state): Use gdbarch_remote_register_number. * features/gdb-target.dtd: Add feature, reg, vector, union, and field. * arm-tdep.c (arm_register_aliases): New. (arm_register_name_strings): Rename to... (arm_register_names): ...this. Make const. Delete the old version. (current_option, arm_register_byte): Delete. (set_disassembly_style): Simplify. Do not adjust arm_register_names. (value_of_arm_user_reg): New. (arm_gdbarch_init): Verify any described registers. Call tdesc_use_registers. Don't use arm_register_byte. Create aliases for standard register names. (_initialize_arm_tdep): Do not adjust arm_register_names. * user-regs.c (struct user_reg): Add baton member. (append_user_reg, user_reg_add_builtin, user_regs_init) (user_reg_add, value_of_user_reg): Use a baton for user register functions. * std-regs.c: Update. * user-regs.h (user_reg_read_ftype, user_reg_add_builtin) (user_reg_add): Add baton argument. * NEWS: Mention target description register support. * features/arm-core.xml, features/arm-fpa.xml: New. * eval.c (evaluate_subexp_standard): Allow ptype $register when the program is not running. * gdb.texinfo (-target-disconnect): Use @smallexample. (Requirements): Add anchor for Expat. Update description. (Target Descriptions): Mention Expat. (Target Description Format): Document new elements. Use @smallexample. (Predefined Target Types, Standard Target Features): New sections. * doc/gdbint.texinfo (Target Descriptions): New section. * gdb.xml/single-reg.xml, gdb.xml/tdesc-regs.exp, gdb.xml/core-only.xml, gdb.xml/extra-regs.xml: New files.
2007-02-08 22:00:36 +01:00
/* Return the remote protocol register number associated with this
register. Normally the identity mapping. */
typedef int (gdbarch_remote_register_number_ftype) (struct gdbarch *gdbarch, int regno);
extern int gdbarch_remote_register_number (struct gdbarch *gdbarch, int regno);
extern void set_gdbarch_remote_register_number (struct gdbarch *gdbarch, gdbarch_remote_register_number_ftype *remote_register_number);
/* Fetch the target specific address used to represent a load module. */
extern int gdbarch_fetch_tls_load_module_address_p (struct gdbarch *gdbarch);
typedef CORE_ADDR (gdbarch_fetch_tls_load_module_address_ftype) (struct objfile *objfile);
extern CORE_ADDR gdbarch_fetch_tls_load_module_address (struct gdbarch *gdbarch, struct objfile *objfile);
extern void set_gdbarch_fetch_tls_load_module_address (struct gdbarch *gdbarch, gdbarch_fetch_tls_load_module_address_ftype *fetch_tls_load_module_address);
/* Return the thread-local address at OFFSET in the thread-local
storage for the thread PTID and the shared library or executable
file given by LM_ADDR. If that block of thread-local storage hasn't
been allocated yet, this function may throw an error. LM_ADDR may
be zero for statically linked multithreaded inferiors. */
extern int gdbarch_get_thread_local_address_p (struct gdbarch *gdbarch);
typedef CORE_ADDR (gdbarch_get_thread_local_address_ftype) (struct gdbarch *gdbarch, ptid_t ptid, CORE_ADDR lm_addr, CORE_ADDR offset);
extern CORE_ADDR gdbarch_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, CORE_ADDR lm_addr, CORE_ADDR offset);
extern void set_gdbarch_get_thread_local_address (struct gdbarch *gdbarch, gdbarch_get_thread_local_address_ftype *get_thread_local_address);
1999-08-31 03:14:27 +02:00
extern CORE_ADDR gdbarch_frame_args_skip (struct gdbarch *gdbarch);
extern void set_gdbarch_frame_args_skip (struct gdbarch *gdbarch, CORE_ADDR frame_args_skip);
1999-06-14 20:08:47 +02:00
typedef CORE_ADDR (gdbarch_unwind_pc_ftype) (struct gdbarch *gdbarch, struct frame_info *next_frame);
extern CORE_ADDR gdbarch_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame);
extern void set_gdbarch_unwind_pc (struct gdbarch *gdbarch, gdbarch_unwind_pc_ftype *unwind_pc);
typedef CORE_ADDR (gdbarch_unwind_sp_ftype) (struct gdbarch *gdbarch, struct frame_info *next_frame);
extern CORE_ADDR gdbarch_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame);
extern void set_gdbarch_unwind_sp (struct gdbarch *gdbarch, gdbarch_unwind_sp_ftype *unwind_sp);
/* DEPRECATED_FRAME_LOCALS_ADDRESS as been replaced by the per-frame
frame-base. Enable frame-base before frame-unwind. */
2003-06-09 Andrew Cagney <cagney@redhat.com> * gdbarch.sh (FRAME_NUM_ARGS): Change to function with predicate. * gdbarch.h, gdbarch.c: Re-generate. * arch-utils.h (frame_num_args_unknown): Delete both declarations. * arch-utils.c (frame_num_args_unknown): Delete function. * stack.c (print_args_stub): Use FRAME_NUM_ARGS_P. (frame_info): Use FRAME_NUM_ARGS_P. * arm-tdep.c (arm_frame_num_args): Delete function. (arm_gdbarch_init): Do not set frame_num_args. * config/pa/tm-hppa64.h (FRAME_NUM_ARGS): Delete. * hppa-tdep.c (hppa_frame_num_args): Delete function. (hppa_gdbarch_init): Do not set frame_num_args. * config/sparc/tm-sparc.h (FRAME_NUM_ARGS): Delete. * xstormy16-tdep.c (xstormy16_gdbarch_init): Do not set frame_num_args to default frame_num_args_unknown. * v850-tdep.c (v850_gdbarch_init): Ditto. * sparc-tdep.c (sparc_gdbarch_init): Ditto. * sh-tdep.c (sh_gdbarch_init): Ditto. * s390-tdep.c (s390_gdbarch_init): Ditto. * rs6000-tdep.c (rs6000_gdbarch_init): Ditto. * mn10300-tdep.c (mn10300_gdbarch_init): Ditto. * mips-tdep.c (mips_gdbarch_init): Ditto. * mcore-tdep.c (mcore_gdbarch_init): Ditto. * m68k-tdep.c (m68k_gdbarch_init): Ditto. * m68hc11-tdep.c (m68hc11_gdbarch_init): Ditto. * ia64-tdep.c (ia64_gdbarch_init): Ditto. * i386-tdep.c (i386_gdbarch_init): Ditto. * h8300-tdep.c (h8300_gdbarch_init): Ditto. * frv-tdep.c (frv_gdbarch_init): Ditto. * d10v-tdep.c (d10v_gdbarch_init): Ditto. * cris-tdep.c (cris_gdbarch_init): Ditto. * avr-tdep.c (avr_gdbarch_init): Ditto. * alpha-tdep.c (alpha_gdbarch_init): Ditto.
2003-06-09 19:35:59 +02:00
extern int gdbarch_frame_num_args_p (struct gdbarch *gdbarch);
1999-08-31 03:14:27 +02:00
typedef int (gdbarch_frame_num_args_ftype) (struct frame_info *frame);
extern int gdbarch_frame_num_args (struct gdbarch *gdbarch, struct frame_info *frame);
extern void set_gdbarch_frame_num_args (struct gdbarch *gdbarch, gdbarch_frame_num_args_ftype *frame_num_args);
1999-06-14 20:08:47 +02:00
extern int gdbarch_frame_align_p (struct gdbarch *gdbarch);
typedef CORE_ADDR (gdbarch_frame_align_ftype) (struct gdbarch *gdbarch, CORE_ADDR address);
extern CORE_ADDR gdbarch_frame_align (struct gdbarch *gdbarch, CORE_ADDR address);
extern void set_gdbarch_frame_align (struct gdbarch *gdbarch, gdbarch_frame_align_ftype *frame_align);
typedef int (gdbarch_stabs_argument_has_addr_ftype) (struct gdbarch *gdbarch, struct type *type);
extern int gdbarch_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type);
extern void set_gdbarch_stabs_argument_has_addr (struct gdbarch *gdbarch, gdbarch_stabs_argument_has_addr_ftype *stabs_argument_has_addr);
extern int gdbarch_frame_red_zone_size (struct gdbarch *gdbarch);
extern void set_gdbarch_frame_red_zone_size (struct gdbarch *gdbarch, int frame_red_zone_size);
typedef CORE_ADDR (gdbarch_convert_from_func_ptr_addr_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ);
extern CORE_ADDR gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ);
extern void set_gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr);
2001-06-16 00:10:21 +02:00
/* On some machines there are bits in addresses which are not really
part of the address, but are used by the kernel, the hardware, etc.
for special purposes. gdbarch_addr_bits_remove takes out any such bits so
2001-06-16 00:10:21 +02:00
we get a "real" address such as one would find in a symbol table.
This is used only for addresses of instructions, and even then I'm
not sure it's used in all contexts. It exists to deal with there
being a few stray bits in the PC which would mislead us, not as some
sort of generic thing to handle alignment or segmentation (it's
possible it should be in TARGET_READ_PC instead). */
typedef CORE_ADDR (gdbarch_addr_bits_remove_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
2001-06-16 00:10:21 +02:00
extern CORE_ADDR gdbarch_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr);
extern void set_gdbarch_addr_bits_remove (struct gdbarch *gdbarch, gdbarch_addr_bits_remove_ftype *addr_bits_remove);
Clear non-significant bits of address on memory access ARMv8 supports tagged address, that is, the top one byte in address is ignored. It is always enabled on aarch64-linux. See https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt The tag in the tagged address is modeled as non-significant bits in address, so this patch adds a new gdbarch method significant_addr_bit and clear the non-significant bits (the top byte in ARMv8) of the virtual address at the point before passing address to target cache layer. IOW, the address used in the target cache layer is already cleared. Before this patch, (gdb) x/x 0x0000000000411030 0x411030 <global>: 0x00000000 (gdb) x/x 0xf000000000411030 0xf000000000411030: Cannot access memory at address 0xf000000000411030 After this patch, (gdb) x/x 0x0000000000411030 0x411030 <global>: 0x00000000 (gdb) x/x 0xf000000000411030 0xf000000000411030: 0x00000000 Note that I used address_significant in paddress, but it causes a regression gdb.base/long_long.exp, because gdb clears the non-significant bits in address, but test still expects them. p/a val.oct^M $24 = 0x2ee53977053977^M (gdb) FAIL: gdb.base/long_long.exp: p/a val.oct so I defer the change there. gdb: 2017-12-08 Yao Qi <yao.qi@linaro.org> * aarch64-tdep.c (aarch64_gdbarch_init): Install gdbarch significant_addr_bit. * gdbarch.sh (significant_addr_bit): New. * gdbarch.c, gdbarch.h: Re-generated. * target.c (memory_xfer_partial): Call address_significant. * utils.c (address_significant): New function. * utils.h (address_significant): Declare. 2017-12-08 Yao Qi <yao.qi@linaro.org> gdb/testsuite: * gdb.arch/aarch64-tagged-pointer.c: New file. * gdb.arch/aarch64-tagged-pointer.exp: New file.
2017-12-08 18:27:03 +01:00
/* On some machines, not all bits of an address word are significant.
For example, on AArch64, the top bits of an address known as the "tag"
are ignored by the kernel, the hardware, etc. and can be regarded as
additional data associated with the address. */
extern int gdbarch_significant_addr_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_significant_addr_bit (struct gdbarch *gdbarch, int significant_addr_bit);
/* FIXME/cagney/2001-01-18: This should be split in two. A target method that
indicates if the target needs software single step. An ISA method to
implement it.
FIXME/cagney/2001-01-18: The logic is backwards. It should be asking if the
target can single step. If not, then implement single step using breakpoints.
gdbarch software_single_step returns VEC (CORE_ADDR) * This patch changes gdbarch method software_single_step to return a vector of addresses on which GDB should insert breakpoints, and don't insert breakpoints. Instead, the caller of gdbarch_software_single_step inserts breakpoints if the returned vector is not NULL. gdb: 2016-11-08 Yao Qi <yao.qi@linaro.org> * aarch64-tdep.c (aarch64_software_single_step): Return VEC (CORE_ADDR) *. Return NULL instead of 0. Don't call insert_single_step_breakpoint. * alpha-tdep.c (alpha_deal_with_atomic_sequence): Likewise. (alpha_software_single_step): Likewise. * alpha-tdep.h (alpha_software_single_step): Update declaration. * arm-linux-tdep.c (arm_linux_software_single_step): Return VEC (CORE_ADDR) *. Return NULL instead of 0. * arm-tdep.c (arm_software_single_step): Return NULL instead of 0. * arm-tdep.h (arm_software_single_step): Update declaration. * breakpoint.c (insert_single_step_breakpoints): New function. * breakpoint.h (insert_single_step_breakpoints): Declare. * cris-tdep.c (cris_software_single_step): Return VEC (CORE_ADDR) *. Don't call insert_single_step_breakpoint. * gdbarch.sh (software_single_step): Change it to return VEC (CORE_ADDR) *. * gdbarch.c, gdbarch.h: Regenerated. * infrun.c (maybe_software_singlestep): Adjust. * mips-tdep.c (mips_deal_with_atomic_sequence): Return VEC (CORE_ADDR) *. Don't call insert_single_step_breakpoint. (micromips_deal_with_atomic_sequence): Likewise. (deal_with_atomic_sequence): Likewise. (mips_software_single_step): Likewise. * mips-tdep.h (mips_software_single_step): Update declaration. * moxie-tdep.c (moxie_software_single_step): Likewise. * nios2-tdep.c (nios2_software_single_step): Likewise. * ppc-tdep.h (ppc_deal_with_atomic_sequence): Update declaration. * record-full.c (record_full_resume): Adjust. (record_full_wait_1): Likewise. * rs6000-aix-tdep.c (rs6000_software_single_step): Return VEC (CORE_ADDR) *. Don't call insert_single_step_breakpoint. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Return VEC (CORE_ADDR) *. Don't call insert_single_step_breakpoint. * s390-linux-tdep.c (s390_software_single_step): Likewise. * sparc-tdep.c (sparc_software_single_step): Likewise. * spu-tdep.c (spu_software_single_step): Likewise. * tic6x-tdep.c (tic6x_software_single_step): Likewise.
2016-11-08 15:28:32 +01:00
Return a vector of addresses on which the software single step
breakpoints should be inserted. NULL means software single step is
not used.
Multiple breakpoints may be inserted for some instructions such as
conditional branch. However, each implementation must always evaluate
the condition and only put the breakpoint at the branch destination if
the condition is true, so that we ensure forward progress when stepping
past a conditional branch to self. */
extern int gdbarch_software_single_step_p (struct gdbarch *gdbarch);
Change return type of gdbarch_software_single_step to vector<CORE_ADDR> This is a relatively straightforward patch that changes gdbarch_software_single_step so it returns an std::vector<CORE_ADDR> instead of a VEC (CORE_ADDR). gdb/ChangeLog: * gdbarch.sh (software_single_step): Change return type to std::vector<CORE_ADDR>. * gdbarch.c, gdbarch.h: Re-generate. * arch/arm-get-next-pcs.c (thumb_deal_with_atomic_sequence_raw): Adjust. (arm_deal_with_atomic_sequence_raw): Adjust. (thumb_get_next_pcs_raw): Adjust. (arm_get_next_pcs_raw): Adjust. (arm_get_next_pcs): Adjust. * arch/arm-get-next-pcs.h (arm_get_next_pcs): Adjust. * aarch64-tdep.c (aarch64_software_single_step): Adjust. * alpha-tdep.c (alpha_deal_with_atomic_sequence): Adjust. (alpha_software_single_step): Adjust. * alpha-tdep.h (alpha_software_single_step): Adjust. * arm-linux-tdep.c (arm_linux_software_single_step): Adjust. * arm-tdep.c (arm_software_single_step): Adjust. (arm_breakpoint_kind_from_current_state): Adjust. * arm-tdep.h (arm_software_single_step): Adjust. * breakpoint.c (insert_single_step_breakpoint): Adjust. * cris-tdep.c (cris_software_single_step): Adjust. * mips-tdep.c (mips_deal_with_atomic_sequence): Adjust. (micromips_deal_with_atomic_sequence): Adjust. (deal_with_atomic_sequence): Adjust. (mips_software_single_step): Adjust. * mips-tdep.h (mips_software_single_step): Adjust. * moxie-tdep.c (moxie_software_single_step): Adjust. * nios2-tdep.c (nios2_software_single_step): Adjust. * ppc-tdep.h (ppc_deal_with_atomic_sequence): Adjust. * rs6000-aix-tdep.c (rs6000_software_single_step): Adjust. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust. * s390-linux-tdep.c (s390_software_single_step): Adjust. * sparc-tdep.c (sparc_software_single_step): Adjust. * spu-tdep.c (spu_software_single_step): Adjust. * tic6x-tdep.c (tic6x_software_single_step): Adjust. gdb/gdbserver/ChangeLog: * linux-arm-low.c (arm_gdbserver_get_next_pcs): Adjust to software_single_step change of return type to std::vector<CORE_ADDR>. * linux-low.c (install_software_single_step_breakpoints): Likewise. * linux-low.h (install_software_single_step_breakpoints): Likewise.
2017-05-02 19:30:07 +02:00
typedef std::vector<CORE_ADDR> (gdbarch_software_single_step_ftype) (struct regcache *regcache);
extern std::vector<CORE_ADDR> gdbarch_software_single_step (struct gdbarch *gdbarch, struct regcache *regcache);
extern void set_gdbarch_software_single_step (struct gdbarch *gdbarch, gdbarch_software_single_step_ftype *software_single_step);
/* Return non-zero if the processor is executing a delay slot and a
further single-step is needed before the instruction finishes. */
extern int gdbarch_single_step_through_delay_p (struct gdbarch *gdbarch);
typedef int (gdbarch_single_step_through_delay_ftype) (struct gdbarch *gdbarch, struct frame_info *frame);
extern int gdbarch_single_step_through_delay (struct gdbarch *gdbarch, struct frame_info *frame);
extern void set_gdbarch_single_step_through_delay (struct gdbarch *gdbarch, gdbarch_single_step_through_delay_ftype *single_step_through_delay);
/* FIXME: cagney/2003-08-28: Need to find a better way of selecting the
disassembler. Perhaps objdump can handle it? */
2003-09-04 Andrew Cagney <cagney@redhat.com> * avr-tdep.c: Include "dis-asm.h". * cris-tdep.c: Include "dis-asm.h". (cris_delayed_get_disassembler): Use "struct disassemble_info" instead of corresponding typedef. * h8300-tdep.c: Include "dis-asm.h". * ia64-tdep.c: Include "dis-asm.h". * i386-tdep.c: Include "dis-asm.h". (i386_print_insn): Use "struct disassemble_info" instead of corresponding typedef. * m68k-tdep.c: Include "dis-asm.h". * mcore-tdep.c: Include "dis-asm.h". * mips-tdep.c: Include "dis-asm.h". (gdb_print_insn_mips): Make static, use "struct disassemble_info" instead of corresponding typedef. * ns32k-tdep.c: Include "dis-asm.h". * s390-tdep.c: Include "dis-asm.h". * sparc-tdep.c: Include "dis-asm.h". * vax-tdep.c: Include "dis-asm.h". * v850-tdep.c: Include "dis-asm.h". * mn10300-tdep.c: Include "dis-asm.h". * rs6000-tdep.c: Include "dis-asm.h". * xstormy16-tdep.c: Include "dis-asm.h". (_initialize_xstormy16_tdep): Delete "extern" declaration of print_insn_xstormy16. * Makefile.in (v850-tdep.o): Update dependencies. (vax-tdep.o, sparc-tdep.o, s390-tdep.o): Ditto. (ns32k-tdep.o, mips-tdep.o, mcore-tdep.o): Ditto. (m68k-tdep.o, ia64-tdep.o, i386-tdep.o): Ditto. (h8300-tdep.o, cris-tdep.o, avr-tdep.o): Ditto. (mn10300-tdep.o, xstormy16-tdep.o, disasm.o): Ditto. (gdbarch_h): Remove $(dis_asm_h). * disasm.c: Include "dis-asm.h". (dis_asm_read_memory): Use "struct disassemble_info" instead of corresponding typedef. (dis_asm_memory_error, dump_insns, do_assembly_only): Ditto. (gdb_disassemble_info, gdb_disassembly, gdb_print_insn): Ditto. * gdbarch.sh: Do not include "dis-asm.h". (struct disassemble_info): Declare opaque. (TARGET_PRINT_INSN): Update declaration. * gdbarch.h, gdbarch.c: Re-generate.
2003-09-09 06:41:32 +02:00
typedef int (gdbarch_print_insn_ftype) (bfd_vma vma, struct disassemble_info *info);
extern int gdbarch_print_insn (struct gdbarch *gdbarch, bfd_vma vma, struct disassemble_info *info);
extern void set_gdbarch_print_insn (struct gdbarch *gdbarch, gdbarch_print_insn_ftype *print_insn);
* gdbarch.sh (skip_trampoline_code): Add FRAME argument. * gdbarch.c, gdbarch.h: Regenerate. * arch-utils.c (generic_skip_trampoline_code): Add FRAME argument. * arch-utils.h (generic_skip_trampoline_code): Likewise. * infrun.c (handle_inferior_event): Pass current frame to gdbarch_skip_trampoline_code and skip_language_trampoline. * language.c (unk_lang_trampoline): Add FRAME argument. (skip_language_trampoline): Add FRAME argument. Pass it to skip_trampoline callback. * language.h: Add forward declaration of struct frame_info. (struct language_defn): Add FRAME argument to skip_trampoline. (skip_language_trampoline): Add FRAME argument. * cp-abi.c (cplus_skip_trampoline): Add FRAME argument. Pass it to skip_trampoline callback. * cp-abi.h: Add forward declaration of struct frame_info. (cplus_skip_trampoline): Add FRAME argument. (struct cp_abi_ops): Add FRAME argument to skip_trampoline callback. * gnu-v3-abi.c (gnuv3_skip_trampoline): Add FRAME argument. Pass it to gdbarch_skip_trampoline_code. * objc-lang.c (objc_skip_trampoline): Add FRAME argument. Pass it to gdbarch_skip_trampoline_code. * minsyms.c (find_solib_trampoline_target): Add FRAME argument. * symtab.h (find_solib_trampoline_target): Likewise. * obsd-tdep.c (obsd_skip_solib_resolver): Pass current frame to find_solib_trampoline_target. * arm-tdep.c (arm_skip_stub): Add FRAME argument. Read registers from FRAME instead of calling read_register. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code): Add FRAME argument. Read registers from FRAME instead of using read_register. * hppa-tdep.c (hppa_skip_trampoline_code): Likewise. * hppa-tdep.h (hppa_skip_trampoline_code): Add FRAME argument. * i386-cygwin-tdep.c (i386_cygwin_skip_trampoline_code): Add FRAME argument. * m32c-tdep.c (m32c_skip_trampoline_code): Add FRAME argument. * mips-tdep.c (mips_skip_trampoline_code): Add FRAME argument. Read registers from FRAME instead of using read_signed_register. * ppc-linux-tdep.c (ppc_linux_skip_trampoline_code): Add FRAME argument. (ppc64_standard_linkage_target): Likewise. Read registers from FRAME instead of using read_register. (ppc64_skip_trampoline_code): Add FRAME argument. Pass it to ppc64_standard_linkage_target. * rs6000-tdep.c (rs6000_skip_trampoline_code): Add FRAME argument. Pass it to find_solib_trampoline_target. Read registers from FRAME instead of using read_register. * xstormy16-tdep.c (xstormy16_skip_trampoline_code): Add FRAME argument.
2007-06-16 00:39:52 +02:00
typedef CORE_ADDR (gdbarch_skip_trampoline_code_ftype) (struct frame_info *frame, CORE_ADDR pc);
extern CORE_ADDR gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, struct frame_info *frame, CORE_ADDR pc);
extern void set_gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, gdbarch_skip_trampoline_code_ftype *skip_trampoline_code);
/* If in_solib_dynsym_resolve_code() returns true, and SKIP_SOLIB_RESOLVER
evaluates non-zero, this is the address where the debugger will place
a step-resume breakpoint to get us past the dynamic linker. */
typedef CORE_ADDR (gdbarch_skip_solib_resolver_ftype) (struct gdbarch *gdbarch, CORE_ADDR pc);
extern CORE_ADDR gdbarch_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc);
extern void set_gdbarch_skip_solib_resolver (struct gdbarch *gdbarch, gdbarch_skip_solib_resolver_ftype *skip_solib_resolver);
/* Some systems also have trampoline code for returning from shared libs. */
* blockframe.c (find_pc_partial_function_gnu_ifunc): Change type of "name" parameter to const char ** from char **. All callers updated. (find_pc_partial_function): Ditto. (cache_pc_function_name): Change type to const char * from char *. * symtab.h ((find_pc_partial_function_gnu_ifunc): Update. (find_pc_partial_function): Update. * alpha-tdep.h (struct gdbarch_tdep, member pc_in_sigtramp): Change type of "name" parameter to const char * from char *. All uses updated. * arch-utils.c (generic_in_solib_return_trampoline): Change type of "name" parameter to const char * from char *. * arch-utils.h (generic_in_solib_return_trampoline): Update. * frv-linux-tdep.c (frv_linux_pc_in_sigtramp): Change type of "name" parameter to const char * from char *. * gdbarch.sh (in_solib_return_trampoline): Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * hppa-hpux-tdep.c (hppa_hpux_in_solib_return_trampoline): Update. * rs6000-tdep.c (rs6000_in_solib_return_trampoline): Update. * m32r-linux-tdep.c (m32r_linux_pc_in_sigtramp): Change type of "name" parameter to const char * from char *. * skip.c (skip_function_pc): Ditto. * sparc-sol2-tdep.c (sparc_sol2_pc_in_sigtramp): Ditto. * sparc-tdep.h (sparc_sol2_pc_in_sigtramp): Update. * sparc64fbsd-tdep.c (sparc64fbsd_pc_in_sigtramp): Ditto. * sparc64nbsd-tdep.c (sparc64nbsd_pc_in_sigtramp): Ditto. * sparc64obsd-tdep.c (sparc64obsd_pc_in_sigtramp): Ditto. * sparcnbsd-tdep.c (sparc32nbsd_pc_in_sigtramp): Ditto. * sparcobsd-tdep.c (sparc32obsd_pc_in_sigtramp): Ditto. * nbsd-tdep.c (nbsd_pc_in_sigtramp): Similary for "func_name". * nbsd-tdep.h (nbsd_pc_in_sigtramp): Update.
2012-02-02 21:19:17 +01:00
typedef int (gdbarch_in_solib_return_trampoline_ftype) (struct gdbarch *gdbarch, CORE_ADDR pc, const char *name);
extern int gdbarch_in_solib_return_trampoline (struct gdbarch *gdbarch, CORE_ADDR pc, const char *name);
extern void set_gdbarch_in_solib_return_trampoline (struct gdbarch *gdbarch, gdbarch_in_solib_return_trampoline_ftype *in_solib_return_trampoline);
infrun: step through indirect branch thunks With version 7.3 GCC supports new options -mindirect-branch=<choice> -mfunction-return=<choice> The choices are: keep behaves as before thunk jumps through a thunk thunk-external jumps through an external thunk thunk-inline jumps through an inlined thunk For thunk and thunk-external, GDB would, on a call to the thunk, step into the thunk and then resume to its caller assuming that this is an undebuggable function. On a return thunk, GDB would stop inside the thunk. Make GDB step through such thunks instead. Before: Temporary breakpoint 1, main () at gdb.base/step-indirect-call-thunk.c:37 37 x = apply (inc, 41); (gdb) s apply (op=0x80483e6 <inc>, x=41) at gdb.base/step-indirect-call-thunk.c:29 29 return op (x); (gdb) 30 } After: Temporary breakpoint 1, main () at gdb.base/step-indirect-call-thunk.c:37 37 x = apply (inc, 41); (gdb) s apply (op=0x80483e6 <inc>, x=41) at gdb.base/step-indirect-call-thunk.c:29 29 return op (x); (gdb) inc (x=41) at gdb.base/step-indirect-call-thunk.c:23 23 return x + 1; This is independent of the step-mode. In order to step into the thunk, you would need to use stepi. When stepping over an indirect call thunk, GDB would first step through the thunk, then recognize that it stepped into a sub-routine and resume to the caller (of the thunk). Not sure whether this is worth optimizing. Thunk detection is implemented via gdbarch. I implemented the methods for IA. Other architectures may run into unexpected fails. The tests assume a fixed number of instruction steps to reach a thunk. This depends on the compiler as well as the architecture. They may need adjustments when we add support for more architectures. Or we can simply drop those tests that cover being able to step into thunks using instruction stepping. When using an older GCC, the tests will fail to build and will be reported as untested: Running .../gdb.base/step-indirect-call-thunk.exp ... gdb compile failed, \ gcc: error: unrecognized command line option '-mindirect-branch=thunk' gcc: error: unrecognized command line option '-mfunction-return=thunk' === gdb Summary === # of untested testcases 1 gdb/ * infrun.c (process_event_stop_test): Call gdbarch_in_indirect_branch_thunk. * gdbarch.sh (in_indirect_branch_thunk): New. * gdbarch.c: Regenerated. * gdbarch.h: Regenerated. * x86-tdep.h: New. * x86-tdep.c: New. * Makefile.in (ALL_TARGET_OBS): Add x86-tdep.o. (HFILES_NO_SRCDIR): Add x86-tdep.h. (ALLDEPFILES): Add x86-tdep.c. * arch-utils.h (default_in_indirect_branch_thunk): New. * arch-utils.c (default_in_indirect_branch_thunk): New. * i386-tdep: Include x86-tdep.h. (i386_in_indirect_branch_thunk): New. (i386_elf_init_abi): Set in_indirect_branch_thunk gdbarch function. * amd64-tdep: Include x86-tdep.h. (amd64_in_indirect_branch_thunk): New. (amd64_init_abi): Set in_indirect_branch_thunk gdbarch function. testsuite/ * gdb.base/step-indirect-call-thunk.exp: New. * gdb.base/step-indirect-call-thunk.c: New. * gdb.reverse/step-indirect-call-thunk.exp: New. * gdb.reverse/step-indirect-call-thunk.c: New.
2018-02-14 14:30:57 +01:00
/* Return true if PC lies inside an indirect branch thunk. */
typedef bool (gdbarch_in_indirect_branch_thunk_ftype) (struct gdbarch *gdbarch, CORE_ADDR pc);
extern bool gdbarch_in_indirect_branch_thunk (struct gdbarch *gdbarch, CORE_ADDR pc);
extern void set_gdbarch_in_indirect_branch_thunk (struct gdbarch *gdbarch, gdbarch_in_indirect_branch_thunk_ftype *in_indirect_branch_thunk);
/* A target might have problems with watchpoints as soon as the stack
frame of the current function has been destroyed. This mostly happens
as the first action in a function's epilogue. stack_frame_destroyed_p()
is defined to return a non-zero value if either the given addr is one
instruction after the stack destroying instruction up to the trailing
return instruction or if we can figure out that the stack frame has
already been invalidated regardless of the value of addr. Targets
which don't suffer from that problem could just let this functionality
untouched. */
typedef int (gdbarch_stack_frame_destroyed_p_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
extern int gdbarch_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR addr);
extern void set_gdbarch_stack_frame_destroyed_p (struct gdbarch *gdbarch, gdbarch_stack_frame_destroyed_p_ftype *stack_frame_destroyed_p);
MIPS: Keep the ISA bit in compressed code addresses 1. Background information The MIPS architecture, as originally designed and implemented in mid-1980s has a uniform instruction word size that is 4 bytes, naturally aligned. As such all MIPS instructions are located at addresses that have their bits #1 and #0 set to zeroes, and any attempt to execute an instruction from an address that has any of the two bits set to one causes an address error exception. This may for example happen when a jump-register instruction is executed whose register value used as the jump target has any of these bits set. Then in mid 1990s LSI sought a way to improve code density for their TinyRISC family of MIPS cores and invented an alternatively encoded instruction set in a joint effort with MIPS Technologies (then a subsidiary of SGI). The new instruction set has been named the MIPS16 ASE (Application-Specific Extension) and uses a variable instruction word size, which is 2 bytes (as the name of the ASE suggests) for most, but there are a couple of exceptions that take 4 bytes, and then most of the 2-byte instructions can be treated with a 2-byte extension prefix to expand the range of the immediate operands used. As a result instructions are no longer 4-byte aligned, instead they are aligned to a multiple of 2. That left the bit #0 still unused for code references, be it for the standard MIPS (i.e. as originally invented) or for the MIPS16 instruction set, and based on that observation a clever trick was invented that on one hand allowed the processor to be seamlessly switched between the two instruction sets at any time at the run time while on the other avoided the introduction of any special control register to do that. So it is the bit #0 of the instruction address that was chosen as the selector and named the ISA bit. Any instruction executed at an even address is interpreted as a standard MIPS instruction (the address still has to have its bit #1 clear), any instruction executed at an odd address is interpreted as a MIPS16 instruction. To switch between modes ordinary jump instructions are used, such as used for function calls and returns, specifically the bit #0 of the source register used in jump-register instructions selects the execution (ISA) mode for the following piece of code to be interpreted in. Additionally new jump-immediate instructions were added that flipped the ISA bit to select the opposite mode upon execution. They were considered necessary to avoid the need to make register jumps in all cases as the original jump-immediate instructions provided no way to change the bit #0 at all. This was all important for cases where standard MIPS and MIPS16 code had to be mixed, either for compatibility with the existing binary code base or to access resources not reachable from MIPS16 code (the MIPS16 instruction set only provides access to general-purpose registers, and not for example floating-point unit registers or privileged coprocessor 0 registers) -- pieces of code in the opposite mode can be executed as ordinary subroutine calls. A similar approach has been more recently adopted for the MIPS16 replacement instruction set defined as the so called microMIPS ASE. This is another instruction set encoding introduced to the MIPS architecture. Just like the MIPS16 ASE, the microMIPS instruction set uses a variable-length encoding, where each instruction takes a multiple of 2 bytes. The ISA bit has been reused and for microMIPS-capable processors selects between the standard MIPS and the microMIPS mode instead. 2. Statement of the problem To put it shortly, MIPS16 and microMIPS code pointers used by GDB are different to these observed at the run time. This results in the same expressions being evaluated producing different results in GDB and in the program being debugged. Obviously it's the results obtained at the run time that are correct (they define how the program behaves) and therefore by definition the results obtained in GDB are incorrect. A bit longer description will record that obviously at the run time the ISA bit has to be set correctly (refer to background information above if unsure why so) or the program will not run as expected. This is recorded in all the executable file structures used at the run time: the dynamic symbol table (but not always the static one!), the GOT, and obviously in all the addresses embedded in code or data of the program itself, calculated by applying the appropriate relocations at the static link time. While a program is being processed by GDB, the ISA bit is stripped off from any code addresses, presumably to make them the same as the respective raw memory byte address used by the processor to access the instruction in the instruction fetch access cycle. This stripping is actually performed outside GDB proper, in BFD, specifically _bfd_mips_elf_symbol_processing (elfxx-mips.c, see the piece of code at the very bottom of that function, starting with an: "If this is an odd-valued function symbol, assume it's a MIPS16 or microMIPS one." comment). This function is also responsible for symbol table dumps made by `objdump' too, so you'll never see the ISA bit reported there by that tool, you need to use `readelf'. This is however unlike what is ever done at the run time, the ISA bit once present is never stripped off, for example a cast like this: (short *) main will not strip the ISA bit off and if the resulting pointer is intended to be used to access instructions as data, for example for software instruction decoding (like for fault recovery or emulation in a signal handler) or for self-modifying code then the bit still has to be stripped off by an explicit AND operation. This is probably best illustrated with a simple real program example. Let's consider the following simple program: $ cat foobar.c int __attribute__ ((mips16)) foo (void) { return 1; } int __attribute__ ((mips16)) bar (void) { return 2; } int __attribute__ ((nomips16)) foo32 (void) { return 3; } int (*foo32p) (void) = foo32; int (*foop) (void) = foo; int fooi = (int) foo; int main (void) { return foop (); } $ This is plain C with no odd tricks, except from the instruction mode attributes. They are not necessary to trigger this problem, I just put them here so that the program can be contained in a single source file and to make it obvious which function is MIPS16 code and which is not. Let's try it with Linux, so that everyone can repeat this experiment: $ mips-linux-gnu-gcc -mips16 -g -O2 -o foobar foobar.c $ Let's have a look at some interesting symbols: $ mips-linux-gnu-readelf -s foobar | egrep 'table|foo|bar' Symbol table '.dynsym' contains 7 entries: Symbol table '.symtab' contains 95 entries: 55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c 66: 0040068c 4 FUNC GLOBAL DEFAULT [MIPS16] 12 bar 68: 00410848 4 OBJECT GLOBAL DEFAULT 21 foo32p 70: 00410844 4 OBJECT GLOBAL DEFAULT 21 foop 78: 00400684 8 FUNC GLOBAL DEFAULT 12 foo32 80: 00400680 4 FUNC GLOBAL DEFAULT [MIPS16] 12 foo 88: 00410840 4 OBJECT GLOBAL DEFAULT 21 fooi $ Hmm, no sight of the ISA bit, but notice how foo and bar (but not foo32!) have been marked as MIPS16 functions (ELF symbol structure's `st_other' field is used for that). So let's try to run and poke at this program with GDB. I'll be using a native system for simplicity (I'll be using ellipses here and there to remove unrelated clutter): $ ./foobar $ echo $? 1 $ So far, so good. $ gdb ./foobar [...] (gdb) break main Breakpoint 1 at 0x400490: file foobar.c, line 23. (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) Yay, it worked! OK, so let's poke at it: (gdb) print main $1 = {int (void)} 0x400490 <main> (gdb) print foo32 $2 = {int (void)} 0x400684 <foo32> (gdb) print foo32p $3 = (int (*)(void)) 0x400684 <foo32> (gdb) print bar $4 = {int (void)} 0x40068c <bar> (gdb) print foo $5 = {int (void)} 0x400680 <foo> (gdb) print foop $6 = (int (*)(void)) 0x400681 <foo> (gdb) A-ha! Here's the difference and finally the ISA bit! (gdb) print /x fooi $7 = 0x400681 (gdb) p/x $pc p/x $pc $8 = 0x400491 (gdb) And here as well... (gdb) advance foo foo () at foobar.c:4 4 } (gdb) disassemble Dump of assembler code for function foo: 0x00400680 <+0>: jr ra 0x00400682 <+2>: li v0,1 End of assembler dump. (gdb) finish Run till exit from #0 foo () at foobar.c:4 main () at foobar.c:24 24 } Value returned is $9 = 1 (gdb) continue Continuing. [Inferior 1 (process 14103) exited with code 01] (gdb) So let's be a bit inquisitive... (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) Actually we do not like to run foo here at all. Let's run bar instead! (gdb) set foop = bar (gdb) print foop $10 = (int (*)(void)) 0x40068c <bar> (gdb) Hmm, no ISA bit. Is it going to work? (gdb) advance bar bar () at foobar.c:9 9 } (gdb) p/x $pc $11 = 0x40068c (gdb) disassemble Dump of assembler code for function bar: => 0x0040068c <+0>: jr ra 0x0040068e <+2>: li v0,2 End of assembler dump. (gdb) finish Run till exit from #0 bar () at foobar.c:9 Program received signal SIGILL, Illegal instruction. bar () at foobar.c:9 9 } (gdb) Oops! (gdb) p/x $pc $12 = 0x40068c (gdb) We're still there! (gdb) continue Continuing. Program terminated with signal SIGILL, Illegal instruction. The program no longer exists. (gdb) So let's try something else: (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) set foop = foo (gdb) advance foo foo () at foobar.c:4 4 } (gdb) disassemble Dump of assembler code for function foo: => 0x00400680 <+0>: jr ra 0x00400682 <+2>: li v0,1 End of assembler dump. (gdb) finish Run till exit from #0 foo () at foobar.c:4 Program received signal SIGILL, Illegal instruction. foo () at foobar.c:4 4 } (gdb) continue Continuing. Program terminated with signal SIGILL, Illegal instruction. The program no longer exists. (gdb) The same problem! (gdb) run Starting program: /net/build2-lucid-cs/scratch/macro/mips-linux-fsf-gcc/isa-bit/foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) set foop = foo32 (gdb) advance foo32 foo32 () at foobar.c:14 14 } (gdb) disassemble Dump of assembler code for function foo32: => 0x00400684 <+0>: jr ra 0x00400688 <+4>: li v0,3 End of assembler dump. (gdb) finish Run till exit from #0 foo32 () at foobar.c:14 main () at foobar.c:24 24 } Value returned is $14 = 3 (gdb) continue Continuing. [Inferior 1 (process 14113) exited with code 03] (gdb) That did work though, so it's the ISA bit only! (gdb) quit Enough! That's the tip of the iceberg only though. So let's rebuild the executable with some dynamic symbols: $ mips-linux-gnu-gcc -mips16 -Wl,--export-dynamic -g -O2 -o foobar-dyn foobar.c $ mips-linux-gnu-readelf -s foobar-dyn | egrep 'table|foo|bar' Symbol table '.dynsym' contains 32 entries: 6: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar 8: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p 9: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop 15: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32 17: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo 25: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi Symbol table '.symtab' contains 95 entries: 55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c 69: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar 71: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p 72: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop 79: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32 81: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo 89: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi $ OK, now the ISA bit is there for a change, but the MIPS16 `st_other' attribute gone, hmm... What does `objdump' do then: $ mips-linux-gnu-objdump -Tt foobar-dyn | egrep 'SYMBOL|foo|bar' foobar-dyn: file format elf32-tradbigmips SYMBOL TABLE: 00000000 l df *ABS* 00000000 foobar.c 004009cc g F .text 00000004 0xf0 bar 00410b88 g O .data 00000004 foo32p 00410b84 g O .data 00000004 foop 004009c4 g F .text 00000008 foo32 004009c0 g F .text 00000004 0xf0 foo 00410b80 g O .data 00000004 fooi DYNAMIC SYMBOL TABLE: 004009cc g DF .text 00000004 Base 0xf0 bar 00410b88 g DO .data 00000004 Base foo32p 00410b84 g DO .data 00000004 Base foop 004009c4 g DF .text 00000008 Base foo32 004009c0 g DF .text 00000004 Base 0xf0 foo 00410b80 g DO .data 00000004 Base fooi $ Hmm, the attribute (0xf0, printed raw) is back, and the ISA bit gone again. Let's have a look at some DWARF-2 records GDB uses (I'll be stripping off a lot here for brevity) -- debug info: $ mips-linux-gnu-readelf -wi foobar Contents of the .debug_info section: [...] Compilation Unit @ offset 0x88: Length: 0xbb (32-bit) Version: 4 Abbrev Offset: 62 Pointer Size: 4 <0><93>: Abbrev Number: 1 (DW_TAG_compile_unit) <94> DW_AT_producer : (indirect string, offset: 0x19e): GNU C 4.8.0 20120513 (experimental) -meb -mips16 -march=mips32r2 -mhard-float -mllsc -mplt -mno-synci -mno-shared -mabi=32 -g -O2 <98> DW_AT_language : 1 (ANSI C) <99> DW_AT_name : (indirect string, offset: 0x190): foobar.c <9d> DW_AT_comp_dir : (indirect string, offset: 0x225): [...] <a1> DW_AT_ranges : 0x0 <a5> DW_AT_low_pc : 0x0 <a9> DW_AT_stmt_list : 0x27 <1><ad>: Abbrev Number: 2 (DW_TAG_subprogram) <ae> DW_AT_external : 1 <ae> DW_AT_name : foo <b2> DW_AT_decl_file : 1 <b3> DW_AT_decl_line : 1 <b4> DW_AT_prototyped : 1 <b4> DW_AT_type : <0xc2> <b8> DW_AT_low_pc : 0x400680 <bc> DW_AT_high_pc : 0x400684 <c0> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <c2> DW_AT_GNU_all_call_sites: 1 <1><c2>: Abbrev Number: 3 (DW_TAG_base_type) <c3> DW_AT_byte_size : 4 <c4> DW_AT_encoding : 5 (signed) <c5> DW_AT_name : int <1><c9>: Abbrev Number: 4 (DW_TAG_subprogram) <ca> DW_AT_external : 1 <ca> DW_AT_name : (indirect string, offset: 0x18a): foo32 <ce> DW_AT_decl_file : 1 <cf> DW_AT_decl_line : 11 <d0> DW_AT_prototyped : 1 <d0> DW_AT_type : <0xc2> <d4> DW_AT_low_pc : 0x400684 <d8> DW_AT_high_pc : 0x40068c <dc> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <de> DW_AT_GNU_all_call_sites: 1 <1><de>: Abbrev Number: 2 (DW_TAG_subprogram) <df> DW_AT_external : 1 <df> DW_AT_name : bar <e3> DW_AT_decl_file : 1 <e4> DW_AT_decl_line : 6 <e5> DW_AT_prototyped : 1 <e5> DW_AT_type : <0xc2> <e9> DW_AT_low_pc : 0x40068c <ed> DW_AT_high_pc : 0x400690 <f1> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <f3> DW_AT_GNU_all_call_sites: 1 <1><f3>: Abbrev Number: 5 (DW_TAG_subprogram) <f4> DW_AT_external : 1 <f4> DW_AT_name : (indirect string, offset: 0x199): main <f8> DW_AT_decl_file : 1 <f9> DW_AT_decl_line : 21 <fa> DW_AT_prototyped : 1 <fa> DW_AT_type : <0xc2> <fe> DW_AT_low_pc : 0x400490 <102> DW_AT_high_pc : 0x4004a4 <106> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <108> DW_AT_GNU_all_tail_call_sites: 1 [...] $ -- no sign of the ISA bit anywhere -- frame info: $ mips-linux-gnu-readelf -wf foobar [...] Contents of the .debug_frame section: 00000000 0000000c ffffffff CIE Version: 1 Augmentation: "" Code alignment factor: 1 Data alignment factor: -4 Return address column: 31 DW_CFA_def_cfa_register: r29 DW_CFA_nop 00000010 0000000c 00000000 FDE cie=00000000 pc=00400680..00400684 00000020 0000000c 00000000 FDE cie=00000000 pc=00400684..0040068c 00000030 0000000c 00000000 FDE cie=00000000 pc=0040068c..00400690 00000040 00000018 00000000 FDE cie=00000000 pc=00400490..004004a4 DW_CFA_advance_loc: 6 to 00400496 DW_CFA_def_cfa_offset: 32 DW_CFA_offset: r31 at cfa-4 DW_CFA_advance_loc: 6 to 0040049c DW_CFA_restore: r31 DW_CFA_def_cfa_offset: 0 DW_CFA_nop DW_CFA_nop DW_CFA_nop [...] $ -- no sign of the ISA bit anywhere -- range info (GDB doesn't use arange): $ mips-linux-gnu-readelf -wR foobar Contents of the .debug_ranges section: Offset Begin End 00000000 00400680 00400690 00000000 00400490 004004a4 00000000 <End of list> $ -- no sign of the ISA bit anywhere -- line info: $ mips-linux-gnu-readelf -wl foobar Raw dump of debug contents of section .debug_line: [...] Offset: 0x27 Length: 78 DWARF Version: 2 Prologue Length: 31 Minimum Instruction Length: 1 Initial value of 'is_stmt': 1 Line Base: -5 Line Range: 14 Opcode Base: 13 Opcodes: Opcode 1 has 0 args Opcode 2 has 1 args Opcode 3 has 1 args Opcode 4 has 1 args Opcode 5 has 1 args Opcode 6 has 0 args Opcode 7 has 0 args Opcode 8 has 0 args Opcode 9 has 1 args Opcode 10 has 0 args Opcode 11 has 0 args Opcode 12 has 1 args The Directory Table is empty. The File Name Table: Entry Dir Time Size Name 1 0 0 0 foobar.c Line Number Statements: Extended opcode 2: set Address to 0x400681 Special opcode 6: advance Address by 0 to 0x400681 and Line by 1 to 2 Special opcode 7: advance Address by 0 to 0x400681 and Line by 2 to 4 Special opcode 55: advance Address by 3 to 0x400684 and Line by 8 to 12 Special opcode 7: advance Address by 0 to 0x400684 and Line by 2 to 14 Advance Line by -7 to 7 Special opcode 131: advance Address by 9 to 0x40068d and Line by 0 to 7 Special opcode 7: advance Address by 0 to 0x40068d and Line by 2 to 9 Advance PC by 3 to 0x400690 Extended opcode 1: End of Sequence Extended opcode 2: set Address to 0x400491 Advance Line by 21 to 22 Copy Special opcode 6: advance Address by 0 to 0x400491 and Line by 1 to 23 Special opcode 60: advance Address by 4 to 0x400495 and Line by -1 to 22 Special opcode 34: advance Address by 2 to 0x400497 and Line by 1 to 23 Special opcode 62: advance Address by 4 to 0x40049b and Line by 1 to 24 Special opcode 32: advance Address by 2 to 0x40049d and Line by -1 to 23 Special opcode 6: advance Address by 0 to 0x40049d and Line by 1 to 24 Advance PC by 7 to 0x4004a4 Extended opcode 1: End of Sequence [...] -- a-ha, the ISA bit is there! However it's not always right for some reason, I don't have a small test case to show it, but here's an excerpt from MIPS16 libc, a prologue of a function: 00019630 <__libc_init_first>: 19630: e8a0 jrc ra 19632: 6500 nop 00019634 <_init>: 19634: f000 6a11 li v0,17 19638: f7d8 0b08 la v1,15e00 <_DYNAMIC+0x15c54> 1963c: f400 3240 sll v0,16 19640: e269 addu v0,v1 19642: 659a move gp,v0 19644: 64f6 save 48,ra,s0-s1 19646: 671c move s0,gp 19648: d204 sw v0,16(sp) 1964a: f352 984c lw v0,-27828(s0) 1964e: 6724 move s1,a0 and the corresponding DWARF-2 line info: Line Number Statements: Extended opcode 2: set Address to 0x19631 Advance Line by 44 to 45 Copy Special opcode 8: advance Address by 0 to 0x19631 and Line by 3 to 48 Special opcode 66: advance Address by 4 to 0x19635 and Line by 5 to 53 Advance PC by constant 17 to 0x19646 Special opcode 25: advance Address by 1 to 0x19647 and Line by 6 to 59 Advance Line by -6 to 53 Special opcode 33: advance Address by 2 to 0x19649 and Line by 0 to 53 Special opcode 39: advance Address by 2 to 0x1964b and Line by 6 to 59 Advance Line by -6 to 53 Special opcode 61: advance Address by 4 to 0x1964f and Line by 0 to 53 -- see that "Advance PC by constant 17" there? It clears the ISA bit, however code at 0x19646 is not standard MIPS code at all. For some reason the constant is always 17, I've never seen DW_LNS_const_add_pc used with any other value -- is that a binutils bug or what? 3. Solution: I think we should retain the value of the ISA bit in code references, that is effectively treat them as cookies as they indeed are (although trivially calculated) rather than raw memory byte addresses. In a perfect world both the static symbol table and the respective DWARF-2 records should be fixed to include the ISA bit in all the cases. I think however that this is infeasible. All the uses of `_bfd_mips_elf_symbol_processing' can not necessarily be tracked down. This function is used by `elf_slurp_symbol_table' that in turn is used by `bfd_canonicalize_symtab' and `bfd_canonicalize_dynamic_symtab', which are public interfaces. Similarly DWARF-2 records are used outside GDB, one notable if a bit questionable is the exception unwinder (libgcc/unwind-dw2.c) -- I have identified at least bits in `execute_cfa_program' and `uw_frame_state_for', both around the calls to `_Unwind_IsSignalFrame', that would need an update as they effectively flip the ISA bit freely; see also the comment about MASK_RETURN_ADDR in gcc/config/mips/mips.h. But there may be more places. Any change in how DWARF-2 records are produced would require an update there and would cause compatibility problems with libgcc.a binaries already distributed; given that this is a static library a complex change involving function renames would likely be required. I propose therefore to accept the existing inconsistencies and deal with them entirely within GDB. I have figured out that the ISA bit lost in various places can still be recovered as long as we have symbol information -- that'll have the `st_other' attribute correctly set to one of standard MIPS/MIPS16/microMIPS encoding. Here's the resulting change. It adds a couple of new `gdbarch' hooks, one to update symbol information with the ISA bit lost in `_bfd_mips_elf_symbol_processing', and two other ones to adjust DWARF-2 records as they're processed. The ISA bit is set in each address handled according to information retrieved from the symbol table for the symbol spanning the address if any; limits are adjusted based on the address they point to related to the respective base address. Additionally minimal symbol information has to be adjusted accordingly in its gdbarch hook. With these changes in place some complications with ISA bit juggling in the PC that never fully worked can be removed from the MIPS backend. Conversely, the generic dynamic linker event special breakpoint symbol handler has to be updated to call the minimal symbol gdbarch hook to record that the symbol is a MIPS16 or microMIPS address if applicable or the breakpoint will be set at the wrong address and either fail to work or cause SIGTRAPs (this is because the symbol is handled early on and bypasses regular symbol processing). 4. Results obtained The change fixes the example above -- to repeat only the crucial steps: (gdb) break main Breakpoint 1 at 0x400491: file foobar.c, line 23. (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) print foo $1 = {int (void)} 0x400681 <foo> (gdb) set foop = bar (gdb) advance bar bar () at foobar.c:9 9 } (gdb) disassemble Dump of assembler code for function bar: => 0x0040068d <+0>: jr ra 0x0040068f <+2>: li v0,2 End of assembler dump. (gdb) finish Run till exit from #0 bar () at foobar.c:9 main () at foobar.c:24 24 } Value returned is $2 = 2 (gdb) continue Continuing. [Inferior 1 (process 14128) exited with code 02] (gdb) -- excellent! The change removes about 90 failures per MIPS16 multilib in mips-sde-elf testing too, results for MIPS16 are now similar to that for standard MIPS; microMIPS results are a bit worse because of host-I/O problems in QEMU used instead of MIPSsim for microMIPS testing only: === gdb Summary === # of expected passes 14299 # of unexpected failures 187 # of expected failures 56 # of known failures 58 # of unresolved testcases 11 # of untested testcases 52 # of unsupported tests 174 MIPS16: === gdb Summary === # of expected passes 14298 # of unexpected failures 187 # of unexpected successes 2 # of expected failures 54 # of known failures 58 # of unresolved testcases 12 # of untested testcases 52 # of unsupported tests 174 microMIPS: === gdb Summary === # of expected passes 14149 # of unexpected failures 201 # of unexpected successes 2 # of expected failures 54 # of known failures 58 # of unresolved testcases 7 # of untested testcases 53 # of unsupported tests 175 2014-12-12 Maciej W. Rozycki <macro@codesourcery.com> Maciej W. Rozycki <macro@mips.com> Pedro Alves <pedro@codesourcery.com> gdb/ * gdbarch.sh (elf_make_msymbol_special): Change type to `F', remove `predefault' and `invalid_p' initializers. (make_symbol_special): New architecture method. (adjust_dwarf2_addr, adjust_dwarf2_line): Likewise. (objfile, symbol): New declarations. * arch-utils.h (default_elf_make_msymbol_special): Remove prototype. (default_make_symbol_special): New prototype. (default_adjust_dwarf2_addr): Likewise. (default_adjust_dwarf2_line): Likewise. * mips-tdep.h (mips_unmake_compact_addr): New prototype. * arch-utils.c (default_elf_make_msymbol_special): Remove function. (default_make_symbol_special): New function. (default_adjust_dwarf2_addr): Likewise. (default_adjust_dwarf2_line): Likewise. * dwarf2-frame.c (decode_frame_entry_1): Call `gdbarch_adjust_dwarf2_addr'. * dwarf2loc.c (dwarf2_find_location_expression): Likewise. * dwarf2read.c (create_addrmap_from_index): Likewise. (process_psymtab_comp_unit_reader): Likewise. (add_partial_symbol): Likewise. (add_partial_subprogram): Likewise. (process_full_comp_unit): Likewise. (read_file_scope): Likewise. (read_func_scope): Likewise. Call `gdbarch_make_symbol_special'. (read_lexical_block_scope): Call `gdbarch_adjust_dwarf2_addr'. (read_call_site_scope): Likewise. (dwarf2_ranges_read): Likewise. (dwarf2_record_block_ranges): Likewise. (read_attribute_value): Likewise. (dwarf_decode_lines_1): Call `gdbarch_adjust_dwarf2_line'. (new_symbol_full): Call `gdbarch_adjust_dwarf2_addr'. * elfread.c (elf_symtab_read): Don't call `gdbarch_elf_make_msymbol_special' if unset. * mips-linux-tdep.c (micromips_linux_sigframe_validate): Strip the ISA bit from the PC. * mips-tdep.c (mips_unmake_compact_addr): New function. (mips_elf_make_msymbol_special): Set the ISA bit in the symbol's address appropriately. (mips_make_symbol_special): New function. (mips_pc_is_mips): Set the ISA bit before symbol lookup. (mips_pc_is_mips16): Likewise. (mips_pc_is_micromips): Likewise. (mips_pc_isa): Likewise. (mips_adjust_dwarf2_addr): New function. (mips_adjust_dwarf2_line): Likewise. (mips_read_pc, mips_unwind_pc): Keep the ISA bit. (mips_addr_bits_remove): Likewise. (mips_skip_trampoline_code): Likewise. (mips_write_pc): Don't set the ISA bit. (mips_eabi_push_dummy_call): Likewise. (mips_o64_push_dummy_call): Likewise. (mips_gdbarch_init): Install `mips_make_symbol_special', `mips_adjust_dwarf2_addr' and `mips_adjust_dwarf2_line' gdbarch handlers. * solib.c (gdb_bfd_lookup_symbol_from_symtab): Get target-specific symbol address adjustments. * gdbarch.h: Regenerate. * gdbarch.c: Regenerate. 2014-12-12 Maciej W. Rozycki <macro@codesourcery.com> gdb/testsuite/ * gdb.base/func-ptrs.c: New file. * gdb.base/func-ptrs.exp: New file.
2014-12-12 14:31:53 +01:00
/* Process an ELF symbol in the minimal symbol table in a backend-specific
way. Normally this hook is supposed to do nothing, however if required,
then this hook can be used to apply tranformations to symbols that are
considered special in some way. For example the MIPS backend uses it
to interpret `st_other' information to mark compressed code symbols so
that they can be treated in the appropriate manner in the processing of
the main symbol table and DWARF-2 records. */
extern int gdbarch_elf_make_msymbol_special_p (struct gdbarch *gdbarch);
typedef void (gdbarch_elf_make_msymbol_special_ftype) (asymbol *sym, struct minimal_symbol *msym);
extern void gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, asymbol *sym, struct minimal_symbol *msym);
extern void set_gdbarch_elf_make_msymbol_special (struct gdbarch *gdbarch, gdbarch_elf_make_msymbol_special_ftype *elf_make_msymbol_special);
typedef void (gdbarch_coff_make_msymbol_special_ftype) (int val, struct minimal_symbol *msym);
extern void gdbarch_coff_make_msymbol_special (struct gdbarch *gdbarch, int val, struct minimal_symbol *msym);
extern void set_gdbarch_coff_make_msymbol_special (struct gdbarch *gdbarch, gdbarch_coff_make_msymbol_special_ftype *coff_make_msymbol_special);
MIPS: Keep the ISA bit in compressed code addresses 1. Background information The MIPS architecture, as originally designed and implemented in mid-1980s has a uniform instruction word size that is 4 bytes, naturally aligned. As such all MIPS instructions are located at addresses that have their bits #1 and #0 set to zeroes, and any attempt to execute an instruction from an address that has any of the two bits set to one causes an address error exception. This may for example happen when a jump-register instruction is executed whose register value used as the jump target has any of these bits set. Then in mid 1990s LSI sought a way to improve code density for their TinyRISC family of MIPS cores and invented an alternatively encoded instruction set in a joint effort with MIPS Technologies (then a subsidiary of SGI). The new instruction set has been named the MIPS16 ASE (Application-Specific Extension) and uses a variable instruction word size, which is 2 bytes (as the name of the ASE suggests) for most, but there are a couple of exceptions that take 4 bytes, and then most of the 2-byte instructions can be treated with a 2-byte extension prefix to expand the range of the immediate operands used. As a result instructions are no longer 4-byte aligned, instead they are aligned to a multiple of 2. That left the bit #0 still unused for code references, be it for the standard MIPS (i.e. as originally invented) or for the MIPS16 instruction set, and based on that observation a clever trick was invented that on one hand allowed the processor to be seamlessly switched between the two instruction sets at any time at the run time while on the other avoided the introduction of any special control register to do that. So it is the bit #0 of the instruction address that was chosen as the selector and named the ISA bit. Any instruction executed at an even address is interpreted as a standard MIPS instruction (the address still has to have its bit #1 clear), any instruction executed at an odd address is interpreted as a MIPS16 instruction. To switch between modes ordinary jump instructions are used, such as used for function calls and returns, specifically the bit #0 of the source register used in jump-register instructions selects the execution (ISA) mode for the following piece of code to be interpreted in. Additionally new jump-immediate instructions were added that flipped the ISA bit to select the opposite mode upon execution. They were considered necessary to avoid the need to make register jumps in all cases as the original jump-immediate instructions provided no way to change the bit #0 at all. This was all important for cases where standard MIPS and MIPS16 code had to be mixed, either for compatibility with the existing binary code base or to access resources not reachable from MIPS16 code (the MIPS16 instruction set only provides access to general-purpose registers, and not for example floating-point unit registers or privileged coprocessor 0 registers) -- pieces of code in the opposite mode can be executed as ordinary subroutine calls. A similar approach has been more recently adopted for the MIPS16 replacement instruction set defined as the so called microMIPS ASE. This is another instruction set encoding introduced to the MIPS architecture. Just like the MIPS16 ASE, the microMIPS instruction set uses a variable-length encoding, where each instruction takes a multiple of 2 bytes. The ISA bit has been reused and for microMIPS-capable processors selects between the standard MIPS and the microMIPS mode instead. 2. Statement of the problem To put it shortly, MIPS16 and microMIPS code pointers used by GDB are different to these observed at the run time. This results in the same expressions being evaluated producing different results in GDB and in the program being debugged. Obviously it's the results obtained at the run time that are correct (they define how the program behaves) and therefore by definition the results obtained in GDB are incorrect. A bit longer description will record that obviously at the run time the ISA bit has to be set correctly (refer to background information above if unsure why so) or the program will not run as expected. This is recorded in all the executable file structures used at the run time: the dynamic symbol table (but not always the static one!), the GOT, and obviously in all the addresses embedded in code or data of the program itself, calculated by applying the appropriate relocations at the static link time. While a program is being processed by GDB, the ISA bit is stripped off from any code addresses, presumably to make them the same as the respective raw memory byte address used by the processor to access the instruction in the instruction fetch access cycle. This stripping is actually performed outside GDB proper, in BFD, specifically _bfd_mips_elf_symbol_processing (elfxx-mips.c, see the piece of code at the very bottom of that function, starting with an: "If this is an odd-valued function symbol, assume it's a MIPS16 or microMIPS one." comment). This function is also responsible for symbol table dumps made by `objdump' too, so you'll never see the ISA bit reported there by that tool, you need to use `readelf'. This is however unlike what is ever done at the run time, the ISA bit once present is never stripped off, for example a cast like this: (short *) main will not strip the ISA bit off and if the resulting pointer is intended to be used to access instructions as data, for example for software instruction decoding (like for fault recovery or emulation in a signal handler) or for self-modifying code then the bit still has to be stripped off by an explicit AND operation. This is probably best illustrated with a simple real program example. Let's consider the following simple program: $ cat foobar.c int __attribute__ ((mips16)) foo (void) { return 1; } int __attribute__ ((mips16)) bar (void) { return 2; } int __attribute__ ((nomips16)) foo32 (void) { return 3; } int (*foo32p) (void) = foo32; int (*foop) (void) = foo; int fooi = (int) foo; int main (void) { return foop (); } $ This is plain C with no odd tricks, except from the instruction mode attributes. They are not necessary to trigger this problem, I just put them here so that the program can be contained in a single source file and to make it obvious which function is MIPS16 code and which is not. Let's try it with Linux, so that everyone can repeat this experiment: $ mips-linux-gnu-gcc -mips16 -g -O2 -o foobar foobar.c $ Let's have a look at some interesting symbols: $ mips-linux-gnu-readelf -s foobar | egrep 'table|foo|bar' Symbol table '.dynsym' contains 7 entries: Symbol table '.symtab' contains 95 entries: 55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c 66: 0040068c 4 FUNC GLOBAL DEFAULT [MIPS16] 12 bar 68: 00410848 4 OBJECT GLOBAL DEFAULT 21 foo32p 70: 00410844 4 OBJECT GLOBAL DEFAULT 21 foop 78: 00400684 8 FUNC GLOBAL DEFAULT 12 foo32 80: 00400680 4 FUNC GLOBAL DEFAULT [MIPS16] 12 foo 88: 00410840 4 OBJECT GLOBAL DEFAULT 21 fooi $ Hmm, no sight of the ISA bit, but notice how foo and bar (but not foo32!) have been marked as MIPS16 functions (ELF symbol structure's `st_other' field is used for that). So let's try to run and poke at this program with GDB. I'll be using a native system for simplicity (I'll be using ellipses here and there to remove unrelated clutter): $ ./foobar $ echo $? 1 $ So far, so good. $ gdb ./foobar [...] (gdb) break main Breakpoint 1 at 0x400490: file foobar.c, line 23. (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) Yay, it worked! OK, so let's poke at it: (gdb) print main $1 = {int (void)} 0x400490 <main> (gdb) print foo32 $2 = {int (void)} 0x400684 <foo32> (gdb) print foo32p $3 = (int (*)(void)) 0x400684 <foo32> (gdb) print bar $4 = {int (void)} 0x40068c <bar> (gdb) print foo $5 = {int (void)} 0x400680 <foo> (gdb) print foop $6 = (int (*)(void)) 0x400681 <foo> (gdb) A-ha! Here's the difference and finally the ISA bit! (gdb) print /x fooi $7 = 0x400681 (gdb) p/x $pc p/x $pc $8 = 0x400491 (gdb) And here as well... (gdb) advance foo foo () at foobar.c:4 4 } (gdb) disassemble Dump of assembler code for function foo: 0x00400680 <+0>: jr ra 0x00400682 <+2>: li v0,1 End of assembler dump. (gdb) finish Run till exit from #0 foo () at foobar.c:4 main () at foobar.c:24 24 } Value returned is $9 = 1 (gdb) continue Continuing. [Inferior 1 (process 14103) exited with code 01] (gdb) So let's be a bit inquisitive... (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) Actually we do not like to run foo here at all. Let's run bar instead! (gdb) set foop = bar (gdb) print foop $10 = (int (*)(void)) 0x40068c <bar> (gdb) Hmm, no ISA bit. Is it going to work? (gdb) advance bar bar () at foobar.c:9 9 } (gdb) p/x $pc $11 = 0x40068c (gdb) disassemble Dump of assembler code for function bar: => 0x0040068c <+0>: jr ra 0x0040068e <+2>: li v0,2 End of assembler dump. (gdb) finish Run till exit from #0 bar () at foobar.c:9 Program received signal SIGILL, Illegal instruction. bar () at foobar.c:9 9 } (gdb) Oops! (gdb) p/x $pc $12 = 0x40068c (gdb) We're still there! (gdb) continue Continuing. Program terminated with signal SIGILL, Illegal instruction. The program no longer exists. (gdb) So let's try something else: (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) set foop = foo (gdb) advance foo foo () at foobar.c:4 4 } (gdb) disassemble Dump of assembler code for function foo: => 0x00400680 <+0>: jr ra 0x00400682 <+2>: li v0,1 End of assembler dump. (gdb) finish Run till exit from #0 foo () at foobar.c:4 Program received signal SIGILL, Illegal instruction. foo () at foobar.c:4 4 } (gdb) continue Continuing. Program terminated with signal SIGILL, Illegal instruction. The program no longer exists. (gdb) The same problem! (gdb) run Starting program: /net/build2-lucid-cs/scratch/macro/mips-linux-fsf-gcc/isa-bit/foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) set foop = foo32 (gdb) advance foo32 foo32 () at foobar.c:14 14 } (gdb) disassemble Dump of assembler code for function foo32: => 0x00400684 <+0>: jr ra 0x00400688 <+4>: li v0,3 End of assembler dump. (gdb) finish Run till exit from #0 foo32 () at foobar.c:14 main () at foobar.c:24 24 } Value returned is $14 = 3 (gdb) continue Continuing. [Inferior 1 (process 14113) exited with code 03] (gdb) That did work though, so it's the ISA bit only! (gdb) quit Enough! That's the tip of the iceberg only though. So let's rebuild the executable with some dynamic symbols: $ mips-linux-gnu-gcc -mips16 -Wl,--export-dynamic -g -O2 -o foobar-dyn foobar.c $ mips-linux-gnu-readelf -s foobar-dyn | egrep 'table|foo|bar' Symbol table '.dynsym' contains 32 entries: 6: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar 8: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p 9: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop 15: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32 17: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo 25: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi Symbol table '.symtab' contains 95 entries: 55: 00000000 0 FILE LOCAL DEFAULT ABS foobar.c 69: 004009cd 4 FUNC GLOBAL DEFAULT 12 bar 71: 00410b88 4 OBJECT GLOBAL DEFAULT 21 foo32p 72: 00410b84 4 OBJECT GLOBAL DEFAULT 21 foop 79: 004009c4 8 FUNC GLOBAL DEFAULT 12 foo32 81: 004009c1 4 FUNC GLOBAL DEFAULT 12 foo 89: 00410b80 4 OBJECT GLOBAL DEFAULT 21 fooi $ OK, now the ISA bit is there for a change, but the MIPS16 `st_other' attribute gone, hmm... What does `objdump' do then: $ mips-linux-gnu-objdump -Tt foobar-dyn | egrep 'SYMBOL|foo|bar' foobar-dyn: file format elf32-tradbigmips SYMBOL TABLE: 00000000 l df *ABS* 00000000 foobar.c 004009cc g F .text 00000004 0xf0 bar 00410b88 g O .data 00000004 foo32p 00410b84 g O .data 00000004 foop 004009c4 g F .text 00000008 foo32 004009c0 g F .text 00000004 0xf0 foo 00410b80 g O .data 00000004 fooi DYNAMIC SYMBOL TABLE: 004009cc g DF .text 00000004 Base 0xf0 bar 00410b88 g DO .data 00000004 Base foo32p 00410b84 g DO .data 00000004 Base foop 004009c4 g DF .text 00000008 Base foo32 004009c0 g DF .text 00000004 Base 0xf0 foo 00410b80 g DO .data 00000004 Base fooi $ Hmm, the attribute (0xf0, printed raw) is back, and the ISA bit gone again. Let's have a look at some DWARF-2 records GDB uses (I'll be stripping off a lot here for brevity) -- debug info: $ mips-linux-gnu-readelf -wi foobar Contents of the .debug_info section: [...] Compilation Unit @ offset 0x88: Length: 0xbb (32-bit) Version: 4 Abbrev Offset: 62 Pointer Size: 4 <0><93>: Abbrev Number: 1 (DW_TAG_compile_unit) <94> DW_AT_producer : (indirect string, offset: 0x19e): GNU C 4.8.0 20120513 (experimental) -meb -mips16 -march=mips32r2 -mhard-float -mllsc -mplt -mno-synci -mno-shared -mabi=32 -g -O2 <98> DW_AT_language : 1 (ANSI C) <99> DW_AT_name : (indirect string, offset: 0x190): foobar.c <9d> DW_AT_comp_dir : (indirect string, offset: 0x225): [...] <a1> DW_AT_ranges : 0x0 <a5> DW_AT_low_pc : 0x0 <a9> DW_AT_stmt_list : 0x27 <1><ad>: Abbrev Number: 2 (DW_TAG_subprogram) <ae> DW_AT_external : 1 <ae> DW_AT_name : foo <b2> DW_AT_decl_file : 1 <b3> DW_AT_decl_line : 1 <b4> DW_AT_prototyped : 1 <b4> DW_AT_type : <0xc2> <b8> DW_AT_low_pc : 0x400680 <bc> DW_AT_high_pc : 0x400684 <c0> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <c2> DW_AT_GNU_all_call_sites: 1 <1><c2>: Abbrev Number: 3 (DW_TAG_base_type) <c3> DW_AT_byte_size : 4 <c4> DW_AT_encoding : 5 (signed) <c5> DW_AT_name : int <1><c9>: Abbrev Number: 4 (DW_TAG_subprogram) <ca> DW_AT_external : 1 <ca> DW_AT_name : (indirect string, offset: 0x18a): foo32 <ce> DW_AT_decl_file : 1 <cf> DW_AT_decl_line : 11 <d0> DW_AT_prototyped : 1 <d0> DW_AT_type : <0xc2> <d4> DW_AT_low_pc : 0x400684 <d8> DW_AT_high_pc : 0x40068c <dc> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <de> DW_AT_GNU_all_call_sites: 1 <1><de>: Abbrev Number: 2 (DW_TAG_subprogram) <df> DW_AT_external : 1 <df> DW_AT_name : bar <e3> DW_AT_decl_file : 1 <e4> DW_AT_decl_line : 6 <e5> DW_AT_prototyped : 1 <e5> DW_AT_type : <0xc2> <e9> DW_AT_low_pc : 0x40068c <ed> DW_AT_high_pc : 0x400690 <f1> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <f3> DW_AT_GNU_all_call_sites: 1 <1><f3>: Abbrev Number: 5 (DW_TAG_subprogram) <f4> DW_AT_external : 1 <f4> DW_AT_name : (indirect string, offset: 0x199): main <f8> DW_AT_decl_file : 1 <f9> DW_AT_decl_line : 21 <fa> DW_AT_prototyped : 1 <fa> DW_AT_type : <0xc2> <fe> DW_AT_low_pc : 0x400490 <102> DW_AT_high_pc : 0x4004a4 <106> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <108> DW_AT_GNU_all_tail_call_sites: 1 [...] $ -- no sign of the ISA bit anywhere -- frame info: $ mips-linux-gnu-readelf -wf foobar [...] Contents of the .debug_frame section: 00000000 0000000c ffffffff CIE Version: 1 Augmentation: "" Code alignment factor: 1 Data alignment factor: -4 Return address column: 31 DW_CFA_def_cfa_register: r29 DW_CFA_nop 00000010 0000000c 00000000 FDE cie=00000000 pc=00400680..00400684 00000020 0000000c 00000000 FDE cie=00000000 pc=00400684..0040068c 00000030 0000000c 00000000 FDE cie=00000000 pc=0040068c..00400690 00000040 00000018 00000000 FDE cie=00000000 pc=00400490..004004a4 DW_CFA_advance_loc: 6 to 00400496 DW_CFA_def_cfa_offset: 32 DW_CFA_offset: r31 at cfa-4 DW_CFA_advance_loc: 6 to 0040049c DW_CFA_restore: r31 DW_CFA_def_cfa_offset: 0 DW_CFA_nop DW_CFA_nop DW_CFA_nop [...] $ -- no sign of the ISA bit anywhere -- range info (GDB doesn't use arange): $ mips-linux-gnu-readelf -wR foobar Contents of the .debug_ranges section: Offset Begin End 00000000 00400680 00400690 00000000 00400490 004004a4 00000000 <End of list> $ -- no sign of the ISA bit anywhere -- line info: $ mips-linux-gnu-readelf -wl foobar Raw dump of debug contents of section .debug_line: [...] Offset: 0x27 Length: 78 DWARF Version: 2 Prologue Length: 31 Minimum Instruction Length: 1 Initial value of 'is_stmt': 1 Line Base: -5 Line Range: 14 Opcode Base: 13 Opcodes: Opcode 1 has 0 args Opcode 2 has 1 args Opcode 3 has 1 args Opcode 4 has 1 args Opcode 5 has 1 args Opcode 6 has 0 args Opcode 7 has 0 args Opcode 8 has 0 args Opcode 9 has 1 args Opcode 10 has 0 args Opcode 11 has 0 args Opcode 12 has 1 args The Directory Table is empty. The File Name Table: Entry Dir Time Size Name 1 0 0 0 foobar.c Line Number Statements: Extended opcode 2: set Address to 0x400681 Special opcode 6: advance Address by 0 to 0x400681 and Line by 1 to 2 Special opcode 7: advance Address by 0 to 0x400681 and Line by 2 to 4 Special opcode 55: advance Address by 3 to 0x400684 and Line by 8 to 12 Special opcode 7: advance Address by 0 to 0x400684 and Line by 2 to 14 Advance Line by -7 to 7 Special opcode 131: advance Address by 9 to 0x40068d and Line by 0 to 7 Special opcode 7: advance Address by 0 to 0x40068d and Line by 2 to 9 Advance PC by 3 to 0x400690 Extended opcode 1: End of Sequence Extended opcode 2: set Address to 0x400491 Advance Line by 21 to 22 Copy Special opcode 6: advance Address by 0 to 0x400491 and Line by 1 to 23 Special opcode 60: advance Address by 4 to 0x400495 and Line by -1 to 22 Special opcode 34: advance Address by 2 to 0x400497 and Line by 1 to 23 Special opcode 62: advance Address by 4 to 0x40049b and Line by 1 to 24 Special opcode 32: advance Address by 2 to 0x40049d and Line by -1 to 23 Special opcode 6: advance Address by 0 to 0x40049d and Line by 1 to 24 Advance PC by 7 to 0x4004a4 Extended opcode 1: End of Sequence [...] -- a-ha, the ISA bit is there! However it's not always right for some reason, I don't have a small test case to show it, but here's an excerpt from MIPS16 libc, a prologue of a function: 00019630 <__libc_init_first>: 19630: e8a0 jrc ra 19632: 6500 nop 00019634 <_init>: 19634: f000 6a11 li v0,17 19638: f7d8 0b08 la v1,15e00 <_DYNAMIC+0x15c54> 1963c: f400 3240 sll v0,16 19640: e269 addu v0,v1 19642: 659a move gp,v0 19644: 64f6 save 48,ra,s0-s1 19646: 671c move s0,gp 19648: d204 sw v0,16(sp) 1964a: f352 984c lw v0,-27828(s0) 1964e: 6724 move s1,a0 and the corresponding DWARF-2 line info: Line Number Statements: Extended opcode 2: set Address to 0x19631 Advance Line by 44 to 45 Copy Special opcode 8: advance Address by 0 to 0x19631 and Line by 3 to 48 Special opcode 66: advance Address by 4 to 0x19635 and Line by 5 to 53 Advance PC by constant 17 to 0x19646 Special opcode 25: advance Address by 1 to 0x19647 and Line by 6 to 59 Advance Line by -6 to 53 Special opcode 33: advance Address by 2 to 0x19649 and Line by 0 to 53 Special opcode 39: advance Address by 2 to 0x1964b and Line by 6 to 59 Advance Line by -6 to 53 Special opcode 61: advance Address by 4 to 0x1964f and Line by 0 to 53 -- see that "Advance PC by constant 17" there? It clears the ISA bit, however code at 0x19646 is not standard MIPS code at all. For some reason the constant is always 17, I've never seen DW_LNS_const_add_pc used with any other value -- is that a binutils bug or what? 3. Solution: I think we should retain the value of the ISA bit in code references, that is effectively treat them as cookies as they indeed are (although trivially calculated) rather than raw memory byte addresses. In a perfect world both the static symbol table and the respective DWARF-2 records should be fixed to include the ISA bit in all the cases. I think however that this is infeasible. All the uses of `_bfd_mips_elf_symbol_processing' can not necessarily be tracked down. This function is used by `elf_slurp_symbol_table' that in turn is used by `bfd_canonicalize_symtab' and `bfd_canonicalize_dynamic_symtab', which are public interfaces. Similarly DWARF-2 records are used outside GDB, one notable if a bit questionable is the exception unwinder (libgcc/unwind-dw2.c) -- I have identified at least bits in `execute_cfa_program' and `uw_frame_state_for', both around the calls to `_Unwind_IsSignalFrame', that would need an update as they effectively flip the ISA bit freely; see also the comment about MASK_RETURN_ADDR in gcc/config/mips/mips.h. But there may be more places. Any change in how DWARF-2 records are produced would require an update there and would cause compatibility problems with libgcc.a binaries already distributed; given that this is a static library a complex change involving function renames would likely be required. I propose therefore to accept the existing inconsistencies and deal with them entirely within GDB. I have figured out that the ISA bit lost in various places can still be recovered as long as we have symbol information -- that'll have the `st_other' attribute correctly set to one of standard MIPS/MIPS16/microMIPS encoding. Here's the resulting change. It adds a couple of new `gdbarch' hooks, one to update symbol information with the ISA bit lost in `_bfd_mips_elf_symbol_processing', and two other ones to adjust DWARF-2 records as they're processed. The ISA bit is set in each address handled according to information retrieved from the symbol table for the symbol spanning the address if any; limits are adjusted based on the address they point to related to the respective base address. Additionally minimal symbol information has to be adjusted accordingly in its gdbarch hook. With these changes in place some complications with ISA bit juggling in the PC that never fully worked can be removed from the MIPS backend. Conversely, the generic dynamic linker event special breakpoint symbol handler has to be updated to call the minimal symbol gdbarch hook to record that the symbol is a MIPS16 or microMIPS address if applicable or the breakpoint will be set at the wrong address and either fail to work or cause SIGTRAPs (this is because the symbol is handled early on and bypasses regular symbol processing). 4. Results obtained The change fixes the example above -- to repeat only the crucial steps: (gdb) break main Breakpoint 1 at 0x400491: file foobar.c, line 23. (gdb) run Starting program: .../foobar Breakpoint 1, main () at foobar.c:23 23 return foop (); (gdb) print foo $1 = {int (void)} 0x400681 <foo> (gdb) set foop = bar (gdb) advance bar bar () at foobar.c:9 9 } (gdb) disassemble Dump of assembler code for function bar: => 0x0040068d <+0>: jr ra 0x0040068f <+2>: li v0,2 End of assembler dump. (gdb) finish Run till exit from #0 bar () at foobar.c:9 main () at foobar.c:24 24 } Value returned is $2 = 2 (gdb) continue Continuing. [Inferior 1 (process 14128) exited with code 02] (gdb) -- excellent! The change removes about 90 failures per MIPS16 multilib in mips-sde-elf testing too, results for MIPS16 are now similar to that for standard MIPS; microMIPS results are a bit worse because of host-I/O problems in QEMU used instead of MIPSsim for microMIPS testing only: === gdb Summary === # of expected passes 14299 # of unexpected failures 187 # of expected failures 56 # of known failures 58 # of unresolved testcases 11 # of untested testcases 52 # of unsupported tests 174 MIPS16: === gdb Summary === # of expected passes 14298 # of unexpected failures 187 # of unexpected successes 2 # of expected failures 54 # of known failures 58 # of unresolved testcases 12 # of untested testcases 52 # of unsupported tests 174 microMIPS: === gdb Summary === # of expected passes 14149 # of unexpected failures 201 # of unexpected successes 2 # of expected failures 54 # of known failures 58 # of unresolved testcases 7 # of untested testcases 53 # of unsupported tests 175 2014-12-12 Maciej W. Rozycki <macro@codesourcery.com> Maciej W. Rozycki <macro@mips.com> Pedro Alves <pedro@codesourcery.com> gdb/ * gdbarch.sh (elf_make_msymbol_special): Change type to `F', remove `predefault' and `invalid_p' initializers. (make_symbol_special): New architecture method. (adjust_dwarf2_addr, adjust_dwarf2_line): Likewise. (objfile, symbol): New declarations. * arch-utils.h (default_elf_make_msymbol_special): Remove prototype. (default_make_symbol_special): New prototype. (default_adjust_dwarf2_addr): Likewise. (default_adjust_dwarf2_line): Likewise. * mips-tdep.h (mips_unmake_compact_addr): New prototype. * arch-utils.c (default_elf_make_msymbol_special): Remove function. (default_make_symbol_special): New function. (default_adjust_dwarf2_addr): Likewise. (default_adjust_dwarf2_line): Likewise. * dwarf2-frame.c (decode_frame_entry_1): Call `gdbarch_adjust_dwarf2_addr'. * dwarf2loc.c (dwarf2_find_location_expression): Likewise. * dwarf2read.c (create_addrmap_from_index): Likewise. (process_psymtab_comp_unit_reader): Likewise. (add_partial_symbol): Likewise. (add_partial_subprogram): Likewise. (process_full_comp_unit): Likewise. (read_file_scope): Likewise. (read_func_scope): Likewise. Call `gdbarch_make_symbol_special'. (read_lexical_block_scope): Call `gdbarch_adjust_dwarf2_addr'. (read_call_site_scope): Likewise. (dwarf2_ranges_read): Likewise. (dwarf2_record_block_ranges): Likewise. (read_attribute_value): Likewise. (dwarf_decode_lines_1): Call `gdbarch_adjust_dwarf2_line'. (new_symbol_full): Call `gdbarch_adjust_dwarf2_addr'. * elfread.c (elf_symtab_read): Don't call `gdbarch_elf_make_msymbol_special' if unset. * mips-linux-tdep.c (micromips_linux_sigframe_validate): Strip the ISA bit from the PC. * mips-tdep.c (mips_unmake_compact_addr): New function. (mips_elf_make_msymbol_special): Set the ISA bit in the symbol's address appropriately. (mips_make_symbol_special): New function. (mips_pc_is_mips): Set the ISA bit before symbol lookup. (mips_pc_is_mips16): Likewise. (mips_pc_is_micromips): Likewise. (mips_pc_isa): Likewise. (mips_adjust_dwarf2_addr): New function. (mips_adjust_dwarf2_line): Likewise. (mips_read_pc, mips_unwind_pc): Keep the ISA bit. (mips_addr_bits_remove): Likewise. (mips_skip_trampoline_code): Likewise. (mips_write_pc): Don't set the ISA bit. (mips_eabi_push_dummy_call): Likewise. (mips_o64_push_dummy_call): Likewise. (mips_gdbarch_init): Install `mips_make_symbol_special', `mips_adjust_dwarf2_addr' and `mips_adjust_dwarf2_line' gdbarch handlers. * solib.c (gdb_bfd_lookup_symbol_from_symtab): Get target-specific symbol address adjustments. * gdbarch.h: Regenerate. * gdbarch.c: Regenerate. 2014-12-12 Maciej W. Rozycki <macro@codesourcery.com> gdb/testsuite/ * gdb.base/func-ptrs.c: New file. * gdb.base/func-ptrs.exp: New file.
2014-12-12 14:31:53 +01:00
/* Process a symbol in the main symbol table in a backend-specific way.
Normally this hook is supposed to do nothing, however if required,
then this hook can be used to apply tranformations to symbols that
are considered special in some way. This is currently used by the
MIPS backend to make sure compressed code symbols have the ISA bit
set. This in turn is needed for symbol values seen in GDB to match
the values used at the runtime by the program itself, for function
and label references. */
typedef void (gdbarch_make_symbol_special_ftype) (struct symbol *sym, struct objfile *objfile);
extern void gdbarch_make_symbol_special (struct gdbarch *gdbarch, struct symbol *sym, struct objfile *objfile);
extern void set_gdbarch_make_symbol_special (struct gdbarch *gdbarch, gdbarch_make_symbol_special_ftype *make_symbol_special);
/* Adjust the address retrieved from a DWARF-2 record other than a line
entry in a backend-specific way. Normally this hook is supposed to
return the address passed unchanged, however if that is incorrect for
any reason, then this hook can be used to fix the address up in the
required manner. This is currently used by the MIPS backend to make
sure addresses in FDE, range records, etc. referring to compressed
code have the ISA bit set, matching line information and the symbol
table. */
typedef CORE_ADDR (gdbarch_adjust_dwarf2_addr_ftype) (CORE_ADDR pc);
extern CORE_ADDR gdbarch_adjust_dwarf2_addr (struct gdbarch *gdbarch, CORE_ADDR pc);
extern void set_gdbarch_adjust_dwarf2_addr (struct gdbarch *gdbarch, gdbarch_adjust_dwarf2_addr_ftype *adjust_dwarf2_addr);
/* Adjust the address updated by a line entry in a backend-specific way.
Normally this hook is supposed to return the address passed unchanged,
however in the case of inconsistencies in these records, this hook can
be used to fix them up in the required manner. This is currently used
by the MIPS backend to make sure all line addresses in compressed code
are presented with the ISA bit set, which is not always the case. This
in turn ensures breakpoint addresses are correctly matched against the
stop PC. */
typedef CORE_ADDR (gdbarch_adjust_dwarf2_line_ftype) (CORE_ADDR addr, int rel);
extern CORE_ADDR gdbarch_adjust_dwarf2_line (struct gdbarch *gdbarch, CORE_ADDR addr, int rel);
extern void set_gdbarch_adjust_dwarf2_line (struct gdbarch *gdbarch, gdbarch_adjust_dwarf2_line_ftype *adjust_dwarf2_line);
extern int gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch);
extern void set_gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch, int cannot_step_breakpoint);
/* See comment in target.h about continuable, steppable and
non-steppable watchpoints. */
extern int gdbarch_have_nonsteppable_watchpoint (struct gdbarch *gdbarch);
extern void set_gdbarch_have_nonsteppable_watchpoint (struct gdbarch *gdbarch, int have_nonsteppable_watchpoint);
2002-10-16 22:50:22 +02:00
extern int gdbarch_address_class_type_flags_p (struct gdbarch *gdbarch);
typedef int (gdbarch_address_class_type_flags_ftype) (int byte_size, int dwarf2_addr_class);
extern int gdbarch_address_class_type_flags (struct gdbarch *gdbarch, int byte_size, int dwarf2_addr_class);
extern void set_gdbarch_address_class_type_flags (struct gdbarch *gdbarch, gdbarch_address_class_type_flags_ftype *address_class_type_flags);
extern int gdbarch_address_class_type_flags_to_name_p (struct gdbarch *gdbarch);
typedef const char * (gdbarch_address_class_type_flags_to_name_ftype) (struct gdbarch *gdbarch, int type_flags);
extern const char * gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags);
2002-10-16 22:50:22 +02:00
extern void set_gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name);
[gdbarch] New method "execute_dwarf_cfa_vendor_op" and migrate SPARC to it Recently a feature called "return address signing" has been added to GCC to prevent stack smash stack on AArch64. For details please refer: https://gcc.gnu.org/ml/gcc-patches/2017-01/msg00376.html GDB needs to be aware of this feature so it can restore the original return address which is critical for unwinding. On compiler side, whenever return address, i.e. LR register, is mangled or restored by hardware instruction, compiler is expected to generate a DW_CFA_AARCH64_negate_ra_state to toggle return address signing status. DW_CFA_AARCH64_negate_ra_state is using the same CFI number and therefore need to be multiplexed with DW_CFA_GNU_window_save which was designed for SPARC. A new gdbarch method "execute_dwarf_cfa_vendor_op" is introduced by this patch. It's parameters has been restricted to those only needed by SPARC and AArch64 for multiplexing DW_CFA_GNU_window_save which is a CFI operation takes none operand. Should any further DWARF CFI operation want to be multiplexed in the future, the parameter list can be extended. Below is the current function prototype. typedef int (gdbarch_execute_dwarf_cfa_vendor_op_ftype) (struct gdbarch *gdbarch, gdb_byte op, struct dwarf2_frame_state *fs); DW_CFA_GNU_window_save support for SPARC is migrated to this new gdbarch method by this patch. gdb/ * gdbarch.sh: New gdbarch method execute_dwarf_cfa_vendor_op. * gdbarch.c: Regenerated. * gdbarch.h: Regenerated. * dwarf2-frame.c (dwarf2_frame_state_alloc_regs): Made the visibility external. (execute_cfa_program): Call execute_dwarf_cfa_vendor_op for CFI between DW_CFA_lo_user and DW_CFA_high_user inclusive. (enum cfa_how_kind): Move to ... (struct dwarf2_frame_state_reg_info): Likewise. (struct dwarf2_frame_state): Likewise. * dwarf2-frame.h: ... here. (dwarf2_frame_state_alloc_regs): New declaration. * sparc-tdep.c (sparc_execute_dwarf_cfa_vendor_op): New function. (sparc32_gdbarch_init): Register execute_dwarf_cfa_vendor_op hook.
2017-04-26 15:05:03 +02:00
/* Execute vendor-specific DWARF Call Frame Instruction. OP is the instruction.
FS are passed from the generic execute_cfa_program function. */
typedef bool (gdbarch_execute_dwarf_cfa_vendor_op_ftype) (struct gdbarch *gdbarch, gdb_byte op, struct dwarf2_frame_state *fs);
extern bool gdbarch_execute_dwarf_cfa_vendor_op (struct gdbarch *gdbarch, gdb_byte op, struct dwarf2_frame_state *fs);
extern void set_gdbarch_execute_dwarf_cfa_vendor_op (struct gdbarch *gdbarch, gdbarch_execute_dwarf_cfa_vendor_op_ftype *execute_dwarf_cfa_vendor_op);
/* Return the appropriate type_flags for the supplied address class.
This function should return 1 if the address class was recognized and
type_flags was set, zero otherwise. */
2002-10-16 22:50:22 +02:00
extern int gdbarch_address_class_name_to_type_flags_p (struct gdbarch *gdbarch);
typedef int (gdbarch_address_class_name_to_type_flags_ftype) (struct gdbarch *gdbarch, const char *name, int *type_flags_ptr);
extern int gdbarch_address_class_name_to_type_flags (struct gdbarch *gdbarch, const char *name, int *type_flags_ptr);
2002-10-16 22:50:22 +02:00
extern void set_gdbarch_address_class_name_to_type_flags (struct gdbarch *gdbarch, gdbarch_address_class_name_to_type_flags_ftype *address_class_name_to_type_flags);
/* Is a register in a group */
typedef int (gdbarch_register_reggroup_p_ftype) (struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup);
extern int gdbarch_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup);
extern void set_gdbarch_register_reggroup_p (struct gdbarch *gdbarch, gdbarch_register_reggroup_p_ftype *register_reggroup_p);
/* Fetch the pointer to the ith function argument. */
extern int gdbarch_fetch_pointer_argument_p (struct gdbarch *gdbarch);
typedef CORE_ADDR (gdbarch_fetch_pointer_argument_ftype) (struct frame_info *frame, int argi, struct type *type);
extern CORE_ADDR gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, struct frame_info *frame, int argi, struct type *type);
extern void set_gdbarch_fetch_pointer_argument (struct gdbarch *gdbarch, gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument);
Replace 'core_regset_sections' by iterator method The core_regset_sections list in gdbarch (needed for multi-arch capable core file generation support) is replaced by an iterator method. Overall, this reduces the code a bit, and it allows for more flexibility. gdb/ChangeLog: * amd64-linux-tdep.c (amd64_linux_regset_sections): Remove. (amd64_linux_iterate_over_regset_sections): New. (amd64_linux_init_abi_common): Don't install the regset section list, but the new iterator in gdbarch. * arm-linux-tdep.c (arm_linux_fpa_regset_sections) (arm_linux_vfp_regset_sections): Remove. Move combined logic... (arm_linux_iterate_over_regset_sections): ...here. New function. (arm_linux_init_abi): Set iterator instead of section list. * corelow.c (get_core_registers_cb): New function, logic moved from... (get_core_registers): ...loop body here. Use new iterator method instead of walking through the regset section list. * gdbarch.sh: Remove 'core_regset_sections'. New method 'iterate_over_regset_sections'. New typedef 'iterate_over_regset_sections_cb'. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * i386-linux-tdep.c (i386_linux_regset_sections) (i386_linux_sse_regset_sections, i386_linux_avx_regset_sections): Remove. (i386_linux_iterate_over_regset_sections): New. (i386_linux_init_abi): Don't choose a regset section list, but install new iterator in gdbarch. * linux-tdep.c (struct linux_collect_regset_section_cb_data): New. (linux_collect_regset_section_cb): New function, logic moved from... (linux_collect_thread_registers): ...loop body here. Use iterator method instead of walking through list. (linux_make_corefile_notes_1): Check for presence of iterator method instead of regset section list. * ppc-linux-tdep.c (ppc_linux_vsx_regset_sections) (ppc_linux_vmx_regset_sections, ppc_linux_fp_regset_sections) (ppc64_linux_vsx_regset_sections, ppc64_linux_vmx_regset_sections) (ppc64_linux_fp_regset_sections): Remove. Move combined logic... (ppc_linux_iterate_over_regset_sections): ...here. New function. (ppc_linux_init_abi): Don't choose from above regset section lists, but install new iterator in gdbarch. * regset.h (struct core_regset_section): Remove. * s390-linux-tdep.c (struct gdbarch_tdep): Add new fields have_linux_v1, have_linux_v2, and have_tdb. (s390_linux32_regset_sections, s390_linux32v1_regset_sections) (s390_linux32v2_regset_sections, s390_linux64_regset_sections) (s390_linux64v1_regset_sections, s390_linux64v2_regset_sections) (s390x_linux64_regset_sections, s390x_linux64v1_regset_sections) (s390x_linux64v2_regset_sections): Remove. Move combined logic... (s390_iterate_over_regset_sections): ...here. New function. Use new tdep fields. (s390_gdbarch_init): Set new tdep fields. Don't choose from above regset section lists, but install new iterator.
2014-09-04 17:26:43 +02:00
/* Iterate over all supported register notes in a core file. For each
supported register note section, the iterator must call CB and pass
CB_DATA unchanged. If REGCACHE is not NULL, the iterator can limit
the supported register note sections based on the current register
values. Otherwise it should enumerate all supported register note
sections. */
extern int gdbarch_iterate_over_regset_sections_p (struct gdbarch *gdbarch);
Replace 'core_regset_sections' by iterator method The core_regset_sections list in gdbarch (needed for multi-arch capable core file generation support) is replaced by an iterator method. Overall, this reduces the code a bit, and it allows for more flexibility. gdb/ChangeLog: * amd64-linux-tdep.c (amd64_linux_regset_sections): Remove. (amd64_linux_iterate_over_regset_sections): New. (amd64_linux_init_abi_common): Don't install the regset section list, but the new iterator in gdbarch. * arm-linux-tdep.c (arm_linux_fpa_regset_sections) (arm_linux_vfp_regset_sections): Remove. Move combined logic... (arm_linux_iterate_over_regset_sections): ...here. New function. (arm_linux_init_abi): Set iterator instead of section list. * corelow.c (get_core_registers_cb): New function, logic moved from... (get_core_registers): ...loop body here. Use new iterator method instead of walking through the regset section list. * gdbarch.sh: Remove 'core_regset_sections'. New method 'iterate_over_regset_sections'. New typedef 'iterate_over_regset_sections_cb'. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * i386-linux-tdep.c (i386_linux_regset_sections) (i386_linux_sse_regset_sections, i386_linux_avx_regset_sections): Remove. (i386_linux_iterate_over_regset_sections): New. (i386_linux_init_abi): Don't choose a regset section list, but install new iterator in gdbarch. * linux-tdep.c (struct linux_collect_regset_section_cb_data): New. (linux_collect_regset_section_cb): New function, logic moved from... (linux_collect_thread_registers): ...loop body here. Use iterator method instead of walking through list. (linux_make_corefile_notes_1): Check for presence of iterator method instead of regset section list. * ppc-linux-tdep.c (ppc_linux_vsx_regset_sections) (ppc_linux_vmx_regset_sections, ppc_linux_fp_regset_sections) (ppc64_linux_vsx_regset_sections, ppc64_linux_vmx_regset_sections) (ppc64_linux_fp_regset_sections): Remove. Move combined logic... (ppc_linux_iterate_over_regset_sections): ...here. New function. (ppc_linux_init_abi): Don't choose from above regset section lists, but install new iterator in gdbarch. * regset.h (struct core_regset_section): Remove. * s390-linux-tdep.c (struct gdbarch_tdep): Add new fields have_linux_v1, have_linux_v2, and have_tdb. (s390_linux32_regset_sections, s390_linux32v1_regset_sections) (s390_linux32v2_regset_sections, s390_linux64_regset_sections) (s390_linux64v1_regset_sections, s390_linux64v2_regset_sections) (s390x_linux64_regset_sections, s390x_linux64v1_regset_sections) (s390x_linux64v2_regset_sections): Remove. Move combined logic... (s390_iterate_over_regset_sections): ...here. New function. Use new tdep fields. (s390_gdbarch_init): Set new tdep fields. Don't choose from above regset section lists, but install new iterator.
2014-09-04 17:26:43 +02:00
typedef void (gdbarch_iterate_over_regset_sections_ftype) (struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache);
extern void gdbarch_iterate_over_regset_sections (struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache);
extern void set_gdbarch_iterate_over_regset_sections (struct gdbarch *gdbarch, gdbarch_iterate_over_regset_sections_ftype *iterate_over_regset_sections);
* gdbarch.sh (make_corefile_notes): New architecture callback. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * gcore.c (write_gcore_file): Try gdbarch_make_corefile_notes before target_make_corefile_notes. If NULL is returned, the target does not support core file generation. * linux-nat.c: Include "linux-tdep.h". (find_signalled_thread, find_stop_signal): Remove. (linux_nat_do_thread_registers): Likewise. (struct linux_nat_corefile_thread_data): Likewise. (linux_nat_corefile_thread_callback): Likewise. (iterate_over_spus): Likewise. (struct linux_spu_corefile_data): Likewise. (linux_spu_corefile_callback): Likewise. (linux_spu_make_corefile_notes): Likewise. (linux_nat_collect_thread_registers): New function. (linux_nat_make_corefile_notes): Replace contents by call to linux_make_corefile_notes passing linux_nat_collect_thread_registers as native-only callback. * linux-tdep.h: Include "bfd.h". (struct regcache): Add forward declaration. (linux_collect_thread_registers_ftype): New typedef. (linux_make_corefile_notes): Add prototype. * linux-tdep.c: Include "gdbthread.h", "gdbcore.h", "regcache.h", "regset.h", and "elf-bfd.h". (find_signalled_thread, find_stop_signal): New functions. (linux_spu_make_corefile_notes): Likewise. (linux_collect_thread_registers): Likewise. (struct linux_corefile_thread_data): New data structure. (linux_corefile_thread_callback): New funcion. (linux_make_corefile_notes): Likewise. (linux_make_corefile_notes_1): Likewise. (linux_init_abi): Install it.
2012-01-20 10:56:56 +01:00
/* Create core file notes */
extern int gdbarch_make_corefile_notes_p (struct gdbarch *gdbarch);
typedef char * (gdbarch_make_corefile_notes_ftype) (struct gdbarch *gdbarch, bfd *obfd, int *note_size);
extern char * gdbarch_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size);
extern void set_gdbarch_make_corefile_notes (struct gdbarch *gdbarch, gdbarch_make_corefile_notes_ftype *make_corefile_notes);
/* Find core file memory regions */
extern int gdbarch_find_memory_regions_p (struct gdbarch *gdbarch);
typedef int (gdbarch_find_memory_regions_ftype) (struct gdbarch *gdbarch, find_memory_region_ftype func, void *data);
extern int gdbarch_find_memory_regions (struct gdbarch *gdbarch, find_memory_region_ftype func, void *data);
extern void set_gdbarch_find_memory_regions (struct gdbarch *gdbarch, gdbarch_find_memory_regions_ftype *find_memory_regions);
/* Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from
core file into buffer READBUF with length LEN. Return the number of bytes read
(zero indicates failure).
failed, otherwise, return the red length of READBUF. */
extern int gdbarch_core_xfer_shared_libraries_p (struct gdbarch *gdbarch);
typedef ULONGEST (gdbarch_core_xfer_shared_libraries_ftype) (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
extern ULONGEST gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
extern void set_gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries);
ppc-aix core file relocation. The current code attempts to provide relocation support when debugging core files via the rs6000_xfer_partial method of the rs6000-nat target_ops vector. However, this target_ops vector does not get pushed on the target stack at all when debugging core files, thus bypassing completely that part of the code. This patch fixes the problem by extending corelow's core_xfer_partial into handling the TARGET_OBJECT_LIBRARIES_AIX object. gdb/ChangeLog: * gdbarch.sh (core_xfer_shared_libraries_aix): New method. * gdbarch.h, gdbarch.c: Regenerate. * corelow.c (core_xfer_partial): Add TARGET_OBJECT_LIBRARIES_AIX handling. * rs6000-aix-tdep.h: New file. * Makefile.in (HFILES_NO_SRCDIR): Add rs6000-aix-tdep.h. * rs6000-aix-tdep.c: Include "rs6000-aix-tdep.h" and "xml-utils.h". (struct field_info, struct ld_info_desc): New types. (ld_info32_desc, ld_info64_desc): New static constants. (struct ld_info): New type. (rs6000_aix_extract_ld_info): New function. (rs6000_aix_shared_library_to_xml): Likewise. (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. (rs6000_aix_init_osabi): Add call to set_gdbarch_core_xfer_shared_libraries_aix. * rs6000-nat.c: Add "rs6000-aix-tdep.h" include. Remove "xml-utils.h" include. (LdInfo): Delete typedef. (ARCH64_DECL, LDI_FIELD, LDI_NEXT, LDI_FD, LDI_FILENAME): Delete macros. (rs6000_ptrace_ldinfo): Change return type to gdb_byte *. Adjust code accordingly. (rs6000_core_ldinfo): Delete, folded into rs6000_aix_core_xfer_shared_libraries_aix. (rs6000_xfer_shared_library): Delete. (rs6000_xfer_shared_libraries): Reimplement.
2013-05-15 14:26:14 +02:00
/* Read offset OFFSET of TARGET_OBJECT_LIBRARIES_AIX formatted shared
libraries list from core file into buffer READBUF with length LEN.
Return the number of bytes read (zero indicates failure). */
ppc-aix core file relocation. The current code attempts to provide relocation support when debugging core files via the rs6000_xfer_partial method of the rs6000-nat target_ops vector. However, this target_ops vector does not get pushed on the target stack at all when debugging core files, thus bypassing completely that part of the code. This patch fixes the problem by extending corelow's core_xfer_partial into handling the TARGET_OBJECT_LIBRARIES_AIX object. gdb/ChangeLog: * gdbarch.sh (core_xfer_shared_libraries_aix): New method. * gdbarch.h, gdbarch.c: Regenerate. * corelow.c (core_xfer_partial): Add TARGET_OBJECT_LIBRARIES_AIX handling. * rs6000-aix-tdep.h: New file. * Makefile.in (HFILES_NO_SRCDIR): Add rs6000-aix-tdep.h. * rs6000-aix-tdep.c: Include "rs6000-aix-tdep.h" and "xml-utils.h". (struct field_info, struct ld_info_desc): New types. (ld_info32_desc, ld_info64_desc): New static constants. (struct ld_info): New type. (rs6000_aix_extract_ld_info): New function. (rs6000_aix_shared_library_to_xml): Likewise. (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. (rs6000_aix_init_osabi): Add call to set_gdbarch_core_xfer_shared_libraries_aix. * rs6000-nat.c: Add "rs6000-aix-tdep.h" include. Remove "xml-utils.h" include. (LdInfo): Delete typedef. (ARCH64_DECL, LDI_FIELD, LDI_NEXT, LDI_FD, LDI_FILENAME): Delete macros. (rs6000_ptrace_ldinfo): Change return type to gdb_byte *. Adjust code accordingly. (rs6000_core_ldinfo): Delete, folded into rs6000_aix_core_xfer_shared_libraries_aix. (rs6000_xfer_shared_library): Delete. (rs6000_xfer_shared_libraries): Reimplement.
2013-05-15 14:26:14 +02:00
extern int gdbarch_core_xfer_shared_libraries_aix_p (struct gdbarch *gdbarch);
typedef ULONGEST (gdbarch_core_xfer_shared_libraries_aix_ftype) (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
extern ULONGEST gdbarch_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
ppc-aix core file relocation. The current code attempts to provide relocation support when debugging core files via the rs6000_xfer_partial method of the rs6000-nat target_ops vector. However, this target_ops vector does not get pushed on the target stack at all when debugging core files, thus bypassing completely that part of the code. This patch fixes the problem by extending corelow's core_xfer_partial into handling the TARGET_OBJECT_LIBRARIES_AIX object. gdb/ChangeLog: * gdbarch.sh (core_xfer_shared_libraries_aix): New method. * gdbarch.h, gdbarch.c: Regenerate. * corelow.c (core_xfer_partial): Add TARGET_OBJECT_LIBRARIES_AIX handling. * rs6000-aix-tdep.h: New file. * Makefile.in (HFILES_NO_SRCDIR): Add rs6000-aix-tdep.h. * rs6000-aix-tdep.c: Include "rs6000-aix-tdep.h" and "xml-utils.h". (struct field_info, struct ld_info_desc): New types. (ld_info32_desc, ld_info64_desc): New static constants. (struct ld_info): New type. (rs6000_aix_extract_ld_info): New function. (rs6000_aix_shared_library_to_xml): Likewise. (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. (rs6000_aix_init_osabi): Add call to set_gdbarch_core_xfer_shared_libraries_aix. * rs6000-nat.c: Add "rs6000-aix-tdep.h" include. Remove "xml-utils.h" include. (LdInfo): Delete typedef. (ARCH64_DECL, LDI_FIELD, LDI_NEXT, LDI_FD, LDI_FILENAME): Delete macros. (rs6000_ptrace_ldinfo): Change return type to gdb_byte *. Adjust code accordingly. (rs6000_core_ldinfo): Delete, folded into rs6000_aix_core_xfer_shared_libraries_aix. (rs6000_xfer_shared_library): Delete. (rs6000_xfer_shared_libraries): Reimplement.
2013-05-15 14:26:14 +02:00
extern void set_gdbarch_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch, gdbarch_core_xfer_shared_libraries_aix_ftype *core_xfer_shared_libraries_aix);
gdb/ Make core files the process_stratum. * corefile.c (core_target): New variable. (core_file_command): Remove variable t, use core_target. * corelow.c (core_ops): Make it static. (init_core_ops): Change to process_stratum. Initialize CORE_TARGET. * defs.h (make_cleanup_unpush_target): New prototype. * gdbarch.h: Regenerate. * gdbarch.sh (core_pid_to_str): Remove core_stratum from its comment. * gdbcore.h (core_target): New declaration. * inf-ptrace.c (inf_ptrace_create_inferior, inf_ptrace_attach): New variables ops_already_pushed and back_to. Use push_target, make_cleanup_unpush_target and discard_cleanups calls. * record.c (record_open): Replace core_stratum by a core_bfd check. * target.c (target_is_pushed): New function. (find_core_target): Remove. * target.h (enum strata) <core_stratum>: Remove. (target_is_pushed): New declaration. (find_core_target): Remove declaration. * tracepoint.c (init_tfile_ops) <to_stratum>: Remove comment. * utils.c (do_unpush_target, make_cleanup_unpush_target): New functions. gdb/doc/ Make core files the process_stratum. * gdb.texinfo (Active Targets): Remove core_stratum. Include record_stratum example. gdb/testsuite/ Make core files the process_stratum. * gdb.base/corefile.exp (run: load core again) (run: sanity check we see the core file, run: with core) (run: core file is cleared, attach: load core again) (attach: sanity check we see the core file, attach: with core) (attach: core file is cleared): New tests. * gdb.base/coremaker.c (main): New parameters. Implement "sleep" argv.
2010-07-19 19:51:25 +02:00
/* How the core target converts a PTID from a core file to a string. */
* corelow.c (get_core_registers): Adjust. (core_file_thread_alive): Rename to... (core_thread_alive): ... this. (core_pid_to_str): Try gdbarch_core_pid_to_str first. (init_core_ops): Adjust. (coreops_suppress_target): Delete. (_initialize_corelow): Unconditionally add core_ops. * procfs.c: Include "inf-child.h". (procfs_ops): Delete. (init_procfs_ops): Delete. Reimplement as... (procfs_target): ... this, inheriting from inf-child. (procfs_attach, procfs_detach, procfs_fetch_registers): Adjust. (procfs_prepare_to_store): Delete. (procfs_store_registers, procfs_resume): Adjust. (procfs_open): Delete. (procfs_suppress_run): Delete. (procfs_can_run): Delete. (procfs_mourn_inferior): Adjust. (procfs_init_inferior): Add target_ops parameter. Adjust. (procfs_create_inferior): Don't pass procfs_init_inferior to fork_inferior. Instead call it after fork_inferior returns. (procfs_find_new_threads): Adjust. (_initialize_procfs): Adjust to use procfs_target instead of init_procfs_ops. * sol-thread.c (orig_core_ops, sol_core_ops): Delete. (lwp_to_thread): Use target_thread_alive. (sol_thread_open): Delete. (sol_thread_attach): Delete. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers): Adjust to use find_target_beneath. (sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete. (sol_thread_xfer_partial): Adjust to use find_target_beneath. (sol_thread_files_info, sol_thread_kill_inferior): Delete. (check_for_thread_db): New. (sol_thread_notice_signals, sol_thread_create_inferior): Delete. (sol_thread_new_objfile): Call check_for_thread_db. (sol_thread_mourn_inferior): Adjust to use find_target_beneath. (sol_thread_can_run): Delete. (sol_thread_alive): Adjust to use find_target_beneath. (sol_thread_stop): Delete. (rw_common): Use target_write_memory or target_read_memory. (ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers. (ps_lsetregs, ps_lsetfpregs): Use target_store_registers. (solaris_pid_to_str): Remove check for libthread_db initialization failing. (sol_find_new_threads): Remove check for libthread_db initialization failing, or for an invalid inferior_ptid. Adjust to use find_target_beneath. (sol_core_open, sol_core_close, sol_core_detach, sol_core_files_info, sol_find_memory_regions, sol_make_note_section, ignore): Delete. (init_sol_thread_ops): Make it a thread_stratum target. Remove unneeded callback settings. (init_sol_core_ops): Delete. (_initialize_sol_thread): No longer call init_sol_core_ops, set procfs_suppress_run, or hack with core_ops. * target.h (struct target_ops): Add a target_ops * parameter to to_resume, to_fetch_registers, to_store_registers, to_thread_alive and to_find_new_threads. (target_fetch_registers, target_store_registers) (target_thread_alive, target_find_new_threads): Redeclare as function. * target.c (update_current_target): Do not inherit or de_fault to_resume, to_fetch_registers, to_store_registers, to_thread_alive, to_find_new_threads. (target_resume): Adjust. (target_thread_alive, target_find_new_threads): New. (debug_to_resume, debug_to_fetch_registers): Delete. (target_fetch_registers): New. (debug_to_store_registers): Delete. (target_store_registers): New. (debug_to_thread_alive, debug_to_find_new_threads): Delete. (setup_target_debug): Adjust. * gdbcore.h (core_ops): Delete declaration. * inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c, inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c, i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c, hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c, nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c, alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c, bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c, hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c, ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c, m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c, mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c, ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c, shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c, vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes. * gdbarch.sh (core_pid_to_str): New gdbarch callback. * gdbarch.h, gdbarch.c: Regenerate. * sol2-tdep.c: Include "inferior.h". (sol2_core_pid_to_str): New. * sol2-tdep.h (sol2_core_pid_to_str): Declare. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it. * i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
2009-02-23 01:03:50 +01:00
extern int gdbarch_core_pid_to_str_p (struct gdbarch *gdbarch);
Change pid_to_str to return std::string Currently the target pid_to_str method returns a const char *, so many implementations have a static buffer that they update. This patch changes these methods to return a std::string instead. I think this is cleaner and avoids possible gotchas when calling pid_to_str on different ptids in a single statement. (Though no such calls exist currently.) This also updates various helper functions, and the gdbarch pid_to_str methods. I also made a best effort to fix all the callers, but I can't build some of the *-nat.c files. Tested by the buildbot. gdb/ChangeLog 2019-03-13 Tom Tromey <tromey@adacore.com> * i386-gnu-nat.c (i386_gnu_nat_target::fetch_registers) (i386_gnu_nat_target::store_registers): Update. * target-debug.h (target_debug_print_std_string): New macro. * x86-linux-nat.c (x86_linux_nat_target::enable_btrace): Update. * windows-tdep.c (display_one_tib): Update. * tui/tui-stack.c (tui_make_status_line): Update. * top.c (print_inferior_quit_action): Update. * thread.c (thr_try_catch_cmd): Update. (add_thread_with_info): Update. (thread_target_id_str): Update. (thr_try_catch_cmd): Update. (thread_command): Update. (thread_find_command): Update. * record-btrace.c (record_btrace_target::info_record) (record_btrace_resume_thread, record_btrace_target::resume) (record_btrace_cancel_resume, record_btrace_step_thread) (record_btrace_target::wait, record_btrace_target::wait) (record_btrace_target::wait, record_btrace_target::stop): Update. * progspace.c (print_program_space): Update. * process-stratum-target.c (process_stratum_target::thread_address_space): Update. * linux-fork.c (linux_fork_mourn_inferior) (detach_checkpoint_command, info_checkpoints_command) (linux_fork_context): Update. (linux_fork_detach): Update. (class scoped_switch_fork_info): Update. (delete_checkpoint_command): Update. * infrun.c (follow_fork_inferior): Update. (follow_fork_inferior): Update. (proceed_after_vfork_done): Update. (handle_vfork_child_exec_or_exit): Update. (follow_exec): Update. (displaced_step_prepare_throw): Update. (displaced_step_restore): Update. (start_step_over): Update. (resume_1): Update. (clear_proceed_status_thread): Update. (proceed): Update. (print_target_wait_results): Update. (do_target_wait): Update. (context_switch): Update. (stop_all_threads): Update. (restart_threads): Update. (finish_step_over): Update. (handle_signal_stop): Update. (switch_back_to_stepped_thread): Update. (keep_going_pass_signal): Update. (print_exited_reason): Update. (normal_stop): Update. * inferior.c (inferior_pid_to_str): Change return type. (print_selected_inferior): Update. (add_inferior): Update. (detach_inferior): Update. * dummy-frame.c (fprint_dummy_frames): Update. * dcache.c (dcache_info_1): Update. * btrace.c (btrace_enable, btrace_disable, btrace_teardown) (btrace_fetch, btrace_clear): Update. * linux-tdep.c (linux_core_pid_to_str): Change return type. * i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Change return type. * fbsd-tdep.c (fbsd_core_pid_to_str): Change return type. * sol2-tdep.h (sol2_core_pid_to_str): Change return type. * sol2-tdep.c (sol2_core_pid_to_str): Change return type. * gdbarch.c, gdbarch.h: Rebuild. * gdbarch.sh (core_pid_to_str): Change return type. * windows-nat.c (struct windows_nat_target) <pid_to_str>: Change return type. (windows_nat_target::pid_to_str): Change return type. (windows_delete_thread): Update. (windows_nat_target::attach): Update. (windows_nat_target::files_info): Update. * target-delegates.c: Rebuild. * sol-thread.c (class sol_thread_target) <pid_to_str>: Change return type. (sol_thread_target::pid_to_str): Change return type. * remote.c (class remote_target) <pid_to_str>: Change return type. (remote_target::pid_to_str): Change return type. (extended_remote_target::attach, remote_target::remote_stop_ns) (remote_target::remote_notif_remove_queued_reply) (remote_target::push_stop_reply, remote_target::disable_btrace): Update. (extended_remote_target::attach): Update. * remote-sim.c (struct gdbsim_target) <pid_to_str>: Change return type. (gdbsim_target::pid_to_str): Change return type. * ravenscar-thread.c (struct ravenscar_thread_target) <pid_to_str>: Change return type. (ravenscar_thread_target::pid_to_str): Change return type. * procfs.c (class procfs_target) <pid_to_str>: Change return type. (procfs_target::pid_to_str): Change return type. (procfs_target::attach): Update. (procfs_target::detach): Update. (procfs_target::fetch_registers): Update. (procfs_target::store_registers): Update. (procfs_target::wait): Update. (procfs_target::files_info): Update. * obsd-nat.c (obsd_nat_target::pid_to_str): Change return type. * nto-procfs.c (struct nto_procfs_target) <pid_to_str>: Change return type. (nto_procfs_target::pid_to_str): Change return type. (nto_procfs_target::files_info, nto_procfs_target::attach): Update. * linux-thread-db.c (class thread_db_target) <pid_to_str>: Change return type. * linux-nat.c (linux_nat_target::pid_to_str): Change return type. (exit_lwp): Update. (attach_proc_task_lwp_callback, get_detach_signal) (detach_one_lwp, resume_lwp, linux_nat_target::resume) (linux_nat_target::resume, wait_lwp, stop_callback) (maybe_clear_ignore_sigint, stop_wait_callback, status_callback) (save_stop_reason, select_event_lwp, linux_nat_filter_event) (linux_nat_wait_1, resume_stopped_resumed_lwps) (linux_nat_target::wait, linux_nat_stop_lwp): Update. * inf-ptrace.c (inf_ptrace_target::pid_to_str): Change return type. (inf_ptrace_target::attach): Update. (inf_ptrace_target::files_info): Update. * go32-nat.c (struct go32_nat_target) <pid_to_str>: Change return type. (go32_nat_target::pid_to_str): Change return type. * gnu-nat.c (gnu_nat_target::pid_to_str): Change return type. (gnu_nat_target::wait): Update. (gnu_nat_target::wait): Update. (gnu_nat_target::resume): Update. * fbsd-nat.c (fbsd_nat_target::pid_to_str): Change return type. (fbsd_nat_target::wait): Update. * darwin-nat.c (darwin_nat_target::pid_to_str): Change return type. (darwin_nat_target::attach): Update. * corelow.c (class core_target) <pid_to_str>: Change return type. (core_target::pid_to_str): Change return type. * target.c (normal_pid_to_str): Change return type. (default_pid_to_str): Likewise. (target_pid_to_str): Change return type. (target_translate_tls_address): Update. (target_announce_detach): Update. * bsd-uthread.c (struct bsd_uthread_target) <pid_to_str>: Change return type. (bsd_uthread_target::pid_to_str): Change return type. * bsd-kvm.c (class bsd_kvm_target) <pid_to_str>: Change return type. (bsd_kvm_target::pid_to_str): Change return type. * aix-thread.c (class aix_thread_target) <pid_to_str>: Change return type. (aix_thread_target::pid_to_str): Change return type. * target.h (struct target_ops) <pid_to_str>: Change return type. (target_pid_to_str, normal_pid_to_str): Likewise. * obsd-nat.h (class obsd_nat_target) <pid_to_str>: Change return type. * linux-nat.h (class linux_nat_target) <pid_to_str>: Change return type. * inf-ptrace.h (struct inf_ptrace_target) <pid_to_str>: Change return type. * gnu-nat.h (struct gnu_nat_target) <pid_to_str>: Change return type. * fbsd-nat.h (class fbsd_nat_target) <pid_to_str>: Change return type. * darwin-nat.h (class darwin_nat_target) <pid_to_str>: Change return type.
2019-02-28 17:09:55 +01:00
typedef std::string (gdbarch_core_pid_to_str_ftype) (struct gdbarch *gdbarch, ptid_t ptid);
extern std::string gdbarch_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid);
* corelow.c (get_core_registers): Adjust. (core_file_thread_alive): Rename to... (core_thread_alive): ... this. (core_pid_to_str): Try gdbarch_core_pid_to_str first. (init_core_ops): Adjust. (coreops_suppress_target): Delete. (_initialize_corelow): Unconditionally add core_ops. * procfs.c: Include "inf-child.h". (procfs_ops): Delete. (init_procfs_ops): Delete. Reimplement as... (procfs_target): ... this, inheriting from inf-child. (procfs_attach, procfs_detach, procfs_fetch_registers): Adjust. (procfs_prepare_to_store): Delete. (procfs_store_registers, procfs_resume): Adjust. (procfs_open): Delete. (procfs_suppress_run): Delete. (procfs_can_run): Delete. (procfs_mourn_inferior): Adjust. (procfs_init_inferior): Add target_ops parameter. Adjust. (procfs_create_inferior): Don't pass procfs_init_inferior to fork_inferior. Instead call it after fork_inferior returns. (procfs_find_new_threads): Adjust. (_initialize_procfs): Adjust to use procfs_target instead of init_procfs_ops. * sol-thread.c (orig_core_ops, sol_core_ops): Delete. (lwp_to_thread): Use target_thread_alive. (sol_thread_open): Delete. (sol_thread_attach): Delete. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers): Adjust to use find_target_beneath. (sol_thread_prepare_to_store, sol_thread_xfer_memory): Delete. (sol_thread_xfer_partial): Adjust to use find_target_beneath. (sol_thread_files_info, sol_thread_kill_inferior): Delete. (check_for_thread_db): New. (sol_thread_notice_signals, sol_thread_create_inferior): Delete. (sol_thread_new_objfile): Call check_for_thread_db. (sol_thread_mourn_inferior): Adjust to use find_target_beneath. (sol_thread_can_run): Delete. (sol_thread_alive): Adjust to use find_target_beneath. (sol_thread_stop): Delete. (rw_common): Use target_write_memory or target_read_memory. (ps_lgetregs, ps_lgetfpregs): Use target_fetch_registers. (ps_lsetregs, ps_lsetfpregs): Use target_store_registers. (solaris_pid_to_str): Remove check for libthread_db initialization failing. (sol_find_new_threads): Remove check for libthread_db initialization failing, or for an invalid inferior_ptid. Adjust to use find_target_beneath. (sol_core_open, sol_core_close, sol_core_detach, sol_core_files_info, sol_find_memory_regions, sol_make_note_section, ignore): Delete. (init_sol_thread_ops): Make it a thread_stratum target. Remove unneeded callback settings. (init_sol_core_ops): Delete. (_initialize_sol_thread): No longer call init_sol_core_ops, set procfs_suppress_run, or hack with core_ops. * target.h (struct target_ops): Add a target_ops * parameter to to_resume, to_fetch_registers, to_store_registers, to_thread_alive and to_find_new_threads. (target_fetch_registers, target_store_registers) (target_thread_alive, target_find_new_threads): Redeclare as function. * target.c (update_current_target): Do not inherit or de_fault to_resume, to_fetch_registers, to_store_registers, to_thread_alive, to_find_new_threads. (target_resume): Adjust. (target_thread_alive, target_find_new_threads): New. (debug_to_resume, debug_to_fetch_registers): Delete. (target_fetch_registers): New. (debug_to_store_registers): Delete. (target_store_registers): New. (debug_to_thread_alive, debug_to_find_new_threads): Delete. (setup_target_debug): Adjust. * gdbcore.h (core_ops): Delete declaration. * inf-ptrace.c, linux-nat.c, remote.c, amd64-linux-nat.c, inf-child.c, linux-thread-db.c, bsd-uthread.c, inf-ttrace.c, i386-sol2-tdep.c, darwin-nat.c, gnu-nat.c, go32-nat.c, hpux-thread.c, i386-linux-nat.c, i386fbsd-nat.c, monitor.c, nto-procfs.c, remote-m32r-sdi.c, remote-mips.c, windows-nat.c, alphabsd-nat.c, amd64bsd-nat.c, arm-linux-nat.c, armnbsd-nat.c, bsd-kvm.c, hppa-hpux-nat.c, hppa-linux-nat.c, hppabsd-nat.c, hppanbsd-nat.c, i386-darwin-nat.c, i386bsd-nat.c, ia64-linux-nat.c, m32r-linux-nat.c, m68kbsd-nat.c, m68klinux-nat.c, m88kbsd-nat.c, mips-linux-nat.c, mips64obsd-nat.c, mipsnbsd-nat.c, ppc-linux-nat.c, ppcnbsd-nat.c, ppcobsd-nat.c, remote-sim.c, rs6000-nat.c, s390-nat.c, shnbsd-nat.c, sparc-nat.c, sparc-nat.h, spu-linux-nat.c, vaxbsd-nat.c, xtensa-linux-nat.c: Adjust to target_ops changes. * gdbarch.sh (core_pid_to_str): New gdbarch callback. * gdbarch.h, gdbarch.c: Regenerate. * sol2-tdep.c: Include "inferior.h". (sol2_core_pid_to_str): New. * sol2-tdep.h (sol2_core_pid_to_str): Declare. * amd64-sol2-tdep.c (amd64_sol2_init_abi): Set it. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Set it. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Set it. * i386-sol2-tdep.c (i386_sol2_init_abi): Set it.
2009-02-23 01:03:50 +01:00
extern void set_gdbarch_core_pid_to_str (struct gdbarch *gdbarch, gdbarch_core_pid_to_str_ftype *core_pid_to_str);
/* How the core target extracts the name of a thread from a core file. */
extern int gdbarch_core_thread_name_p (struct gdbarch *gdbarch);
typedef const char * (gdbarch_core_thread_name_ftype) (struct gdbarch *gdbarch, struct thread_info *thr);
extern const char * gdbarch_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr);
extern void set_gdbarch_core_thread_name (struct gdbarch *gdbarch, gdbarch_core_thread_name_ftype *core_thread_name);
/* Read offset OFFSET of TARGET_OBJECT_SIGNAL_INFO signal information
from core file into buffer READBUF with length LEN. Return the number
of bytes read (zero indicates EOF, a negative value indicates failure). */
extern int gdbarch_core_xfer_siginfo_p (struct gdbarch *gdbarch);
typedef LONGEST (gdbarch_core_xfer_siginfo_ftype) (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
extern LONGEST gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
extern void set_gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdbarch_core_xfer_siginfo_ftype *core_xfer_siginfo);
/* BFD target to use when generating a core file. */
extern int gdbarch_gcore_bfd_target_p (struct gdbarch *gdbarch);
extern const char * gdbarch_gcore_bfd_target (struct gdbarch *gdbarch);
extern void set_gdbarch_gcore_bfd_target (struct gdbarch *gdbarch, const char * gcore_bfd_target);
* NEWS: Mention pointer to member improvements. * Makefile.in (gnu-v3-abi.o): Delete special rule. (eval.o, gnu-v3-abi.o, ia64-tdep.o): Update. * ada-valprint.c (ada_print_scalar): Update for new type codes. * c-typeprint.c (c_print_type): Update for new type codes. (c_type_print_varspec_prefix, c_type_print_varspec_suffix) (c_type_print_base): Likewise. (c_type_print_args): Rewrite. * c-valprint.c (c_val_print): Update for new type codes. Remove support for references to members. Treat methods like functions. * cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size) (cplus_make_method_ptr, cplus_method_ptr_to_value): New. * cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size) (cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes. (struct cp_abi_ops): Add corresponding members. * cp-valprint.c (cp_print_class_method): Delete. (cp_find_class_member): New function. (cp_print_class_member): Use it. Simplify support for bogus member pointers. * dwarf2read.c (quirk_gcc_member_function_pointer): Use lookup_methodptr_type. (read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type. * eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for OP_SCOPE. Update call to value_aggregate_elt. Rewrite member pointer support. (evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle references returned by user defined operators. * f-typeprint.c (f_print_type, f_type_print_varspec_prefix) (f_type_print_varspec_suffix): Remove support for member pointers. * gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type and adjusted. (smash_to_memberptr_type): Likewise, from smash_to_member_type. (lookup_methodptr_type): New. (rank_one_type): Adjust for TYPE_CODE_MEMBERPTR. (recursive_dump_type): Update for new types. * gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR. (lookup_memberptr_type, lookup_methodptr_type) (smash_to_memberptr_type): New prototypes. (smash_to_method_type): Formatting fix. (lookup_member_type, smash_to_member_type): Delete prototypes. * gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New. Do not rely on debug information for the vptr or the method's enclosing type. Handle function descriptors for IA64. (gnuv3_virtual_fn_field): Rewrite using the new functions. (gnuv3_find_method_in, gnuv3_print_method_ptr) (gnuv3_method_ptr_size, gnuv3_make_method_ptr) (gnuv3_method_ptr_to_value): New. (init_gnuv3_ops): Set new members of gnu_v3_abi_ops. * hpread.c (hpread_type_lookup): Update for new types. * infcall.c (value_arg_coerce): Likewise. * m2-typeprint.c (m2_print_type): Remove explicit support for member pointers. * m2-valprint.c (m2_val_print): Likewise. * p-typeprint.c (pascal_type_print_varspec_prefix) (pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise. * p-valprint.c (pascal_val_print): Likewise. (pascal_object_print_class_method, pascal_object_print_class_member): Delete. * p-lang.h (pascal_object_print_class_method) (pascal_object_print_class_member): Delete prototypes. * stabsread.c (read_type): Update for new types. * typeprint.c (print_type_scalar): Likewise. * valops.c (value_struct_elt_for_reference, value_namespace_elt) (value_maybe_namespace_elt, value_aggregate_elt): Add want_address argument. Construct a pointer to member if the address of a function or data member is requested. (value_cast_pointers): Don't modify the input value. (value_cast): Adjust pointer to member handling for new types. Allow null pointer to member constants. Don't modify the input value. (value_ind): Remove pointer to member check. Handle function descriptors for function pointers. (value_struct_elt, value_find_oload_method_list, check_field): Remove pointer to member checks. * value.c (unpack_long): Allow pointers to data members. (value_from_longest): Allow member pointers. * value.h (value_aggregate_elt): Add want_address. * varobj.c (c_variable_editable): Remove check for members. * gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta. * ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors in virtual tables. (ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors. * c-lang.h (cp_print_class_method): Delete prototype. * arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta. * mips-tdep.c (mips_gdbarch_init): Likewise. * gdbarch.c, gdbarch.h: Regenerated. * gdb.cp/classes.exp (test_pointers_to_class_members): Update expected output. Test the types of members and member pointers. * gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for gdb/2092. * gdb.cp/member-ptr.exp: Search for a comment instead of a statement. Enable for GCC. Update expected output for some tests and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class layout. * gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x) (Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond) (Diamond::vget_base): New. (main): Add new tests. * gdb.cp/printmethod.exp: Update expected output for member functions. * gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for print pEe->D::vg().
2007-01-03 19:05:45 +01:00
/* If the elements of C++ vtables are in-place function descriptors rather
than normal function pointers (which may point to code or a descriptor),
set this to one. */
extern int gdbarch_vtable_function_descriptors (struct gdbarch *gdbarch);
extern void set_gdbarch_vtable_function_descriptors (struct gdbarch *gdbarch, int vtable_function_descriptors);
/* Set if the least significant bit of the delta is used instead of the least
significant bit of the pfn for pointers to virtual member functions. */
extern int gdbarch_vbit_in_delta (struct gdbarch *gdbarch);
extern void set_gdbarch_vbit_in_delta (struct gdbarch *gdbarch, int vbit_in_delta);
/* Advance PC to next instruction in order to skip a permanent breakpoint. */
typedef void (gdbarch_skip_permanent_breakpoint_ftype) (struct regcache *regcache);
extern void gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch, struct regcache *regcache);
extern void set_gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch, gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint);
/* The maximum length of an instruction on this architecture in bytes. */
Implement displaced stepping. gdb/ * gdbarch.sh (max_insn_length): New 'variable'. (displaced_step_copy, displaced_step_fixup) (displaced_step_free_closure, displaced_step_location): New functions. (struct displaced_step_closure): Add forward declaration. * gdbarch.c, gdbarch.h: Regenerated. * arch-utils.c: #include "objfiles.h". (simple_displaced_step_copy_insn) (simple_displaced_step_free_closure) (displaced_step_at_entry_point): New functions. * arch-utils.h (simple_displaced_step_copy_insn) (simple_displaced_step_free_closure) (displaced_step_at_entry_point): New prototypes. * i386-tdep.c (I386_MAX_INSN_LEN): Rename to... (I386_MAX_MATCHED_INSN_LEN): ... this. (i386_absolute_jmp_p, i386_absolute_call_p) (i386_ret_p, i386_call_p, i386_breakpoint_p, i386_syscall_p) (i386_displaced_step_fixup): New functions. (struct i386_insn, i386_match_insn): Update. (i386_gdbarch_init): Set gdbarch_max_insn_length. * i386-tdep.h (I386_MAX_INSN_LEN): New. (i386_displaced_step_fixup): New prototype. * i386-linux-tdep.c (i386_linux_init_abi): Include "arch-utils.h". Register gdbarch_displaced_step_copy, gdbarch_displaced_step_fixup, gdbarch_displaced_step_free_closure, and gdbarch_displaced_step_location functions. * infrun.c (debug_displaced): New variable. (show_debug_displaced): New function. (struct displaced_step_request): New struct. (displaced_step_request_queue, displaced_step_ptid) (displaced_step_gdbarch, displaced_step_closure) (displaced_step_original, displaced_step_copy) (displaced_step_saved_copy, can_use_displaced_stepping): New variables. (show_can_use_displaced_stepping, use_displaced_stepping) (displaced_step_clear, cleanup_displaced_step_closure) (displaced_step_dump_bytes, displaced_step_prepare) (displaced_step_clear_cleanup, write_memory_ptid) (displaced_step_fixup): New functions. (resume): Call displaced_step_prepare. (proceed): Call read_pc once, and remember the value. If using displaced stepping, don't remove breakpoints. (handle_inferior_event): Call displaced_step_fixup. Add some debugging output. When we try to step over a breakpoint, but get a signal to deliver to the thread instead, ensure the step-resume breakpoint is actually inserted. If a thread hop is needed, and displaced stepping is enabled, don't remove breakpoints. (init_wait_for_inferior): Call displaced_step_clear. (_initialize_infrun): Add "set debug displaced" command. Add "maint set can-use-displaced-stepping" command. Clear displaced_step_ptid. * inferior.h (debug_displaced): Declare variable. (displaced_step_dump_bytes): Declare function. * Makefile.in (arch-utils.o, i386-linux-tdep.o): Update dependencies. gdb/testsuite/ * gdb.asm/asmsrc1.s: Add scratch space. gdb/doc/ * gdb.texinfo (Debugging Output): Document "set/show debug displaced". (Maintenance Commands): Document "maint set/show can-use-displaced-stepping".
2008-05-02 18:49:54 +02:00
extern int gdbarch_max_insn_length_p (struct gdbarch *gdbarch);
extern ULONGEST gdbarch_max_insn_length (struct gdbarch *gdbarch);
extern void set_gdbarch_max_insn_length (struct gdbarch *gdbarch, ULONGEST max_insn_length);
/* Copy the instruction at FROM to TO, and make any adjustments
necessary to single-step it at that address.
REGS holds the state the thread's registers will have before
executing the copied instruction; the PC in REGS will refer to FROM,
not the copy at TO. The caller should update it to point at TO later.
Return a pointer to data of the architecture's choice to be passed
to gdbarch_displaced_step_fixup. Or, return NULL to indicate that
the instruction's effects have been completely simulated, with the
resulting state written back to REGS.
For a general explanation of displaced stepping and how GDB uses it,
see the comments in infrun.c.
The TO area is only guaranteed to have space for
gdbarch_max_insn_length (arch) bytes, so this function must not
write more bytes than that to that area.
If you do not provide this function, GDB assumes that the
architecture does not support displaced stepping.
If the instruction cannot execute out of line, return NULL. The
core falls back to stepping past the instruction in-line instead in
that case. */
Implement displaced stepping. gdb/ * gdbarch.sh (max_insn_length): New 'variable'. (displaced_step_copy, displaced_step_fixup) (displaced_step_free_closure, displaced_step_location): New functions. (struct displaced_step_closure): Add forward declaration. * gdbarch.c, gdbarch.h: Regenerated. * arch-utils.c: #include "objfiles.h". (simple_displaced_step_copy_insn) (simple_displaced_step_free_closure) (displaced_step_at_entry_point): New functions. * arch-utils.h (simple_displaced_step_copy_insn) (simple_displaced_step_free_closure) (displaced_step_at_entry_point): New prototypes. * i386-tdep.c (I386_MAX_INSN_LEN): Rename to... (I386_MAX_MATCHED_INSN_LEN): ... this. (i386_absolute_jmp_p, i386_absolute_call_p) (i386_ret_p, i386_call_p, i386_breakpoint_p, i386_syscall_p) (i386_displaced_step_fixup): New functions. (struct i386_insn, i386_match_insn): Update. (i386_gdbarch_init): Set gdbarch_max_insn_length. * i386-tdep.h (I386_MAX_INSN_LEN): New. (i386_displaced_step_fixup): New prototype. * i386-linux-tdep.c (i386_linux_init_abi): Include "arch-utils.h". Register gdbarch_displaced_step_copy, gdbarch_displaced_step_fixup, gdbarch_displaced_step_free_closure, and gdbarch_displaced_step_location functions. * infrun.c (debug_displaced): New variable. (show_debug_displaced): New function. (struct displaced_step_request): New struct. (displaced_step_request_queue, displaced_step_ptid) (displaced_step_gdbarch, displaced_step_closure) (displaced_step_original, displaced_step_copy) (displaced_step_saved_copy, can_use_displaced_stepping): New variables. (show_can_use_displaced_stepping, use_displaced_stepping) (displaced_step_clear, cleanup_displaced_step_closure) (displaced_step_dump_bytes, displaced_step_prepare) (displaced_step_clear_cleanup, write_memory_ptid) (displaced_step_fixup): New functions. (resume): Call displaced_step_prepare. (proceed): Call read_pc once, and remember the value. If using displaced stepping, don't remove breakpoints. (handle_inferior_event): Call displaced_step_fixup. Add some debugging output. When we try to step over a breakpoint, but get a signal to deliver to the thread instead, ensure the step-resume breakpoint is actually inserted. If a thread hop is needed, and displaced stepping is enabled, don't remove breakpoints. (init_wait_for_inferior): Call displaced_step_clear. (_initialize_infrun): Add "set debug displaced" command. Add "maint set can-use-displaced-stepping" command. Clear displaced_step_ptid. * inferior.h (debug_displaced): Declare variable. (displaced_step_dump_bytes): Declare function. * Makefile.in (arch-utils.o, i386-linux-tdep.o): Update dependencies. gdb/testsuite/ * gdb.asm/asmsrc1.s: Add scratch space. gdb/doc/ * gdb.texinfo (Debugging Output): Document "set/show debug displaced". (Maintenance Commands): Document "maint set/show can-use-displaced-stepping".
2008-05-02 18:49:54 +02:00
extern int gdbarch_displaced_step_copy_insn_p (struct gdbarch *gdbarch);
typedef struct displaced_step_closure * (gdbarch_displaced_step_copy_insn_ftype) (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs);
extern struct displaced_step_closure * gdbarch_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs);
extern void set_gdbarch_displaced_step_copy_insn (struct gdbarch *gdbarch, gdbarch_displaced_step_copy_insn_ftype *displaced_step_copy_insn);
/* Return true if GDB should use hardware single-stepping to execute
the displaced instruction identified by CLOSURE. If false,
GDB will simply restart execution at the displaced instruction
location, and it is up to the target to ensure GDB will receive
control again (e.g. by placing a software breakpoint instruction
into the displaced instruction buffer).
The default implementation returns false on all targets that
provide a gdbarch_software_single_step routine, and true otherwise. */
typedef int (gdbarch_displaced_step_hw_singlestep_ftype) (struct gdbarch *gdbarch, struct displaced_step_closure *closure);
extern int gdbarch_displaced_step_hw_singlestep (struct gdbarch *gdbarch, struct displaced_step_closure *closure);
extern void set_gdbarch_displaced_step_hw_singlestep (struct gdbarch *gdbarch, gdbarch_displaced_step_hw_singlestep_ftype *displaced_step_hw_singlestep);
Implement displaced stepping. gdb/ * gdbarch.sh (max_insn_length): New 'variable'. (displaced_step_copy, displaced_step_fixup) (displaced_step_free_closure, displaced_step_location): New functions. (struct displaced_step_closure): Add forward declaration. * gdbarch.c, gdbarch.h: Regenerated. * arch-utils.c: #include "objfiles.h". (simple_displaced_step_copy_insn) (simple_displaced_step_free_closure) (displaced_step_at_entry_point): New functions. * arch-utils.h (simple_displaced_step_copy_insn) (simple_displaced_step_free_closure) (displaced_step_at_entry_point): New prototypes. * i386-tdep.c (I386_MAX_INSN_LEN): Rename to... (I386_MAX_MATCHED_INSN_LEN): ... this. (i386_absolute_jmp_p, i386_absolute_call_p) (i386_ret_p, i386_call_p, i386_breakpoint_p, i386_syscall_p) (i386_displaced_step_fixup): New functions. (struct i386_insn, i386_match_insn): Update. (i386_gdbarch_init): Set gdbarch_max_insn_length. * i386-tdep.h (I386_MAX_INSN_LEN): New. (i386_displaced_step_fixup): New prototype. * i386-linux-tdep.c (i386_linux_init_abi): Include "arch-utils.h". Register gdbarch_displaced_step_copy, gdbarch_displaced_step_fixup, gdbarch_displaced_step_free_closure, and gdbarch_displaced_step_location functions. * infrun.c (debug_displaced): New variable. (show_debug_displaced): New function. (struct displaced_step_request): New struct. (displaced_step_request_queue, displaced_step_ptid) (displaced_step_gdbarch, displaced_step_closure) (displaced_step_original, displaced_step_copy) (displaced_step_saved_copy, can_use_displaced_stepping): New variables. (show_can_use_displaced_stepping, use_displaced_stepping) (displaced_step_clear, cleanup_displaced_step_closure) (displaced_step_dump_bytes, displaced_step_prepare) (displaced_step_clear_cleanup, write_memory_ptid) (displaced_step_fixup): New functions. (resume): Call displaced_step_prepare. (proceed): Call read_pc once, and remember the value. If using displaced stepping, don't remove breakpoints. (handle_inferior_event): Call displaced_step_fixup. Add some debugging output. When we try to step over a breakpoint, but get a signal to deliver to the thread instead, ensure the step-resume breakpoint is actually inserted. If a thread hop is needed, and displaced stepping is enabled, don't remove breakpoints. (init_wait_for_inferior): Call displaced_step_clear. (_initialize_infrun): Add "set debug displaced" command. Add "maint set can-use-displaced-stepping" command. Clear displaced_step_ptid. * inferior.h (debug_displaced): Declare variable. (displaced_step_dump_bytes): Declare function. * Makefile.in (arch-utils.o, i386-linux-tdep.o): Update dependencies. gdb/testsuite/ * gdb.asm/asmsrc1.s: Add scratch space. gdb/doc/ * gdb.texinfo (Debugging Output): Document "set/show debug displaced". (Maintenance Commands): Document "maint set/show can-use-displaced-stepping".
2008-05-02 18:49:54 +02:00
/* Fix up the state resulting from successfully single-stepping a
displaced instruction, to give the result we would have gotten from
stepping the instruction in its original location.
REGS is the register state resulting from single-stepping the
displaced instruction.
CLOSURE is the result from the matching call to
gdbarch_displaced_step_copy_insn.
If you provide gdbarch_displaced_step_copy_insn.but not this
function, then GDB assumes that no fixup is needed after
single-stepping the instruction.
For a general explanation of displaced stepping and how GDB uses it,
see the comments in infrun.c. */
extern int gdbarch_displaced_step_fixup_p (struct gdbarch *gdbarch);
typedef void (gdbarch_displaced_step_fixup_ftype) (struct gdbarch *gdbarch, struct displaced_step_closure *closure, CORE_ADDR from, CORE_ADDR to, struct regcache *regs);
extern void gdbarch_displaced_step_fixup (struct gdbarch *gdbarch, struct displaced_step_closure *closure, CORE_ADDR from, CORE_ADDR to, struct regcache *regs);
extern void set_gdbarch_displaced_step_fixup (struct gdbarch *gdbarch, gdbarch_displaced_step_fixup_ftype *displaced_step_fixup);
/* Return the address of an appropriate place to put displaced
instructions while we step over them. There need only be one such
place, since we're only stepping one thread over a breakpoint at a
time.
For a general explanation of displaced stepping and how GDB uses it,
see the comments in infrun.c. */
typedef CORE_ADDR (gdbarch_displaced_step_location_ftype) (struct gdbarch *gdbarch);
extern CORE_ADDR gdbarch_displaced_step_location (struct gdbarch *gdbarch);
extern void set_gdbarch_displaced_step_location (struct gdbarch *gdbarch, gdbarch_displaced_step_location_ftype *displaced_step_location);
/* Relocate an instruction to execute at a different address. OLDLOC
is the address in the inferior memory where the instruction to
relocate is currently at. On input, TO points to the destination
where we want the instruction to be copied (and possibly adjusted)
to. On output, it points to one past the end of the resulting
instruction(s). The effect of executing the instruction at TO shall
be the same as if executing it at FROM. For example, call
instructions that implicitly push the return address on the stack
should be adjusted to return to the instruction after OLDLOC;
relative branches, and other PC-relative instructions need the
offset adjusted; etc. */
extern int gdbarch_relocate_instruction_p (struct gdbarch *gdbarch);
typedef void (gdbarch_relocate_instruction_ftype) (struct gdbarch *gdbarch, CORE_ADDR *to, CORE_ADDR from);
extern void gdbarch_relocate_instruction (struct gdbarch *gdbarch, CORE_ADDR *to, CORE_ADDR from);
extern void set_gdbarch_relocate_instruction (struct gdbarch *gdbarch, gdbarch_relocate_instruction_ftype *relocate_instruction);
/* Refresh overlay mapped state for section OSECT. */
extern int gdbarch_overlay_update_p (struct gdbarch *gdbarch);
typedef void (gdbarch_overlay_update_ftype) (struct obj_section *osect);
extern void gdbarch_overlay_update (struct gdbarch *gdbarch, struct obj_section *osect);
extern void set_gdbarch_overlay_update (struct gdbarch *gdbarch, gdbarch_overlay_update_ftype *overlay_update);
extern int gdbarch_core_read_description_p (struct gdbarch *gdbarch);
typedef const struct target_desc * (gdbarch_core_read_description_ftype) (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd);
extern const struct target_desc * gdbarch_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd);
extern void set_gdbarch_core_read_description (struct gdbarch *gdbarch, gdbarch_core_read_description_ftype *core_read_description);
/* Handle special encoding of static variables in stabs debug info. */
extern int gdbarch_static_transform_name_p (struct gdbarch *gdbarch);
* gdbtypes.h (struct main_type): Change type of name,tag_name, and fields.name members from char * to const char *. All uses updated. (struct cplus_struct_type): Change type of fn_fieldlists.name member from char * to const char *. All uses updated. (type_name_no_tag): Update. (lookup_unsigned_typename, lookup_signed_typename): Update. * gdbtypes.c (type_name_no_tag): Change result type from char * to const char *. All callers updated. (lookup_unsigned_typename, lookup_signed_typename): Change type of name parameter from char * to const char *. * symtab.h (struct cplus_specific): Change type of demangled_name member from char * to const char *. All uses updated. (struct general_symbol_info): Change type of name and mangled_lang.demangled_name members from char * to const char *. All uses updated. (symbol_get_demangled_name, symbol_natural_name): Update. (symbol_demangled_name, symbol_search_name): Update. * symtab.c (symbol_get_demangled_name): Change result type from char * to const char *. All callers updated. (symbol_natural_name, symbol_demangled_name): Ditto. (symbol_search_name): Ditto. (completion_list_add_name): Change type of symname,sym_text, text,word parameters from char * to const char *. (completion_list_objc_symbol): Change type of sym_text, text,word parameters from char * to const char *. * ada-lang.c (find_struct_field): Change type of name parameter from char * to const char *. (encoded_ordered_before): Similarly for N0,N1 parameters. (old_renaming_is_invisible): Similarly for function_name parameter. (ada_type_name): Change result type from char * to const char *. All callers updated. * ada-lang.h (ada_type_name): Update. * buildsym.c (hashname): Change type of name parameter from char * to const char *. * buildsym.h (hashname): Update. * dbxread.c (end_psymtab): Change type of include_list parameter from char ** to const char **. * dwarf2read.c (determine_prefix): Change result type from char * to const char *. All callers updated. * f-lang.c (find_common_for_function): Change type of name, funcname parameters from char * to const char *. * f-lang.c (find_common_for_function): Update. * f-valprint.c (list_all_visible_commons): Change type of funcname parameters from char * to const char *. * gdbarch.sh (static_transform_name): Change type of name parameter and result from char * to const char *. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type of name parameter from char * to const char *. * jv-lang.c (java_primitive_type_from_name): Ditto. (java_demangled_signature_length): Similarly for signature parameter. (java_demangled_signature_copy): Ditto. (java_demangle_type_signature): Ditto. * jv-lang.h (java_primitive_type_from_name): Update. (java_demangle_type_signature): Update. * objc-lang.c (specialcmp): Change type of a,b parameters from char * to const char *. * p-lang.c (is_pascal_string_type): Change type of arrayname parameter from char * to const char *. All callers updated. * p-lang.h (is_pascal_string_type): Update. * solib-frv.c (find_canonical_descriptor_in_load_object): Change type of name parameter from char * to const char *. * sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto. * utils.c (fprintf_symbol_filtered): Ditto. * defs.h (fprintf_symbol_filtered): Update. * sparc-tdep.h (sparc_sol2_static_transform_name): Update. * stabsread.h (end_psymtab): Update. * stack.c (find_frame_funname): Change type of funname parameter from char ** to const char **. * stack.h (find_frame_funname): Update. * typeprint.c (type_print): Change type of varstring parameter from char * to const char *. * value.h (type_print): Update. * xcoffread.c (xcoff_start_psymtab): Change type of filename parameter from char * to const char *. All callers updated. (xcoff_end_psymtab): Change type of include_list parameter from char ** to const char **. All callers updated. (swap_sym): Similarly for name parameter. All callers updated. * coffread.c (patch_type): Add (char*) cast to xfree parameter. Use xstrdup. (process_coff_symbol): Use xstrdup. * stabsread.c (stabs_method_name_from_physname): Renamed from update_method_name_from_physname. Change result type from void to char *. All callers updated. (read_member_functions): In has_destructor case, store name in objfile obstack instead of malloc space. In !has_stub case, fix mem leak.
2012-02-07 05:48:23 +01:00
typedef const char * (gdbarch_static_transform_name_ftype) (const char *name);
extern const char * gdbarch_static_transform_name (struct gdbarch *gdbarch, const char *name);
extern void set_gdbarch_static_transform_name (struct gdbarch *gdbarch, gdbarch_static_transform_name_ftype *static_transform_name);
* gdbarch.sh (sofun_address_maybe_missing): New gdbarch variable. * gdbarch.c, gdbarch.h: Regenerate. * dbxread.c (find_stab_function_addr): Define unconditionally. (read_dbx_symtab): Use gdbarch_sofun_address_maybe_missing instead of SOFUN_ADDRESS_MAYBE_MISSING. (end_psymtab): Likewise. (process_one_symbol): Likewise. * mdebugread.c (parse_partial_symbols): Likewise. * symtab.h (struct minimal_symbol): Always define "filename" member. * elfread.c (elf_symtab_read): Use msym->filename unconditionally. * minsyms.c (lookup_minimal_symbol): Likewise. * symmisc.c (dump_msymbols): Likewise. * config/i386/i386sol2.mt (DEPRECATED_TM_FILE): Remove. * config/i386/linux.mt (DEPRECATED_TM_FILE): Remove. * config/i386/tm-i386sol2.h: Remove file. * config/i386/tm-linux.h: Remove file. * i386-linux-tdep.c (i386_linux_init_abi): Add call to set_gdbarch_sofun_address_maybe_missing. * i386-sol2-tdep.c (i386_sol2_init_abi): Likewise. * config/powerpc/linux.mt (DEPRECATED_TM_FILE): Remove. * config/powerpc/nbsd.mt (DEPRECATED_TM_FILE): Remove. * config/powerpc/obsd.mt (DEPRECATED_TM_FILE): Remove. * config/powerpc/ppc-eabi.mt (DEPRECATED_TM_FILE): Remove. * config/powerpc/ppc-sim.mt (DEPRECATED_TM_FILE): Remove. * config/powerpc/tm-ppc-eabi.h: Remove file. * rs6000-tdep.c (rs6000_gdbarch_init): Add call to set_gdbarch_sofun_address_maybe_missing. * config/sparc/sol2-64.mt (DEPRECATED_TM_FILE): Remove. * config/sparc/sol2.mt (DEPRECATED_TM_FILE): Remove. * config/sparc/tm-sol2.h: Remove file. * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Add call to set_gdbarch_sofun_address_maybe_missing. * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Likewise. doc/ChangeLog: * gdbarch.texi (Target Conditionals): Remove documentation of SOFUN_ADDRESS_MAYBE_MISSING, replaced by ... (Compiler Characteristics): ... documentation of set_gdbarch_sofun_address_maybe_missing.
2007-10-19 14:26:35 +02:00
/* Set if the address in N_SO or N_FUN stabs may be zero. */
extern int gdbarch_sofun_address_maybe_missing (struct gdbarch *gdbarch);
extern void set_gdbarch_sofun_address_maybe_missing (struct gdbarch *gdbarch, int sofun_address_maybe_missing);
/* Parse the instruction at ADDR storing in the record execution log
the registers REGCACHE and memory ranges that will be affected when
the instruction executes, along with their current values.
Return -1 if something goes wrong, 0 otherwise. */
extern int gdbarch_process_record_p (struct gdbarch *gdbarch);
typedef int (gdbarch_process_record_ftype) (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr);
extern int gdbarch_process_record (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr);
extern void set_gdbarch_process_record (struct gdbarch *gdbarch, gdbarch_process_record_ftype *process_record);
/* Save process state after a signal.
Return -1 if something goes wrong, 0 otherwise. */
extern int gdbarch_process_record_signal_p (struct gdbarch *gdbarch);
typedef int (gdbarch_process_record_signal_ftype) (struct gdbarch *gdbarch, struct regcache *regcache, enum gdb_signal signal);
extern int gdbarch_process_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, enum gdb_signal signal);
extern void set_gdbarch_process_record_signal (struct gdbarch *gdbarch, gdbarch_process_record_signal_ftype *process_record_signal);
/* Signal translation: translate inferior's signal (target's) number
into GDB's representation. The implementation of this method must
be host independent. IOW, don't rely on symbols of the NAT_FILE
header (the nm-*.h files), the host <signal.h> header, or similar
headers. This is mainly used when cross-debugging core files ---
"Live" targets hide the translation behind the target interface
(target_wait, target_resume, etc.). */
extern int gdbarch_gdb_signal_from_target_p (struct gdbarch *gdbarch);
typedef enum gdb_signal (gdbarch_gdb_signal_from_target_ftype) (struct gdbarch *gdbarch, int signo);
extern enum gdb_signal gdbarch_gdb_signal_from_target (struct gdbarch *gdbarch, int signo);
extern void set_gdbarch_gdb_signal_from_target (struct gdbarch *gdbarch, gdbarch_gdb_signal_from_target_ftype *gdb_signal_from_target);
This patch implements the new gdbarch method gdbarch_gdb_signal_to_target. It will be used when one wants to convert between the internal GDB signal representation (enum gdb_signal) and the target's representation. The idea of this patch came from a chat between Pedro and I on IRC, plus the discussion of my patches to add the new $_exitsignal convenience variable: <http://sourceware.org/ml/gdb-patches/2013-06/msg00452.html> <http://sourceware.org/ml/gdb-patches/2013-06/msg00352.html> What I did was to investigate, on the Linux kernel, which targets shared the signal numbers definition with the generic definition, present at <include/uapi/asm-generic/signal.h>. For the record, I used linux-3.10-rc7 as the main source of information, always looking at <arch/<ARCH_NAME>/include/uapi/asm/signal.h>. For SIGRTMAX (which defaults to _NSIG in most cases), I had to look at different signal-related files, but most of them (except MIPS) were defined to 64 anyway. Then, with all the differences in hand, I implemented the bits on each target. 2013-08-09 Sergio Durigan Junior <sergiodj@redhat.com> * linux-tdep.c: Define enum with generic signal numbers. (linux_gdb_signal_from_target): New function. (linux_gdb_signal_to_target): Likewise. (linux_init_abi): Set gdbarch_gdb_signal_{to,from}_target methods to the functions above. * linux-tdep.h (linux_gdb_signal_from_target): New prototype. (linux_gdb_signal_to_target): Likewise. * alpha-linux-tdep.c: Define new enum with signals different from generic Linux kernel. (alpha_linux_gdb_signal_from_target): New function. (alpha_linux_gdb_signal_to_target): Likewise. (alpha_linux_init_abi): Set gdbarch_gdb_signal_{to,from}_target with the functions mentioned above. * avr-tdep.c: Define enum with differences between Linux kernel and AVR signals. (avr_linux_gdb_signal_from_target): New function. (avr_linux_gdb_signal_to_target): Likewise. (avr_gdbarch_init): Set gdbarch_gdb_signal_{to,from}_target to the functions mentioned above. * sparc-linux-tdep.c: Define enum with differences between SPARC and generic Linux kernel signal numbers. (sparc32_linux_gdb_signal_from_target): New function. (sparc32_linux_gdb_signal_to_target): Likewise. (sparc32_linux_init_abi): Set gdbarch_gdb_signal_{to,from}_target to the functions defined above. * xtensa-linux-tdep.c: Define enum with differences between Xtensa and Linux kernel generic signals. (xtensa_linux_gdb_signal_from_target): New function. (xtensa_linux_gdb_signal_to_target): Likewise. (xtensa_linux_init_abi): Set gdbarch_gdb_signal_to_target to the functions defined above. * mips-linux-tdep.c: Define enum with differences between signals in MIPS and Linux kernel generic ones. (mips_gdb_signal_to_target): New function. (mips_gdb_signal_from_target): Redefine to use new enum, handle only different signals from the Linux kernel generic. (mips_linux_init_abi): Set gdbarch_gdb_signal_{to,from}_target the functions defined above. * mips-linux-tdep.h (enum mips_signals): Remove.
2013-08-09 18:54:43 +02:00
/* Signal translation: translate the GDB's internal signal number into
the inferior's signal (target's) representation. The implementation
of this method must be host independent. IOW, don't rely on symbols
of the NAT_FILE header (the nm-*.h files), the host <signal.h>
header, or similar headers.
Return the target signal number if found, or -1 if the GDB internal
signal number is invalid. */
extern int gdbarch_gdb_signal_to_target_p (struct gdbarch *gdbarch);
typedef int (gdbarch_gdb_signal_to_target_ftype) (struct gdbarch *gdbarch, enum gdb_signal signal);
extern int gdbarch_gdb_signal_to_target (struct gdbarch *gdbarch, enum gdb_signal signal);
extern void set_gdbarch_gdb_signal_to_target (struct gdbarch *gdbarch, gdbarch_gdb_signal_to_target_ftype *gdb_signal_to_target);
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
/* Extra signal info inspection.
2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/ * target.h (enum target_object): Add new TARGET_OBJECT_SIGNAL_INFO. * infrun.c (siginfo_value_read, siginfo_value_write): New. (siginfo_value_funcs): New. (siginfo_make_value): New. (_initialize_infrun): Create the $_siginfo convenience variable. * gdbtypes.h (append_composite_type_field_aligned): Declare. * gdbtypes.c (append_composite_type_field): Rename to... (append_composite_type_field_aligned): ... this. Add ALIGNMENT argument. Handle it. (append_composite_type_field): Rewrite on top of append_composite_type_field_aligned. * value.h (internalvar_make_value): New typedef. (struct internalvar) <make_value>: New field. (create_internalvar_type_lazy): Declare. * value.c (create_internalvar): Clear make_value. (create_internalvar_type_lazy): New. (value_of_internalvar): If make_value is set use it. (preserve_values): Skip internal variables that don't have a value. * gdbarch.sh (get_siginfo_type): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.h, linux-tdep.c: New. * amd64-linux-tdep.c: Include "linux-tdep.h". (amd64_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * i386-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * arm-linux-tdep.c: Include "linux-tdep.h". (i386_linux_init_abi): Register linux_get_siginfo_type and linux_get_siginfo_mapper. * linux-nat.c (linux_xfer_siginfo): New. (linux_nat_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. * remote.c (PACKET_qXfer_siginfo_read) (PACKET_qXfer_siginfo_write): New. (feature remote_protocol_features): Add "qXfer:siginfo:read" and "qXfer:siginfo:write" features. (remote_xfer_partial): Handle TARGET_OBJECT_SIGNAL_INFO. (_initialize_remote): Add "set/show remote read-siginfo-object" and "set/show remote write-siginfo-object" commands. * Makefile.in (ALL_TARGET_OBS): Add linux-tdep.o. (HFILES_NO_SRCDIR): Add linux-tdep.h. (ALLDEPFILES): Add linux-tdep.c. * configure.tgt (arm*-*-linux* | arm*-*-uclinux*) (i[34567]86-*-linux*, x86_64-*-linux*): Add linux-tdep.o to gdb_target_obs. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/gdbserver/ * server.c (handle_query): Report qXfer:siginfo:read and qXfer:siginfo:write as supported and handle them. * target.h (struct target_ops) <qxfer_siginfo>: New field. * linux-low.c (linux_xfer_siginfo): New. (linux_target_ops): Set it. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/doc/ * gdb.texinfo (Signals): Document $_siginfo. (Convenience Variables): Mention $_siginfo. (Remote Configuration): Document qXfer:siginfo:read, qXfer:siginfo:write packets, and the read-siginfo-object, write-siginfo-object commands. 2009-02-06 Pedro Alves <pedro@codesourcery.com> gdb/testsuite/ * gdb.base/siginfo-obj.c, gdb.base/siginfo-obj.exp: New.
2009-02-06 23:59:01 +01:00
Return a type suitable to inspect extra signal information. */
extern int gdbarch_get_siginfo_type_p (struct gdbarch *gdbarch);
typedef struct type * (gdbarch_get_siginfo_type_ftype) (struct gdbarch *gdbarch);
extern struct type * gdbarch_get_siginfo_type (struct gdbarch *gdbarch);
extern void set_gdbarch_get_siginfo_type (struct gdbarch *gdbarch, gdbarch_get_siginfo_type_ftype *get_siginfo_type);
/* Record architecture-specific information from the symbol table. */
extern int gdbarch_record_special_symbol_p (struct gdbarch *gdbarch);
typedef void (gdbarch_record_special_symbol_ftype) (struct gdbarch *gdbarch, struct objfile *objfile, asymbol *sym);
extern void gdbarch_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile, asymbol *sym);
extern void set_gdbarch_record_special_symbol (struct gdbarch *gdbarch, gdbarch_record_special_symbol_ftype *record_special_symbol);
Implementing catch syscall. * amd64-linux-tdep.c: Include xml-syscall.h header, define the XML syscall name for the architecture. (amd64_linux_get_syscall_number): New function. (amd64_linux_init_abi): Register the correct functions for syscall catchpoint; set the correct syscall file name. * breakpoint.c: New include: xml-syscall.h. (set_raw_breakpoint_without_location): Setting the parameters for the catch syscall feature. (insert_catch_syscall): New. (remove_catch_syscall): New. (breakpoint_hit_catch_syscall): New. (print_it_catch_syscall): New. (print_one_catch_syscall): New. (print_mention_catch_syscall): New. (catch_syscall_breakpoint_ops): New. (syscall_catchpoint_p): New. (create_catchpoint_without_mention): New. (create_catchpoint): Modified in order to use create_catchpoint_without_mention. (create_syscall_event_catchpoint): New. (clean_up_filters): New. (catch_syscall_split_args): New. (catch_syscall_command_1): New. (delete_breakpoint): Add cleanup for catch syscall. (is_syscall_catchpoint_enabled): New. (catch_syscall_enabled): New. (catching_syscall_number): New. (catch_syscall_completer): New completer function. (add_catch_command): Add the completer function for catchpoints. * breakpoint.h (syscalls_to_be_caught): New vector. (catch_syscall_enabled): New. (catching_syscall_number): New. * gdbarch.c: Regenerated. * gdbarch.h: Regenerated. * gdbarch.sh: Add syscall catchpoint functions and structures. (get_syscall_number): New. (UNKNOWN_SYSCALL): New definition. * i386-linux-nat.c (i386_linux_resume): Select the proper request to be made for ptrace() considering if we are catching syscalls or not. * i386-linux-tdep.c: Include xml-syscall.h header, define the XML syscall name for the architecture. (i386_linux_get_syscall_number): New. (i386_linux_init_abi): Register the correct functions for syscall catchpoint; set the correct syscall file name. * inf-child.c (inf_child_set_syscall_catchpoint): New. (inf_child_target): Assign default values to target_ops. * inf-ptrace.c (inf_ptrace_resume): Select the proper request to be made for ptrace() considering if we are catching syscalls or not. * inferior.h (struct inferior): Included new variables any_syscall_count, syscalls_counts and total_syscalls_count, used to keep track of requested syscall catchpoints. * infrun.c (resume): Add syscall catchpoint. (deal_with_syscall_event): New. (handle_inferior_event): Add syscall entry/return events. (inferior_has_called_syscall): New. * linux-nat.c: Define some helpful variables to track wether we have support for the needed ptrace option. (linux_test_for_tracesysgood): New. (linux_supports_tracesysgood): New. (linux_enable_tracesysgood): New. (linux_enable_event_reporting): Save the current used ptrace options. (linux_child_post_attach): Calling linux_enable_tracesysgood. (linux_child_post_startup_inferior): Likewise. (linux_child_set_syscall_catchpoint): New function. (linux_handle_extended_wait): Handle the case which the inferior stops because it has called or returned from a syscall. (linux_target_install_ops): Install the necessary functions to handle syscall catchpoints. * linux-nat.h (struct lwp_info): Include syscall_state into the structure, which indicates if we are in a syscall entry or return. * ppc-linux-tdep.c: Include xml-syscall.h header, define the XML syscall filename for the arch. (ppc_linux_get_syscall_number): New. (ppc_linux_init_abi): Register the correct functions for syscall catchpoint; setting the correct name for the XML syscall file. * target.c (update_current_target): Update/copy functions related to syscall catchpoint. (target_waitstatus_to_string): Add syscall catchpoint entry/return events. * target.h (struct target_waitstatus): Add syscall number. (struct syscall): New struct to hold information about syscalls in the system. (struct target_ops): Add ops for syscall catchpoint. (inferior_has_called_syscall): New. (target_set_syscall_catchpoint): New. * xml-support.c (xml_fetch_content_from_file): New function, transferred from xml-tdesc.c. * xml-support.h (xml_fetch_content_from_file): New. * xml-tdesc.c (fetch_xml_from_file): Function removed; transferred to xml-support.c. (file_read_description_xml): Updated to use the new xml_fetch_content_from_file function. * syscalls/gdb-syscalls.dtd: New definition file for syscall's XML support. * syscalls/amd64-linux.xml: New file containing information about syscalls for GNU/Linux systems that use amd64 architecture. * syscalls/i386-linux.xml: New file containing information about syscalls for GNU/Linux systems that use i386 architecture. * syscalls/ppc-linux.xml: New file containing information about syscalls for GNU/Linux systems that use PPC architecture. * syscalls/ppc64-linux.xml: New file containing information about syscalls for GNU/Linux systems that use PPC64 architecture. * xml-syscall.c: New file containing functions for manipulating syscall's XML files. * xml-syscall.h: New file, exporting the functions above mentioned. * Makefile.in: Support for relocatable GDB datadir and XML syscall. * NEWS: Added information about the catch syscall feature. * doc/gdb.texinfo (Set Catchpoints): Documentation about the new feature. * testsuite/Makefile.in: Inclusion of catch-syscall object. * testsuite/gdb.base/catch-syscall.c: New file. * testsuite/gdb.base/catch-syscall.exp: New file.
2009-09-15 05:30:08 +02:00
/* Function for the 'catch syscall' feature.
Get architecture-specific system calls information from registers. */
extern int gdbarch_get_syscall_number_p (struct gdbarch *gdbarch);
Use thread_info and inferior pointers more throughout This is more preparation bits for multi-target support. In a multi-target scenario, we need to address the case of different processes/threads running on different targets that happen to have the same PID/PTID. E.g., we can have both process 123 in target 1, and process 123 in target 2, while they're in reality different processes running on different machines. Or maybe we've loaded multiple instances of the same core file. Etc. To address this, in my WIP multi-target branch, threads and processes are uniquely identified by the (process_stratum target_ops *, ptid_t) and (process_stratum target_ops *, pid) tuples respectively. I.e., each process_stratum instance has its own thread/process number space. As you can imagine, that requires passing around target_ops * pointers in a number of functions where we're currently passing only a ptid_t or an int. E.g., when we look up a thread_info object by ptid_t in find_thread_ptid, the ptid_t alone isn't sufficient. In many cases though, we already have the thread_info or inferior pointer handy, but we "lose" it somewhere along the call stack, only to look it up again by ptid_t/pid. Since thread_info or inferior objects know their parent target, if we pass around thread_info or inferior pointers when possible, we avoid having to add extra target_ops parameters to many functions, and also, we eliminate a number of by ptid_t/int lookups. So that's what this patch does. In a bit more detail: - Changes a number of functions and methods to take a thread_info or inferior pointer instead of a ptid_t or int parameter. - Changes a number of structure fields from ptid_t/int to inferior or thread_info pointers. - Uses the inferior_thread() function whenever possible instead of inferior_ptid. - Uses thread_info pointers directly when possible instead of the is_running/is_stopped etc. routines that require a lookup. - A number of functions are eliminated along the way, such as: int valid_gdb_inferior_id (int num); int pid_to_gdb_inferior_id (int pid); int gdb_inferior_id_to_pid (int num); int in_inferior_list (int pid); - A few structures and places hold a thread_info pointer across inferior execution, so now they take a strong reference to the (refcounted) thread_info object to avoid the thread_info pointer getting stale. This is done in enable_thread_stack_temporaries and in the infcall.c code. - Related, there's a spot in infcall.c where using a RAII object to handle the refcount would be handy, so a gdb::ref_ptr specialization for thread_info is added (thread_info_ref, in gdbthread.h), along with a gdb_ref_ptr policy that works for all refcounted_object types (in common/refcounted-object.h). gdb/ChangeLog: 2018-06-21 Pedro Alves <palves@redhat.com> * ada-lang.h (ada_get_task_number): Take a thread_info pointer instead of a ptid_t. All callers adjusted. * ada-tasks.c (ada_get_task_number): Likewise. All callers adjusted. (print_ada_task_info, display_current_task_id, task_command_1): Adjust. * breakpoint.c (watchpoint_in_thread_scope): Adjust to use inferior_thread. (breakpoint_kind): Adjust. (remove_breakpoints_pid): Rename to ... (remove_breakpoints_inf): ... this. Adjust to take an inferior pointer. All callers adjusted. (bpstat_clear_actions): Use inferior_thread. (get_bpstat_thread): New. (bpstat_do_actions): Use it. (bpstat_check_breakpoint_conditions, bpstat_stop_status): Adjust to take a thread_info pointer. All callers adjusted. (set_longjmp_breakpoint_for_call_dummy, set_momentary_breakpoint) (breakpoint_re_set_thread): Use inferior_thread. * breakpoint.h (struct inferior): Forward declare. (bpstat_stop_status): Update. (remove_breakpoints_pid): Delete. (remove_breakpoints_inf): New. * bsd-uthread.c (bsd_uthread_target::wait) (bsd_uthread_target::update_thread_list): Use find_thread_ptid. * btrace.c (btrace_add_pc, btrace_enable, btrace_fetch) (maint_btrace_packet_history_cmd) (maint_btrace_clear_packet_history_cmd): Adjust. (maint_btrace_clear_cmd, maint_info_btrace_cmd): Adjust to use inferior_thread. * cli/cli-interp.c: Include "inferior.h". * common/refcounted-object.h (struct refcounted_object_ref_policy): New. * compile/compile-object-load.c: Include gdbthread.h. (store_regs): Use inferior_thread. * corelow.c (core_target::close): Use current_inferior. (core_target_open): Adjust to use first_thread_of_inferior and use the current inferior. * ctf.c (ctf_target::close): Adjust to use current_inferior. * dummy-frame.c (dummy_frame_id) <ptid>: Delete, replaced by ... <thread>: ... this new field. All references adjusted. (dummy_frame_pop, dummy_frame_discard, register_dummy_frame_dtor): Take a thread_info pointer instead of a ptid_t. * dummy-frame.h (dummy_frame_push, dummy_frame_pop) (dummy_frame_discard, register_dummy_frame_dtor): Take a thread_info pointer instead of a ptid_t. * elfread.c: Include "inferior.h". (elf_gnu_ifunc_resolver_stop, elf_gnu_ifunc_resolver_return_stop): Use inferior_thread. * eval.c (evaluate_subexp): Likewise. * frame.c (frame_pop, has_stack_frames, find_frame_sal): Use inferior_thread. * gdb_proc_service.h (struct thread_info): Forward declare. (struct ps_prochandle) <ptid>: Delete, replaced by ... <thread>: ... this new field. All references adjusted. * gdbarch.h, gdbarch.c: Regenerate. * gdbarch.sh (get_syscall_number): Replace 'ptid' parameter with a 'thread' parameter. All implementations and callers adjusted. * gdbthread.h (thread_info) <set_running>: New method. (delete_thread, delete_thread_silent): Take a thread_info pointer instead of a ptid. (global_thread_id_to_ptid, ptid_to_global_thread_id): Delete. (first_thread_of_process): Delete, replaced by ... (first_thread_of_inferior): ... this new function. All callers adjusted. (any_live_thread_of_process): Delete, replaced by ... (any_live_thread_of_inferior): ... this new function. All callers adjusted. (switch_to_thread, switch_to_no_thread): Declare. (is_executing): Delete. (enable_thread_stack_temporaries): Update comment. <enable_thread_stack_temporaries>: Take a thread_info pointer instead of a ptid_t. Incref the thread. <~enable_thread_stack_temporaries>: Decref the thread. <m_ptid>: Delete <m_thr>: New. (thread_stack_temporaries_enabled_p, push_thread_stack_temporary) (get_last_thread_stack_temporary) (value_in_thread_stack_temporaries, can_access_registers_thread): Take a thread_info pointer instead of a ptid_t. All callers adjusted. * infcall.c (get_call_return_value): Use inferior_thread. (run_inferior_call): Work with thread pointers instead of ptid_t. (call_function_by_hand_dummy): Work with thread pointers instead of ptid_t. Use thread_info_ref. * infcmd.c (proceed_thread_callback): Access thread's state directly. (ensure_valid_thread, ensure_not_running): Use inferior_thread, access thread's state directly. (continue_command): Use inferior_thread. (info_program_command): Use find_thread_ptid and access thread state directly. (proceed_after_attach_callback): Use thread state directly. (notice_new_inferior): Take a thread_info pointer instead of a ptid_t. All callers adjusted. (exit_inferior): Take an inferior pointer instead of a pid. All callers adjusted. (exit_inferior_silent): New. (detach_inferior): Delete. (valid_gdb_inferior_id, pid_to_gdb_inferior_id) (gdb_inferior_id_to_pid, in_inferior_list): Delete. (detach_inferior_command, kill_inferior_command): Use find_inferior_id instead of valid_gdb_inferior_id and gdb_inferior_id_to_pid. (inferior_command): Use inferior and thread pointers. * inferior.h (struct thread_info): Forward declare. (notice_new_inferior): Take a thread_info pointer instead of a ptid_t. All callers adjusted. (detach_inferior): Delete declaration. (exit_inferior, exit_inferior_silent): Take an inferior pointer instead of a pid. All callers adjusted. (gdb_inferior_id_to_pid, pid_to_gdb_inferior_id, in_inferior_list) (valid_gdb_inferior_id): Delete. * infrun.c (follow_fork_inferior, proceed_after_vfork_done) (handle_vfork_child_exec_or_exit, follow_exec): Adjust. (struct displaced_step_inferior_state) <pid>: Delete, replaced by ... <inf>: ... this new field. <step_ptid>: Delete, replaced by ... <step_thread>: ... this new field. (get_displaced_stepping_state): Take an inferior pointer instead of a pid. All callers adjusted. (displaced_step_in_progress_any_inferior): Adjust. (displaced_step_in_progress_thread): Take a thread pointer instead of a ptid_t. All callers adjusted. (displaced_step_in_progress, add_displaced_stepping_state): Take an inferior pointer instead of a pid. All callers adjusted. (get_displaced_step_closure_by_addr): Adjust. (remove_displaced_stepping_state): Take an inferior pointer instead of a pid. All callers adjusted. (displaced_step_prepare_throw, displaced_step_prepare) (displaced_step_fixup): Take a thread pointer instead of a ptid_t. All callers adjusted. (start_step_over): Adjust. (infrun_thread_ptid_changed): Remove bit updating ptids in the displaced step queue. (do_target_resume): Adjust. (fetch_inferior_event): Use inferior_thread. (context_switch, get_inferior_stop_soon): Take an execution_control_state pointer instead of a ptid_t. All callers adjusted. (switch_to_thread_cleanup): Delete. (stop_all_threads): Use scoped_restore_current_thread. * inline-frame.c: Include "gdbthread.h". (inline_state) <inline_state>: Take a thread pointer instead of a ptid_t. All callers adjusted. <ptid>: Delete, replaced by ... <thread>: ... this new field. (find_inline_frame_state): Take a thread pointer instead of a ptid_t. All callers adjusted. (skip_inline_frames, step_into_inline_frame) (inline_skipped_frames, inline_skipped_symbol): Take a thread pointer instead of a ptid_t. All callers adjusted. * inline-frame.h (skip_inline_frames, step_into_inline_frame) (inline_skipped_frames, inline_skipped_symbol): Likewise. * linux-fork.c (delete_checkpoint_command): Adjust to use thread pointers directly. * linux-nat.c (get_detach_signal): Likewise. * linux-thread-db.c (thread_from_lwp): New 'stopped' parameter. (thread_db_notice_clone): Adjust. (thread_db_find_new_threads_silently) (thread_db_find_new_threads_2, thread_db_find_new_threads_1): Take a thread pointer instead of a ptid_t. All callers adjusted. * mi/mi-cmd-var.c: Include "inferior.h". (mi_cmd_var_update_iter): Update to use thread pointers. * mi/mi-interp.c (mi_new_thread): Update to use the thread's inferior directly. (mi_output_running_pid, mi_inferior_count): Delete, bits factored out to ... (mi_output_running): ... this new function. (mi_on_resume_1): Adjust to use it. (mi_user_selected_context_changed): Adjust to use inferior_thread. * mi/mi-main.c (proceed_thread): Adjust to use thread pointers directly. (interrupt_thread_callback): : Adjust to use thread and inferior pointers. * proc-service.c: Include "gdbthread.h". (ps_pglobal_lookup): Adjust to use the thread's inferior directly. * progspace-and-thread.c: Include "inferior.h". * progspace.c: Include "inferior.h". * python/py-exitedevent.c (create_exited_event_object): Adjust to hold a reference to an inferior_object. * python/py-finishbreakpoint.c (bpfinishpy_init): Adjust to use inferior_thread. * python/py-inferior.c (struct inferior_object): Give the type a tag name instead of a typedef. (python_on_normal_stop): No need to check if the current thread is listed. (inferior_to_inferior_object): Change return type to inferior_object. All callers adjusted. (find_thread_object): Delete, bits factored out to ... (thread_to_thread_object): ... this new function. * python/py-infthread.c (create_thread_object): Use inferior_to_inferior_object. (thpy_is_stopped): Use thread pointer directly. (gdbpy_selected_thread): Use inferior_thread. * python/py-record-btrace.c (btpy_list_object) <ptid>: Delete field, replaced with ... <thread>: ... this new field. All users adjusted. (btpy_insn_or_gap_new): Drop const. (btpy_list_new): Take a thread pointer instead of a ptid_t. All callers adjusted. * python/py-record.c: Include "gdbthread.h". (recpy_insn_new, recpy_func_new): Take a thread pointer instead of a ptid_t. All callers adjusted. (gdbpy_current_recording): Use inferior_thread. * python/py-record.h (recpy_record_object) <ptid>: Delete field, replaced with ... <thread>: ... this new field. All users adjusted. (recpy_element_object) <ptid>: Delete field, replaced with ... <thread>: ... this new field. All users adjusted. (recpy_insn_new, recpy_func_new): Take a thread pointer instead of a ptid_t. All callers adjusted. * python/py-threadevent.c: Include "gdbthread.h". (get_event_thread): Use thread_to_thread_object. * python/python-internal.h (struct inferior_object): Forward declare. (find_thread_object, find_inferior_object): Delete declarations. (thread_to_thread_object, inferior_to_inferior_object): New declarations. * record-btrace.c: Include "inferior.h". (require_btrace_thread): Use inferior_thread. (record_btrace_frame_sniffer) (record_btrace_tailcall_frame_sniffer): Use inferior_thread. (get_thread_current_frame): Use scoped_restore_current_thread and switch_to_thread. (get_thread_current_frame): Use thread pointer directly. (record_btrace_replay_at_breakpoint): Use thread's inferior pointer directly. * record-full.c: Include "inferior.h". * regcache.c: Include "gdbthread.h". (get_thread_arch_regcache): Use the inferior's address space directly. (get_thread_regcache, registers_changed_thread): New. * regcache.h (get_thread_regcache(thread_info *thread)): New overload. (registers_changed_thread): New. (remote_target) <remote_detach_1>: Swap order of parameters. (remote_add_thread): <remote_add_thread>: Return the new thread. (get_remote_thread_info(ptid_t)): New overload. (remote_target::remote_notice_new_inferior): Use thread pointers directly. (remote_target::process_initial_stop_replies): Use thread_info::set_running. (remote_target::remote_detach_1, remote_target::detach) (extended_remote_target::detach): Adjust. * stack.c (frame_show_address): Use inferior_thread. * target-debug.h (target_debug_print_thread_info_pp): New. * target-delegates.c: Regenerate. * target.c (default_thread_address_space): Delete. (memory_xfer_partial_1): Use current_inferior. (target_detach): Use current_inferior. (target_thread_address_space): Delete. (generic_mourn_inferior): Use current_inferior. * target.h (struct target_ops) <thread_address_space>: Delete. (target_thread_address_space): Delete. * thread.c (init_thread_list): Use ALL_THREADS_SAFE. Use thread pointers directly. (delete_thread_1, delete_thread, delete_thread_silent): Take a thread pointer instead of a ptid_t. Adjust all callers. (ptid_to_global_thread_id, global_thread_id_to_ptid): Delete. (first_thread_of_process): Delete, replaced by ... (first_thread_of_inferior): ... this new function. All callers adjusted. (any_thread_of_process): Rename to ... (any_thread_of_inferior): ... this, and take an inferior pointer. (any_live_thread_of_process): Rename to ... (any_live_thread_of_inferior): ... this, and take an inferior pointer. (thread_stack_temporaries_enabled_p, push_thread_stack_temporary) (value_in_thread_stack_temporaries) (get_last_thread_stack_temporary): Take a thread pointer instead of a ptid_t. Adjust all callers. (thread_info::set_running): New. (validate_registers_access): Use inferior_thread. (can_access_registers_ptid): Rename to ... (can_access_registers_thread): ... this, and take a thread pointer. (print_thread_info_1): Adjust to compare thread pointers instead of ptids. (switch_to_no_thread, switch_to_thread): Make extern. (scoped_restore_current_thread::~scoped_restore_current_thread): Use m_thread pointer directly. (scoped_restore_current_thread::scoped_restore_current_thread): Use inferior_thread. (thread_command): Use thread pointer directly. (thread_num_make_value_helper): Use inferior_thread. * top.c (execute_command): Use inferior_thread. * tui/tui-interp.c: Include "inferior.h". * varobj.c (varobj_create): Use inferior_thread. (value_of_root_1): Use find_thread_global_id instead of global_thread_id_to_ptid.
2018-06-21 18:09:31 +02:00
typedef LONGEST (gdbarch_get_syscall_number_ftype) (struct gdbarch *gdbarch, thread_info *thread);
extern LONGEST gdbarch_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread);
Implementing catch syscall. * amd64-linux-tdep.c: Include xml-syscall.h header, define the XML syscall name for the architecture. (amd64_linux_get_syscall_number): New function. (amd64_linux_init_abi): Register the correct functions for syscall catchpoint; set the correct syscall file name. * breakpoint.c: New include: xml-syscall.h. (set_raw_breakpoint_without_location): Setting the parameters for the catch syscall feature. (insert_catch_syscall): New. (remove_catch_syscall): New. (breakpoint_hit_catch_syscall): New. (print_it_catch_syscall): New. (print_one_catch_syscall): New. (print_mention_catch_syscall): New. (catch_syscall_breakpoint_ops): New. (syscall_catchpoint_p): New. (create_catchpoint_without_mention): New. (create_catchpoint): Modified in order to use create_catchpoint_without_mention. (create_syscall_event_catchpoint): New. (clean_up_filters): New. (catch_syscall_split_args): New. (catch_syscall_command_1): New. (delete_breakpoint): Add cleanup for catch syscall. (is_syscall_catchpoint_enabled): New. (catch_syscall_enabled): New. (catching_syscall_number): New. (catch_syscall_completer): New completer function. (add_catch_command): Add the completer function for catchpoints. * breakpoint.h (syscalls_to_be_caught): New vector. (catch_syscall_enabled): New. (catching_syscall_number): New. * gdbarch.c: Regenerated. * gdbarch.h: Regenerated. * gdbarch.sh: Add syscall catchpoint functions and structures. (get_syscall_number): New. (UNKNOWN_SYSCALL): New definition. * i386-linux-nat.c (i386_linux_resume): Select the proper request to be made for ptrace() considering if we are catching syscalls or not. * i386-linux-tdep.c: Include xml-syscall.h header, define the XML syscall name for the architecture. (i386_linux_get_syscall_number): New. (i386_linux_init_abi): Register the correct functions for syscall catchpoint; set the correct syscall file name. * inf-child.c (inf_child_set_syscall_catchpoint): New. (inf_child_target): Assign default values to target_ops. * inf-ptrace.c (inf_ptrace_resume): Select the proper request to be made for ptrace() considering if we are catching syscalls or not. * inferior.h (struct inferior): Included new variables any_syscall_count, syscalls_counts and total_syscalls_count, used to keep track of requested syscall catchpoints. * infrun.c (resume): Add syscall catchpoint. (deal_with_syscall_event): New. (handle_inferior_event): Add syscall entry/return events. (inferior_has_called_syscall): New. * linux-nat.c: Define some helpful variables to track wether we have support for the needed ptrace option. (linux_test_for_tracesysgood): New. (linux_supports_tracesysgood): New. (linux_enable_tracesysgood): New. (linux_enable_event_reporting): Save the current used ptrace options. (linux_child_post_attach): Calling linux_enable_tracesysgood. (linux_child_post_startup_inferior): Likewise. (linux_child_set_syscall_catchpoint): New function. (linux_handle_extended_wait): Handle the case which the inferior stops because it has called or returned from a syscall. (linux_target_install_ops): Install the necessary functions to handle syscall catchpoints. * linux-nat.h (struct lwp_info): Include syscall_state into the structure, which indicates if we are in a syscall entry or return. * ppc-linux-tdep.c: Include xml-syscall.h header, define the XML syscall filename for the arch. (ppc_linux_get_syscall_number): New. (ppc_linux_init_abi): Register the correct functions for syscall catchpoint; setting the correct name for the XML syscall file. * target.c (update_current_target): Update/copy functions related to syscall catchpoint. (target_waitstatus_to_string): Add syscall catchpoint entry/return events. * target.h (struct target_waitstatus): Add syscall number. (struct syscall): New struct to hold information about syscalls in the system. (struct target_ops): Add ops for syscall catchpoint. (inferior_has_called_syscall): New. (target_set_syscall_catchpoint): New. * xml-support.c (xml_fetch_content_from_file): New function, transferred from xml-tdesc.c. * xml-support.h (xml_fetch_content_from_file): New. * xml-tdesc.c (fetch_xml_from_file): Function removed; transferred to xml-support.c. (file_read_description_xml): Updated to use the new xml_fetch_content_from_file function. * syscalls/gdb-syscalls.dtd: New definition file for syscall's XML support. * syscalls/amd64-linux.xml: New file containing information about syscalls for GNU/Linux systems that use amd64 architecture. * syscalls/i386-linux.xml: New file containing information about syscalls for GNU/Linux systems that use i386 architecture. * syscalls/ppc-linux.xml: New file containing information about syscalls for GNU/Linux systems that use PPC architecture. * syscalls/ppc64-linux.xml: New file containing information about syscalls for GNU/Linux systems that use PPC64 architecture. * xml-syscall.c: New file containing functions for manipulating syscall's XML files. * xml-syscall.h: New file, exporting the functions above mentioned. * Makefile.in: Support for relocatable GDB datadir and XML syscall. * NEWS: Added information about the catch syscall feature. * doc/gdb.texinfo (Set Catchpoints): Documentation about the new feature. * testsuite/Makefile.in: Inclusion of catch-syscall object. * testsuite/gdb.base/catch-syscall.c: New file. * testsuite/gdb.base/catch-syscall.exp: New file.
2009-09-15 05:30:08 +02:00
extern void set_gdbarch_get_syscall_number (struct gdbarch *gdbarch, gdbarch_get_syscall_number_ftype *get_syscall_number);
Partial fix for PR breakpoints/10737: Make syscall info be per-arch instead of global This patch intends to partially fix PR breakpoints/10737, which is about making the syscall information (for the "catch syscall" command) be per-arch, instead of global. This is not a full fix because of the other issues pointed by Pedro here: <https://sourceware.org/bugzilla/show_bug.cgi?id=10737#c5> However, I consider it a good step towards the real fix. It will also help me fix <https://sourceware.org/bugzilla/show_bug.cgi?id=17402>. What this patch does, basically, is move the "syscalls_info" struct to gdbarch. Currently, the syscall information is stored in a global variable inside gdb/xml-syscall.c, which means that there is no easy way to correlate this info with the current target or architecture being used, for example. This causes strange behaviors, because the syscall info is not re-read when the arch changes. For example, if you put a syscall catchpoint in syscall 5 on i386 (syscall open), and then load a x86_64 program on GDB and put the same syscall 5 there (fstat on x86_64), you will still see that GDB tells you that it is catching "open", even though it is not. With this patch, GDB correctly says that it will be catching fstat syscalls. (gdb) set architecture i386 The target architecture is assumed to be i386 (gdb) catch syscall 5 Catchpoint 1 (syscall 'open' [5]) (gdb) set architecture i386:x86-64 The target architecture is assumed to be i386:x86-64 (gdb) catch syscall 5 Catchpoint 2 (syscall 'open' [5]) But with the patch: (gdb) set architecture i386 The target architecture is assumed to be i386 (gdb) catch syscall 5 Catchpoint 1 (syscall 'open' [5]) (gdb) set architecture i386:x86-64 The target architecture is assumed to be i386:x86-64 (gdb) catch syscall 5 Catchpoint 2 (syscall 'fstat' [5]) As I said, there are still some problems on the "catch syscall" mechanism, because (for example) the user should be able to "catch syscall open" on i386, and then expect "open" to be caught also on x86_64. Currently, it doesn't work. I intend to work on this later. gdb/ 2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com> PR breakpoints/10737 * amd64-linux-tdep.c (amd64_linux_init_abi_common): Adjust call to set_xml_syscall_file_name to provide gdbarch. * arm-linux-tdep.c (arm_linux_init_abi): Likewise. * bfin-linux-tdep.c (bfin_linux_init_abi): Likewise. * breakpoint.c (print_it_catch_syscall): Adjust call to get_syscall_by_number to provide gdbarch. (print_one_catch_syscall): Likewise. (print_mention_catch_syscall): Likewise. (print_recreate_catch_syscall): Likewise. (catch_syscall_split_args): Adjust calls to get_syscall_by_number and get_syscall_by_name to provide gdbarch. (catch_syscall_completer): Adjust call to get_syscall_names to provide gdbarch. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * gdbarch.sh: Forward declare "struct syscalls_info". (xml_syscall_file): New variable. (syscalls_info): Likewise. * i386-linux-tdep.c (i386_linux_init_abi): Adjust call to set_xml_syscall_file_name to provide gdbarch. * mips-linux-tdep.c (mips_linux_init_abi): Likewise. * ppc-linux-tdep.c (ppc_linux_init_abi): Likewise. * s390-linux-tdep.c (s390_gdbarch_init): Likewise. * sparc-linux-tdep.c (sparc32_linux_init_abi): Likewise. * sparc64-linux-tdep.c (sparc64_linux_init_abi): Likewise. * xml-syscall.c: Include gdbarch.h. (set_xml_syscall_file_name): Accept gdbarch parameter. (get_syscall_by_number): Likewise. (get_syscall_by_name): Likewise. (get_syscall_names): Likewise. (my_gdb_datadir): Delete global variable. (struct syscalls_info) <my_gdb_datadir>: New variable. (struct syscalls_info) <sysinfo>: Rename variable to "syscalls_info". (sysinfo): Delete global variable. (have_initialized_sysinfo): Likewise. (xml_syscall_file): Likewise. (sysinfo_free_syscalls_desc): Rename to... (syscalls_info_free_syscalls_desc): ... this. (free_syscalls_info): Rename "sysinfo" to "syscalls_info". Adjust code to the new layout of "struct syscalls_info". (make_cleanup_free_syscalls_info): Rename parameter "sysinfo" to "syscalls_info". (syscall_create_syscall_desc): Likewise. (syscall_start_syscall): Likewise. (syscall_parse_xml): Likewise. (xml_init_syscalls_info): Likewise. Drop "const" from return value. (init_sysinfo): Rename to... (init_syscalls_info): ...this. Add gdbarch as a parameter. Adjust function to deal with gdbarch. (xml_get_syscall_number): Delete parameter sysinfo. Accept gdbarch as a parameter. Adjust code. (xml_get_syscall_name): Likewise. (xml_list_of_syscalls): Likewise. (set_xml_syscall_file_name): Accept gdbarch as parameter. (get_syscall_by_number): Likewise. (get_syscall_by_name): Likewise. (get_syscall_names): Likewise. * xml-syscall.h (set_xml_syscall_file_name): Likewise. (get_syscall_by_number): Likewise. (get_syscall_by_name): Likewise. (get_syscall_names): Likewise. gdb/testsuite/ 2014-11-20 Sergio Durigan Junior <sergiodj@redhat.com> PR breakpoints/10737 * gdb.base/catch-syscall.exp (do_syscall_tests): Call test_catch_syscall_multi_arch. (test_catch_syscall_multi_arch): New function.
2014-11-20 18:28:18 +01:00
/* The filename of the XML syscall for this architecture. */
extern const char * gdbarch_xml_syscall_file (struct gdbarch *gdbarch);
extern void set_gdbarch_xml_syscall_file (struct gdbarch *gdbarch, const char * xml_syscall_file);
/* Information about system calls from this architecture */
extern struct syscalls_info * gdbarch_syscalls_info (struct gdbarch *gdbarch);
extern void set_gdbarch_syscalls_info (struct gdbarch *gdbarch, struct syscalls_info * syscalls_info);
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02:00
/* SystemTap related fields and functions.
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-19 21:53:40 +01:00
A NULL-terminated array of prefixes used to mark an integer constant
on the architecture's assembly.
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02:00
For example, on x86 integer constants are written as:
$10 ;; integer constant 10
in this case, this prefix would be the character `$'. */
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-19 21:53:40 +01:00
extern const char *const * gdbarch_stap_integer_prefixes (struct gdbarch *gdbarch);
extern void set_gdbarch_stap_integer_prefixes (struct gdbarch *gdbarch, const char *const * stap_integer_prefixes);
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02: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-19 21:53:40 +01:00
/* A NULL-terminated array of suffixes used to mark an integer constant
on the architecture's assembly. */
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02: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-19 21:53:40 +01:00
extern const char *const * gdbarch_stap_integer_suffixes (struct gdbarch *gdbarch);
extern void set_gdbarch_stap_integer_suffixes (struct gdbarch *gdbarch, const char *const * stap_integer_suffixes);
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02: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-19 21:53:40 +01:00
/* A NULL-terminated array of prefixes used to mark a register name on
the architecture's assembly.
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02:00
For example, on x86 the register name is written as:
%eax ;; register eax
in this case, this prefix would be the character `%'. */
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-19 21:53:40 +01:00
extern const char *const * gdbarch_stap_register_prefixes (struct gdbarch *gdbarch);
extern void set_gdbarch_stap_register_prefixes (struct gdbarch *gdbarch, const char *const * stap_register_prefixes);
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02: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-19 21:53:40 +01:00
/* A NULL-terminated array of suffixes used to mark a register name on
the architecture's assembly. */
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02: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-19 21:53:40 +01:00
extern const char *const * gdbarch_stap_register_suffixes (struct gdbarch *gdbarch);
extern void set_gdbarch_stap_register_suffixes (struct gdbarch *gdbarch, const char *const * stap_register_suffixes);
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02: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-19 21:53:40 +01:00
/* A NULL-terminated array of prefixes used to mark a register
indirection on the architecture's assembly.
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02:00
For example, on x86 the register indirection is written as:
(%eax) ;; indirecting eax
in this case, this prefix would be the charater `('.
Please note that we use the indirection prefix also for register
displacement, e.g., `4(%eax)' on x86. */
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-19 21:53:40 +01:00
extern const char *const * gdbarch_stap_register_indirection_prefixes (struct gdbarch *gdbarch);
extern void set_gdbarch_stap_register_indirection_prefixes (struct gdbarch *gdbarch, const char *const * stap_register_indirection_prefixes);
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02: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-19 21:53:40 +01:00
/* A NULL-terminated array of suffixes used to mark a register
indirection on the architecture's assembly.
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02:00
For example, on x86 the register indirection is written as:
(%eax) ;; indirecting eax
in this case, this prefix would be the charater `)'.
Please note that we use the indirection suffix also for register
displacement, e.g., `4(%eax)' on x86. */
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-19 21:53:40 +01:00
extern const char *const * gdbarch_stap_register_indirection_suffixes (struct gdbarch *gdbarch);
extern void set_gdbarch_stap_register_indirection_suffixes (struct gdbarch *gdbarch, const char *const * stap_register_indirection_suffixes);
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02: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-19 21:53:40 +01:00
/* Prefix(es) used to name a register using GDB's nomenclature.
2012-04-27 Sergio Durigan Junior <sergiodj@redhat.com> Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * Makefile.in (SFILES): Add `probe' and `stap-probe'. (COMMON_OBS): Likewise. (HFILES_NO_SRCDIR): Add `probe'. * NEWS: Mention support for static and SystemTap probes. * amd64-tdep.c (amd64_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * arm-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (arm_stap_is_single_operand): New function. (arm_stap_parse_special_token): Likewise. (arm_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * ax-gdb.c (require_rvalue): Removing static declaration. (gen_expr): Likewise. * ax-gdb.h (gen_expr): Declaring function. (require_rvalue): Likewise. * breakpoint.c: Include `gdb_regex.h' and `probe.h'. (bkpt_probe_breakpoint_ops): New variable. (momentary_breakpoint_from_master): Set the `probe' value. (add_location_to_breakpoint): Likewise. (break_command_1): Using proper breakpoint_ops according to the argument passed by the user in the command line. (bkpt_probe_insert_location): New function. (bkpt_probe_remove_location): Likewise. (bkpt_probe_create_sals_from_address): Likewise. (bkpt_probe_decode_linespec): Likewise. (tracepoint_probe_create_sals_from_address): Likewise. (tracepoint_probe_decode_linespec): Likewise. (tracepoint_probe_breakpoint_ops): New variable. (trace_command): Using proper breakpoint_ops according to the argument passed by the user in the command line. (initialize_breakpoint_ops): Initializing breakpoint_ops for static probes on breakpoints and tracepoints. * breakpoint.h (struct bp_location) <probe>: New field. * cli-utils.c (skip_spaces_const): New function. (extract_arg): Likewise. * cli-utils.h (skip_spaces_const): Likewise. (extract_arg): Likewise. * coffread.c (coff_sym_fns): Add `sym_probe_fns' value. * configure.ac: Append `stap-probe.o' to be generated when ELF support is present. * configure: Regenerate. * dbxread.c (aout_sym_fns): Add `sym_probe_fns' value. * elfread.c: Include `probe.h' and `arch-utils.h'. (probe_key): New variable. (elf_get_probes): New function. (elf_get_probe_argument_count): Likewise. (elf_evaluate_probe_argument): Likewise. (elf_compile_to_ax): Likewise. (elf_symfile_relocate_probe): Likewise. (stap_probe_key_free): Likewise. (elf_probe_fns): New variable. (elf_sym_fns): Add `sym_probe_fns' value. (elf_sym_fns_lazy_psyms): Likewise. (elf_sym_fns_gdb_index): Likewise. (_initialize_elfread): Initialize objfile cache for static probes. * gdb_vecs.h (struct probe): New forward declaration. (probe_p): New VEC declaration. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix): New variable. (stap_integer_suffix): Likewise. (stap_register_prefix): Likewise. (stap_register_suffix): Likewise. (stap_register_indirection_prefix): Likewise. (stap_register_indirection_suffix): Likewise. (stap_gdb_register_prefix): Likewise. (stap_gdb_register_suffix): Likewise. (stap_is_single_operand): New function. (stap_parse_special_token): Likewise. (struct stap_parse_info): Forward declaration. * i386-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. (i386_elf_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * i386-tdep.h (i386_stap_is_single_operand): New function. (i386_stap_parse_special_token): Likewise. * machoread.c (macho_sym_fns): Add `sym_probe_fns' value. * mipsread.c (ecoff_sym_fns): Likewise. * objfiles.c (objfile_relocate1): Support relocation for static probes. * parse.c (prefixify_expression): Remove static declaration. (initialize_expout): Likewise. (reallocate_expout): Likewise. * parser-defs.h (initialize_expout): Declare function. (reallocate_expout): Likewise. (prefixify_expression): Likewise. * ppc-linux-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (ppc_stap_is_single_operand): New function. (ppc_stap_parse_special_token): Likewise. (ppc_linux_init_abi): Initializing proper fields used by SystemTap probes' arguments parser. * probe.c: New file, for generic statically defined probe support. * probe.h: Likewise. * s390-tdep.c: Including headers needed to perform the parsing of SystemTap probes' arguments. (s390_stap_is_single_operand): New function. (s390_gdbarch_init): Initializing proper fields used by SystemTap probes' arguments parser. * somread.c (som_sym_fns): Add `sym_probe_fns' value. * stap-probe.c: New file, for SystemTap probe support. * stap-probe.h: Likewise. * symfile.h: Include `gdb_vecs.h'. (struct sym_probe_fns): New struct. (struct sym_fns) <sym_probe_fns>: New field. * symtab.c (init_sal): Initialize `probe' field. * symtab.h (struct probe): Forward declaration. (struct symtab_and_line) <probe>: New field. * tracepoint.c (start_tracing): Adjust semaphore on breakpoints locations. (stop_tracing): Likewise. * xcoffread.c (xcoff_sym_fns): Add `sym_probe_fns' value.
2012-04-27 22:47:57 +02:00
For example, on PPC a register is represented by a number in the assembly
language (e.g., `10' is the 10th general-purpose register). However,
inside GDB this same register has an `r' appended to its name, so the 10th
register would be represented as `r10' internally. */
extern const char * gdbarch_stap_gdb_register_prefix (struct gdbarch *gdbarch);
extern void set_gdbarch_stap_gdb_register_prefix (struct gdbarch *gdbarch, const char * stap_gdb_register_prefix);
/* Suffix used to name a register using GDB's nomenclature. */
extern const char * gdbarch_stap_gdb_register_suffix (struct gdbarch *gdbarch);
extern void set_gdbarch_stap_gdb_register_suffix (struct gdbarch *gdbarch, const char * stap_gdb_register_suffix);
/* Check if S is a single operand.
Single operands can be:
- Literal integers, e.g. `$10' on x86
- Register access, e.g. `%eax' on x86
- Register indirection, e.g. `(%eax)' on x86
- Register displacement, e.g. `4(%eax)' on x86
This function should check for these patterns on the string
and return 1 if some were found, or zero otherwise. Please try to match
as much info as you can from the string, i.e., if you have to match
something like `(%', do not match just the `('. */
extern int gdbarch_stap_is_single_operand_p (struct gdbarch *gdbarch);
typedef int (gdbarch_stap_is_single_operand_ftype) (struct gdbarch *gdbarch, const char *s);
extern int gdbarch_stap_is_single_operand (struct gdbarch *gdbarch, const char *s);
extern void set_gdbarch_stap_is_single_operand (struct gdbarch *gdbarch, gdbarch_stap_is_single_operand_ftype *stap_is_single_operand);
/* Function used to handle a "special case" in the parser.
A "special case" is considered to be an unknown token, i.e., a token
that the parser does not know how to parse. A good example of special
case would be ARM's register displacement syntax:
[R0, #4] ;; displacing R0 by 4
Since the parser assumes that a register displacement is of the form:
<number> <indirection_prefix> <register_name> <indirection_suffix>
it means that it will not be able to recognize and parse this odd syntax.
Therefore, we should add a special case function that will handle this token.
This function should generate the proper expression form of the expression
using GDB's internal expression mechanism (e.g., `write_exp_elt_opcode'
and so on). It should also return 1 if the parsing was successful, or zero
if the token was not recognized as a special token (in this case, returning
zero means that the special parser is deferring the parsing to the generic
parser), and should advance the buffer pointer (p->arg). */
extern int gdbarch_stap_parse_special_token_p (struct gdbarch *gdbarch);
typedef int (gdbarch_stap_parse_special_token_ftype) (struct gdbarch *gdbarch, struct stap_parse_info *p);
extern int gdbarch_stap_parse_special_token (struct gdbarch *gdbarch, struct stap_parse_info *p);
extern void set_gdbarch_stap_parse_special_token (struct gdbarch *gdbarch, gdbarch_stap_parse_special_token_ftype *stap_parse_special_token);
Adjust i386 registers on SystemTap probes' arguments (PR breakpoints/24541) This bug has been reported on PR breakpoints/24541, but it is possible to reproduce it easily by running: make check-gdb TESTS=gdb.base/stap-probe.exp RUNTESTFLAGS='--target_board unix/-m32' The underlying cause is kind of complex, and involves decisions made by GCC and the sys/sdt.h header file about how to represent a probe argument that lives in a register in 32-bit programs. I'll use Andrew's example on the bug to illustrate the problem. libstdc++ has a probe named "throw" with two arguments. On i386, the probe is: stapsdt 0x00000028 NT_STAPSDT (SystemTap probe descriptors) Provider: libstdcxx Name: throw Location: 0x00072c96, Base: 0x00133d64, Semaphore: 0x00000000 Arguments: 4@%si 4@%di I.e., the first argument is an unsigned 32-bit value (represented by the "4@") that lives on %si, and the second argument is an unsigned 32-bit value that lives on %di. Note the discrepancy between the argument size reported by the probe (32-bit) and the register size being used to store the value (16-bit). However, if you take a look at the disassemble of a program that uses this probe, you will see: 00072c80 <__cxa_throw@@CXXABI_1.3>: 72c80: 57 push %edi 72c81: 56 push %esi 72c82: 53 push %ebx 72c83: 8b 74 24 10 mov 0x10(%esp),%esi 72c87: e8 74 bf ff ff call 6ec00 <__cxa_finalize@plt+0x980> 72c8c: 81 c3 74 e3 10 00 add $0x10e374,%ebx 72c92: 8b 7c 24 14 mov 0x14(%esp),%edi 72c96: 90 nop <----------------- PROBE IS HERE 72c97: e8 d4 a2 ff ff call 6cf70 <__cxa_get_globals@plt> 72c9c: 83 40 04 01 addl $0x1,0x4(%eax) 72ca0: 83 ec 04 sub $0x4,%esp 72ca3: ff 74 24 1c pushl 0x1c(%esp) 72ca7: 57 push %edi 72ca8: 56 push %esi 72ca9: e8 62 a3 ff ff call 6d010 <__cxa_init_primary_exception@plt> 72cae: 8d 70 40 lea 0x40(%eax),%esi 72cb1: c7 00 01 00 00 00 movl $0x1,(%eax) 72cb7: 89 34 24 mov %esi,(%esp) 72cba: e8 61 96 ff ff call 6c320 <_Unwind_RaiseException@plt> 72cbf: 89 34 24 mov %esi,(%esp) 72cc2: e8 c9 84 ff ff call 6b190 <__cxa_begin_catch@plt> 72cc7: e8 d4 b3 ff ff call 6e0a0 <_ZSt9terminatev@plt> 72ccc: 66 90 xchg %ax,%ax 72cce: 66 90 xchg %ax,%ax Note how the program is actually using %edi, and not %di, to store the second argument. This is the problem here. GDB will basically read the probe argument, then read the contents of %di, and then cast this value to uint32_t, which causes the wrong value to be obtained. In the gdb.base/stap-probe.exp case, this makes GDB read the wrong memory location, and not be able to display a test string. In Andrew's example, this causes GDB to actually stop at a "catch throw" when it should actually have *not* stopped. After some discussion with Frank Eigler and Jakub Jelinek, it was decided that this bug should be fixed on the client side (i.e., the program that actually reads the probes), and this is why I'm proposing this patch. The idea is simple: we will have a gdbarch method, which, for now, is only used by i386. The generic code that deals with register operands on gdb/stap-probe.c will call this method if it exists, passing the current parse information, the register name and its number. The i386 method will then verify if the register size is greater or equal than the size reported by the stap probe (the "4@" part). If it is, we're fine. Otherwise, it will check if we're dealing with any of the "extendable" registers (like ax, bx, si, di, sp, etc.). If we are, it will change the register name to include the "e" prefix. I have tested the patch here in many scenarios, and it fixes Andrew's bug and also the regressions I mentioned before, on gdb.base/stap-probe.exp. No regressions where found on other tests. Comments? gdb/ChangeLog: 2019-06-27 Sergio Durigan Junior <sergiodj@redhat.com> PR breakpoints/24541 * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh: Add 'stap_adjust_register'. * i386-tdep.c: Include '<unordered_set>'. (i386_stap_adjust_register): New function. (i386_elf_init_abi): Register 'i386_stap_adjust_register'. * stap-probe.c (stap_parse_register_operand): Call 'gdbarch_stap_adjust_register'.
2019-06-26 23:34:50 +02:00
/* Perform arch-dependent adjustments to a register name.
In very specific situations, it may be necessary for the register
name present in a SystemTap probe's argument to be handled in a
special way. For example, on i386, GCC may over-optimize the
register allocation and use smaller registers than necessary. In
such cases, the client that is reading and evaluating the SystemTap
probe (ourselves) will need to actually fetch values from the wider
version of the register in question.
To illustrate the example, consider the following probe argument
(i386):
4@%ax
This argument says that its value can be found at the %ax register,
which is a 16-bit register. However, the argument's prefix says
that its type is "uint32_t", which is 32-bit in size. Therefore, in
this case, GDB should actually fetch the probe's value from register
%eax, not %ax. In this scenario, this function would actually
replace the register name from %ax to %eax.
The rationale for this can be found at PR breakpoints/24541. */
extern int gdbarch_stap_adjust_register_p (struct gdbarch *gdbarch);
typedef std::string (gdbarch_stap_adjust_register_ftype) (struct gdbarch *gdbarch, struct stap_parse_info *p, const std::string &regname, int regnum);
extern std::string gdbarch_stap_adjust_register (struct gdbarch *gdbarch, struct stap_parse_info *p, const std::string &regname, int regnum);
Adjust i386 registers on SystemTap probes' arguments (PR breakpoints/24541) This bug has been reported on PR breakpoints/24541, but it is possible to reproduce it easily by running: make check-gdb TESTS=gdb.base/stap-probe.exp RUNTESTFLAGS='--target_board unix/-m32' The underlying cause is kind of complex, and involves decisions made by GCC and the sys/sdt.h header file about how to represent a probe argument that lives in a register in 32-bit programs. I'll use Andrew's example on the bug to illustrate the problem. libstdc++ has a probe named "throw" with two arguments. On i386, the probe is: stapsdt 0x00000028 NT_STAPSDT (SystemTap probe descriptors) Provider: libstdcxx Name: throw Location: 0x00072c96, Base: 0x00133d64, Semaphore: 0x00000000 Arguments: 4@%si 4@%di I.e., the first argument is an unsigned 32-bit value (represented by the "4@") that lives on %si, and the second argument is an unsigned 32-bit value that lives on %di. Note the discrepancy between the argument size reported by the probe (32-bit) and the register size being used to store the value (16-bit). However, if you take a look at the disassemble of a program that uses this probe, you will see: 00072c80 <__cxa_throw@@CXXABI_1.3>: 72c80: 57 push %edi 72c81: 56 push %esi 72c82: 53 push %ebx 72c83: 8b 74 24 10 mov 0x10(%esp),%esi 72c87: e8 74 bf ff ff call 6ec00 <__cxa_finalize@plt+0x980> 72c8c: 81 c3 74 e3 10 00 add $0x10e374,%ebx 72c92: 8b 7c 24 14 mov 0x14(%esp),%edi 72c96: 90 nop <----------------- PROBE IS HERE 72c97: e8 d4 a2 ff ff call 6cf70 <__cxa_get_globals@plt> 72c9c: 83 40 04 01 addl $0x1,0x4(%eax) 72ca0: 83 ec 04 sub $0x4,%esp 72ca3: ff 74 24 1c pushl 0x1c(%esp) 72ca7: 57 push %edi 72ca8: 56 push %esi 72ca9: e8 62 a3 ff ff call 6d010 <__cxa_init_primary_exception@plt> 72cae: 8d 70 40 lea 0x40(%eax),%esi 72cb1: c7 00 01 00 00 00 movl $0x1,(%eax) 72cb7: 89 34 24 mov %esi,(%esp) 72cba: e8 61 96 ff ff call 6c320 <_Unwind_RaiseException@plt> 72cbf: 89 34 24 mov %esi,(%esp) 72cc2: e8 c9 84 ff ff call 6b190 <__cxa_begin_catch@plt> 72cc7: e8 d4 b3 ff ff call 6e0a0 <_ZSt9terminatev@plt> 72ccc: 66 90 xchg %ax,%ax 72cce: 66 90 xchg %ax,%ax Note how the program is actually using %edi, and not %di, to store the second argument. This is the problem here. GDB will basically read the probe argument, then read the contents of %di, and then cast this value to uint32_t, which causes the wrong value to be obtained. In the gdb.base/stap-probe.exp case, this makes GDB read the wrong memory location, and not be able to display a test string. In Andrew's example, this causes GDB to actually stop at a "catch throw" when it should actually have *not* stopped. After some discussion with Frank Eigler and Jakub Jelinek, it was decided that this bug should be fixed on the client side (i.e., the program that actually reads the probes), and this is why I'm proposing this patch. The idea is simple: we will have a gdbarch method, which, for now, is only used by i386. The generic code that deals with register operands on gdb/stap-probe.c will call this method if it exists, passing the current parse information, the register name and its number. The i386 method will then verify if the register size is greater or equal than the size reported by the stap probe (the "4@" part). If it is, we're fine. Otherwise, it will check if we're dealing with any of the "extendable" registers (like ax, bx, si, di, sp, etc.). If we are, it will change the register name to include the "e" prefix. I have tested the patch here in many scenarios, and it fixes Andrew's bug and also the regressions I mentioned before, on gdb.base/stap-probe.exp. No regressions where found on other tests. Comments? gdb/ChangeLog: 2019-06-27 Sergio Durigan Junior <sergiodj@redhat.com> PR breakpoints/24541 * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh: Add 'stap_adjust_register'. * i386-tdep.c: Include '<unordered_set>'. (i386_stap_adjust_register): New function. (i386_elf_init_abi): Register 'i386_stap_adjust_register'. * stap-probe.c (stap_parse_register_operand): Call 'gdbarch_stap_adjust_register'.
2019-06-26 23:34:50 +02:00
extern void set_gdbarch_stap_adjust_register (struct gdbarch *gdbarch, gdbarch_stap_adjust_register_ftype *stap_adjust_register);
/* DTrace related functions.
The expression to compute the NARTGth+1 argument to a DTrace USDT probe.
NARG must be >= 0. */
extern int gdbarch_dtrace_parse_probe_argument_p (struct gdbarch *gdbarch);
typedef void (gdbarch_dtrace_parse_probe_argument_ftype) (struct gdbarch *gdbarch, struct expr_builder *builder, int narg);
extern void gdbarch_dtrace_parse_probe_argument (struct gdbarch *gdbarch, struct expr_builder *builder, int narg);
extern void set_gdbarch_dtrace_parse_probe_argument (struct gdbarch *gdbarch, gdbarch_dtrace_parse_probe_argument_ftype *dtrace_parse_probe_argument);
/* True if the given ADDR does not contain the instruction sequence
corresponding to a disabled DTrace is-enabled probe. */
extern int gdbarch_dtrace_probe_is_enabled_p (struct gdbarch *gdbarch);
typedef int (gdbarch_dtrace_probe_is_enabled_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
extern int gdbarch_dtrace_probe_is_enabled (struct gdbarch *gdbarch, CORE_ADDR addr);
extern void set_gdbarch_dtrace_probe_is_enabled (struct gdbarch *gdbarch, gdbarch_dtrace_probe_is_enabled_ftype *dtrace_probe_is_enabled);
/* Enable a DTrace is-enabled probe at ADDR. */
extern int gdbarch_dtrace_enable_probe_p (struct gdbarch *gdbarch);
typedef void (gdbarch_dtrace_enable_probe_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
extern void gdbarch_dtrace_enable_probe (struct gdbarch *gdbarch, CORE_ADDR addr);
extern void set_gdbarch_dtrace_enable_probe (struct gdbarch *gdbarch, gdbarch_dtrace_enable_probe_ftype *dtrace_enable_probe);
/* Disable a DTrace is-enabled probe at ADDR. */
extern int gdbarch_dtrace_disable_probe_p (struct gdbarch *gdbarch);
typedef void (gdbarch_dtrace_disable_probe_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
extern void gdbarch_dtrace_disable_probe (struct gdbarch *gdbarch, CORE_ADDR addr);
extern void set_gdbarch_dtrace_disable_probe (struct gdbarch *gdbarch, gdbarch_dtrace_disable_probe_ftype *dtrace_disable_probe);
/* True if the list of shared libraries is one and only for all
processes, as opposed to a list of shared libraries per inferior.
This usually means that all processes, although may or may not share
an address space, will see the same set of symbols at the same
addresses. */
extern int gdbarch_has_global_solist (struct gdbarch *gdbarch);
extern void set_gdbarch_has_global_solist (struct gdbarch *gdbarch, int has_global_solist);
/* On some targets, even though each inferior has its own private
address space, the debug interface takes care of making breakpoints
visible to all address spaces automatically. For such cases,
this property should be set to true. */
extern int gdbarch_has_global_breakpoints (struct gdbarch *gdbarch);
extern void set_gdbarch_has_global_breakpoints (struct gdbarch *gdbarch, int has_global_breakpoints);
2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> Add base multi-executable/process support to GDB. gdb/ * Makefile.in (SFILES): Add progspace.c. (COMMON_OBS): Add progspace.o. * progspace.h: New. * progspace.c: New. * breakpoint.h (struct bp_target_info) <placed_address_space>: New field. (struct bp_location) <pspace>: New field. (struct breakpoint) <pspace>: New field. (bpstat_stop_status, breakpoint_here_p) (moribund_breakpoint_here_p, breakpoint_inserted_here_p) (regular_breakpoint_inserted_here_p) (software_breakpoint_inserted_here_p, breakpoint_thread_match) (set_default_breakpoint): Adjust prototypes. (remove_breakpoints_pid, breakpoint_program_space_exit): Declare. (insert_single_step_breakpoint, deprecated_insert_raw_breakpoint): Adjust prototypes. * breakpoint.c (executing_startup): Delete. (default_breakpoint_sspace): New. (breakpoint_restore_shadows): Skip if the address space doesn't match. (update_watchpoint): Record the frame's program space in the breakpoint location. (insert_bp_location): Record the address space in target_info. Adjust to pass the symbol space to solib_name_from_address. (breakpoint_program_space_exit): New. (insert_breakpoint_locations): Switch the symbol space and thread when inserting breakpoints. Don't insert breakpoints in a vfork parent waiting for vfork done if we're not attached to the vfork child. (remove_breakpoints_pid): New. (reattach_breakpoints): Switch to a thread of PID. Ignore breakpoints of other symbol spaces. (create_internal_breakpoint): Store the symbol space in the sal. (create_longjmp_master_breakpoint): Iterate over all symbol spaces. (update_breakpoints_after_exec): Ignore breakpoints for other symbol spaces. (remove_breakpoint): Rename to ... (remove_breakpoint_1): ... this. Pass the breakpoints symbol space to solib_name_from_address. (remove_breakpoint): New. (mark_breakpoints_out): Ignore breakpoints from other symbol spaces. (breakpoint_init_inferior): Ditto. (breakpoint_here_p): Add an address space argument and adjust to use breakpoint_address_match. (moribund_breakpoint_here_p): Ditto. (regular_breakpoint_inserted_here_p): Ditto. (breakpoint_inserted_here_p): Ditto. (software_breakpoint_inserted_here_p): Ditto. (breakpoint_thread_match): Ditto. (bpstat_check_location): Ditto. (bpstat_stop_status): Ditto. (print_breakpoint_location): If there's a location to print, switch the current symbol space. (print_one_breakpoint_location): Add `allflag' argument. (print_one_breakpoint): Ditto. Adjust. (do_captured_breakpoint_query): Adjust. (breakpoint_1): Adjust. (breakpoint_has_pc): Also match the symbol space. (describe_other_breakpoints): Add a symbol space argument and adjust. (set_default_breakpoint): Add a symbol space argument. Set default_breakpoint_sspace. (breakpoint_address_match): New. (check_duplicates_for): Add an address space argument, and adjust. (set_raw_breakpoint): Record the symbol space in the location and in the breakpoint. (set_longjmp_breakpoint): Skip longjmp master breakpoints from other symbol spaces. (remove_thread_event_breakpoints, remove_solib_event_breakpoints) (disable_breakpoints_in_shlibs): Skip breakpoints from other symbol spaces. (disable_breakpoints_in_unloaded_shlib): Match symbol spaces. (create_catchpoint): Set the symbol space in the sal. (disable_breakpoints_before_startup): Skip breakpoints from other symbol spaces. Set executing_startup in the current symbol space. (enable_breakpoints_after_startup): Clear executing_startup in the current symbol space. Skip breakpoints from other symbol spaces. (clone_momentary_breakpoint): Also copy the symbol space. (add_location_to_breakpoint): Set the location's symbol space. (bp_loc_is_permanent): Switch thread and symbol space. (create_breakpoint): Adjust. (expand_line_sal_maybe): Expand comment to mention symbol spaces. Switch thread and symbol space when reading memory. (parse_breakpoint_sals): Set the symbol space in the sal. (break_command_really): Ditto. (skip_prologue_sal): Switch and space. (resolve_sal_pc): Ditto. (watch_command_1): Record the symbol space in the sal. (create_ada_exception_breakpoint): Adjust. (clear_command): Adjust. Match symbol spaces. (update_global_location_list): Use breakpoint_address_match. (breakpoint_re_set_one): Switch thread and space. (breakpoint_re_set): Save symbol space. (breakpoint_re_set_thread): Also reset the symbol space. (deprecated_insert_raw_breakpoint): Add an address space argument. Adjust. (insert_single_step_breakpoint): Ditto. (single_step_breakpoint_inserted_here_p): Ditto. (clear_syscall_counts): New. (_initialize_breakpoint): Install it as inferior_exit observer. * exec.h: Include "progspace.h". (exec_bfd, exec_bfd_mtime): New defines. (exec_close): Declare. * exec.c: Include "gdbthread.h" and "progspace.h". (exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete. (using_exec_ops): New. (exec_close_1): Rename to exec_close, and make public. (exec_close): Rename to exec_close_1, and adjust all callers. Add description. Remove target sections and close executables from all program spaces. (exec_file_attach): Add comment. (add_target_sections): Check on `using_exec_ops' to check if the target should be pushed. (remove_target_sections): Only unpush the target if there are no more target sections in any symbol space. * gdbcore.h: Include "exec.h". (exec_bfd, exec_bfd_mtime): Remove declarations. * frame.h (get_frame_program_space, get_frame_address_space) (frame_unwind_program_space): Declare. * frame.c (struct frame_info) <pspace, aspace>: New fields. (create_sentinel_frame): Add program space argument. Set the pspace and aspace fields of the frame object. (get_current_frame, create_new_frame): Adjust. (get_frame_program_space): New. (frame_unwind_program_space): New. (get_frame_address_space): New. * stack.c (print_frame_info): Adjust. (print_frame): Use the frame's program space. * gdbthread.h (any_live_thread_of_process): Declare. * thread.c (any_live_thread_of_process): New. (switch_to_thread): Switch the program space as well. (restore_selected_frame): Don't warn if trying to restore frame level 0. * inferior.h: Include "progspace.h". (detach_fork): Declare. (struct inferior) <removable, aspace, pspace> <vfork_parent, vfork_child, pending_detach> <waiting_for_vfork_done>: New fields. <terminal_info>: Remove field. <data, num_data>: New fields. (register_inferior_data, register_inferior_data_with_cleanup) (clear_inferior_data, set_inferior_data, inferior_data): Declare. (exit_inferior, exit_inferior_silent, exit_inferior_num_silent) (inferior_appeared): Declare. (find_inferior_pid): Typo. (find_inferior_id, find_inferior_for_program_space): Declare. (set_current_inferior, save_current_inferior, prune_inferiors) (number_of_inferiors): Declare. (inferior_list): Declare. * inferior.c: Include "gdbcore.h" and "symfile.h". (inferior_list): Make public. (delete_inferior_1): Always delete thread silently. (find_inferior_id): Make public. (current_inferior_): New. (current_inferior): Use it. (set_current_inferior): New. (restore_inferior): New. (save_current_inferior): New. (free_inferior): Free the per-inferior data. (add_inferior_silent): Allocate per-inferior data. Call inferior_appeared. (delete_threads_of_inferior): New. (delete_inferior_1): Adjust interface to take an inferior pointer. (delete_inferior): Adjust. (delete_inferior_silent): Adjust. (exit_inferior_1): New. (exit_inferior): New. (exit_inferior_silent): New. (exit_inferior_num_silent): New. (detach_inferior): Adjust. (inferior_appeared): New. (discard_all_inferiors): Adjust. (find_inferior_id): Make public. Assert pid is not zero. (find_inferior_for_program_space): New. (have_inferiors): Check if we have any inferior with pid not zero. (have_live_inferiors): Go over all pushed targets looking for process_stratum. (prune_inferiors): New. (number_of_inferiors): New. (print_inferior): Add executable column. Print vfork parent/child relationships. (inferior_command): Adjust to cope with not running inferiors. (remove_inferior_command): New. (add_inferior_command): New. (clone_inferior_command): New. (struct inferior_data): New. (struct inferior_data_registration): New. (struct inferior_data_registry): New. (inferior_data_registry): New. (register_inferior_data_with_cleanup): New. (register_inferior_data): New. (inferior_alloc_data): New. (inferior_free_data): New. (clear_inferior_data): New. (set_inferior_data): New. (inferior_data): New. (initialize_inferiors): New. (_initialize_inferiors): Register "add-inferior", "remove-inferior" and "clone-inferior" commands. * objfiles.h: Include "progspace.h". (struct objfile) <pspace>: New field. (symfile_objfile, object_files): Don't declare. (ALL_PSPACE_OBJFILES): New. (ALL_PSPACE_OBJFILES_SAFE): New. (ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust. (ALL_PSPACE_SYMTABS): New. (ALL_PRIMARY_SYMTABS): Adjust. (ALL_PSPACE_PRIMARY_SYMTABS): New. (ALL_PSYMTABS): Adjust. (ALL_PSPACE_PSYMTABS): New. * objfiles.c (object_files, symfile_objfile): Delete. (struct objfile_sspace_info): New. (objfiles_pspace_data): New. (objfiles_pspace_data_cleanup): New. (get_objfile_pspace_data): New. (objfiles_changed_p): Delete. (allocate_objfile): Set the objfile's program space. Adjust to reference objfiles_changed_p in pspace data. (free_objfile): Adjust to reference objfiles_changed_p in pspace data. (objfile_relocate): Ditto. (update_section_map): Add pspace argument. Adjust to iterate over objfiles in the passed in pspace. (find_pc_section): Delete sections and num_sections statics. Adjust to refer to program space's objfiles_changed_p. Adjust to refer to sections and num_sections store in the objfile's pspace data. (objfiles_changed): Adjust to reference objfiles_changed_p in pspace data. (_initialize_objfiles): New. * linespec.c (decode_all_digits, decode_dollar): Set the sal's program space. * source.c (current_source_pspace): New. (get_current_source_symtab_and_line): Set the sal's program space. (set_current_source_symtab_and_line): Set current_source_pspace. (select_source_symtab): Ditto. Use ALL_OBJFILES. (forget_cached_source_info): Iterate over all program spaces. * symfile.c (clear_symtab_users): Adjust. * symmisc.c (print_symbol_bcache_statistics): Iterate over all program spaces. (print_objfile_statistics): Ditto. (maintenance_print_msymbols): Ditto. (maintenance_print_objfiles): Ditto. (maintenance_info_symtabs): Ditto. (maintenance_info_psymtabs): Ditto. * symtab.h (SYMTAB_PSPACE): New. (struct symtab_and_line) <pspace>: New field. * symtab.c (init_sal): Clear the sal's program space. (find_pc_sect_symtab): Set the sal's program space. Switch thread and space. (append_expanded_sal): Add program space argument. Iterate over all program spaces. (expand_line_sal): Iterate over all program spaces. Switch program space. * target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New. (struct target_ops) <to_thread_address_space>: New field. (target_thread_address_space): Define. * target.c (target_detach): Only remove breakpoints from the inferior we're detaching. (target_thread_address_space): New. * defs.h (initialize_progspace): Declare. * top.c (gdb_init): Call it. * solist.h (struct so_list) <sspace>: New field. * solib.h (struct program_space): Forward declare. (solib_name_from_address): Adjust prototype. * solib.c (so_list_head): Replace with a macro referencing the program space. (update_solib_list): Set the so's program space. (solib_name_from_address): Add a program space argument and adjust. * solib-svr4.c (struct svr4_info) <pid>: Delete field. <interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low> <interp_plt_sect_high>: New fields. (svr4_info_p, svr4_info): Delete. (solib_svr4_sspace_data): New. (get_svr4_info): Rewrite. (svr4_sspace_data_cleanup): New. (open_symbol_file_object): Adjust. (svr4_default_sos): Adjust. (svr4_fetch_objfile_link_map): Adjust. (interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low) (interp_plt_sect_high): Delete. (svr4_in_dynsym_resolve_code): Adjust. (enable_break): Adjust. (svr4_clear_solib): Revert bit that removed the svr4_info here, and reinstate clearing debug_base, debug_loader_offset_p, debug_loader_offset and debug_loader_name. (_initialize_svr4_solib): Register solib_svr4_pspace_data. Don't install an inferior_exit observer anymore. * printcmd.c (struct display) <pspace>: New field. (display_command): Set the display's sspace. (do_one_display): Match the display's sspace. (display_uses_solib_p): Ditto. * linux-fork.c (detach_fork): Moved to infrun.c. (_initialize_linux_fork): Moved "detach-on-fork" command to infrun.c. * infrun.c (detach_fork): Moved from linux-fork.c. (proceed_after_vfork_done): New. (handle_vfork_child_exec_or_exit): New. (follow_exec_mode_replace, follow_exec_mode_keep) (follow_exec_mode_names, follow_exec_mode_string) (show_follow_exec_mode_string): New. (follow_exec): New. Reinstate the mark_breakpoints_out call. Remove shared libraries before attaching new executable. If user wants to keep the inferior, keep it. (displaced_step_fixup): Adjust to pass an address space to the breakpoints module. (resume): Ditto. (clear_proceed_status): In all-stop mode, always clear the proceed status of all threads. (prepare_to_proceed): Adjust to pass an address space to the breakpoints module. (proceed): Ditto. (adjust_pc_after_break): Ditto. (handle_inferior_event): When handling a process exit, switch the program space to the inferior's that had exited. Call handle_vfork_child_exec_or_exit. Adjust to pass an address space to the breakpoints module. In non-stop mode, when following a fork and detach-fork is off, also resume the other branch. Handle TARGET_WAITKIND_VFORK_DONE. Set the program space in sals. (normal_stop): Prune inferiors. (_initialize_infrun): Install the new "follow-exec-mode" command. "detach-on-fork" moved here. * regcache.h (get_regcache_aspace): Declare. * regcache.c (struct regcache) <aspace>: New field. (regcache_xmalloc): Clear the aspace. (get_regcache_aspace): New. (regcache_cpy): Copy the aspace field. (regcache_cpy_no_passthrough): Ditto. (get_thread_regcache): Fetch the thread's address space from the target, and store it in the regcache. * infcall.c (call_function_by_hand): Set the sal's pspace. * arch-utils.c (default_has_shared_address_space): New. * arch-utils.h (default_has_shared_address_space): Declare. * gdbarch.sh (has_shared_address_space): New. * gdbarch.h, gdbarch.c: Regenerate. * linux-tdep.c: Include auxv.h, target.h, elf/common.h. (linux_has_shared_address_space): New. (_initialize_linux_tdep): Declare. * arm-tdep.c (arm_software_single_step): Pass the frame's address space to insert_single_step_breakpoint. * arm-linux-tdep.c (arm_linux_software_single_step): Pass the frame's pspace to breakpoint functions. * cris-tdep.c (crisv32_single_step_through_delay): Ditto. (cris_software_single_step): Ditto. * mips-tdep.c (deal_with_atomic_sequence): Add frame argument. Pass the frame's pspace to breakpoint functions. (mips_software_single_step): Adjust. (mips_single_step_through_delay): Adjust. * rs6000-aix-tdep.c (rs6000_software_single_step): Adjust. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust. * solib-irix.c (enable_break): Adjust to pass the current frame's address space to breakpoint functions. * sparc-tdep.c (sparc_software_single_step): Ditto. * spu-tdep.c (spu_software_single_step): Ditto. * alpha-tdep.c (alpha_software_single_step): Ditto. * record.c (record_wait): Adjust to pass an address space to the breakpoints module. * fork-child.c (fork_inferior): Set the new inferior's program and address spaces. * inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program and address spaces. (inf_ptrace_attach): Set the inferior's program and address spaces. * linux-nat.c: Include "solib.h". (linux_child_follow_fork): Manage parent and child's program and address spaces. Clone the parent's program space if necessary. Don't wait for the vfork to be done here. Refuse to resume if following the vfork parent while leaving the child stopped. (resume_callback): Don't resume a vfork parent. (linux_nat_resume): Also check for pending events in the lp->waitstatus field. (linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE events to the core. (stop_wait_callback): Don't wait for SIGSTOP on vfork parents. (cancel_breakpoint): Adjust. * linux-thread-db.c (thread_db_wait): Don't remove thread event breakpoints here. (thread_db_mourn_inferior): Don't mark breakpoints out here. Remove thread event breakpoints after mourning. * corelow.c: Include progspace.h. (core_open): Set the inferior's program and address spaces. * remote.c (remote_add_inferior): Set the new inferior's program and address spaces. (remote_start_remote): Update address spaces. (extended_remote_create_inferior_1): Don't init the thread list if we already debugging other inferiors. * darwin-nat.c (darwin_attach): Set the new inferior's program and address spaces. * gnu-nat.c (gnu_attach): Ditto. * go32-nat.c (go32_create_inferior): Ditto. * inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto. * monitor.c (monitor_open): Ditto. * nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto. * procfs.c (do_attach): Ditto. * windows-nat.c (do_initial_windows_stuff): Ditto. * inflow.c (inferior_process_group) (terminal_init_inferior_with_pgrp, terminal_inferior, (terminal_ours_1, inflow_inferior_exit, copy_terminal_info) (child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust to use per-inferior data instead of inferior->terminal_info. (inflow_inferior_data): New. (inflow_new_inferior): Delete. (inflow_inferior_data_cleanup): New. (get_inflow_inferior_data): New. * mi/mi-interp.c (mi_new_inferior): Rename to... (mi_inferior_appeared): ... this. (mi_interpreter_init): Adjust. * tui/tui-disasm.c: Include "progspace.h". (tui_set_disassem_content): Pass an address space to breakpoint_here_p. * NEWS: Mention multi-program debugging support. Mention new commands "add-inferior", "clone-inferior", "remove-inferior", "maint info program-spaces", and new option "set follow-exec-mode". 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * observer.texi (new_inferior): Rename to... (inferior_appeared): ... this. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/testsuite/ * gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork". * gdb.base/foll-exec.exp: Adjust to expect a process id before "Executing new program". * gdb.base/foll-fork.exp: Adjust to spell out "follow-fork". * gdb.base/multi-forks.exp: Ditto. Adjust to the inferior being left listed after having been killed. * gdb.base/attach.exp: Adjust to spell out "symbol-file". * gdb.base/maint.exp: Adjust test. * Makefile.in (ALL_SUBDIRS): Add gdb.multi. * gdb.multi/Makefile.in: New. * gdb.multi/base.exp: New. * gdb.multi/goodbye.c: New. * gdb.multi/hangout.c: New. * gdb.multi/hello.c: New. * gdb.multi/bkpt-multi-exec.c: New. * gdb.multi/bkpt-multi-exec.exp: New. * gdb.multi/crashme.c: New. 2009-10-19 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> gdb/doc/ * gdb.texinfo (Inferiors): Rename node to ... (Inferiors and Programs): ... this. Mention running multiple programs in the same debug session. <info inferiors>: Mention the new 'Executable' column if "info inferiors". Update examples. Document the "add-inferior", "clone-inferior", "remove-inferior" and "maint info program-spaces" commands. (Process): Rename node to... (Forks): ... this. Document "set|show follow-exec-mode".
2009-10-19 11:51:43 +02:00
/* True if inferiors share an address space (e.g., uClinux). */
typedef int (gdbarch_has_shared_address_space_ftype) (struct gdbarch *gdbarch);
extern int gdbarch_has_shared_address_space (struct gdbarch *gdbarch);
extern void set_gdbarch_has_shared_address_space (struct gdbarch *gdbarch, gdbarch_has_shared_address_space_ftype *has_shared_address_space);
Add fast tracepoints. * arch-utils.h (default_fast_tracepoint_valid_at): Declare. * arch-utils.c (default_fast_tracepoint_valid_at): New function. * breakpoint.h (enum bptype): Add bp_fast_tracepoint. * breakpoint.c (tracepoint_type): New function. (ALL_TRACEPOINTS): Use it. (should_be_inserted): Ditto. (bpstat_check_location): Ditto. (print_one_breakpoint_location): Ditto. (user_settable_breakpoint): Ditto. (set_breakpoint_location_function): Ditto. (disable_breakpoints_in_shlibs): Ditto. (delete_trace_command): Ditto. (print_it_typical): Add bp_fast_tracepoint case. (bpstat_what): Ditto. (print_one_breakpoint_location): Ditto. (allocate_bp_location): Ditto. (mention): Ditto. (breakpoint_re_set_one): Ditto. (disable_command): Ditto. (enable_command): Ditto. (check_fast_tracepoint_sals): New function. (break_command_really): Call it. (ftrace_command): New function. (_initialize_breakpoint): Add ftrace command. * gdbarch.sh (fast_tracepoint_valid_at): New. * gdbarch.h, gdbarch.c: Regenerate. * i386-tdep.c (i386_fast_tracepoint_valid_at): New function. (i386_gdbarch_init): Use it. * remote.c (struct remote_state): New field fast_tracepoints. (PACKET_FastTracepoints): New packet config type. (remote_fast_tracepoint_feature): New function. (remote_protocol_features): Add FastTracepoints. (remote_supports_fast_tracepoints): New function. (_initialize_remote): Add FastTracepoints. * tracepoint.c (download_tracepoint): Add fast tracepoint option. * NEWS: Mention fast tracepoints. * gdb.texinfo (Create and Delete Tracepoints): Describe fast tracepoints. (Tracepoint Packets): Describe remote protocol for fast tracepoints. * gdb.trace/tracecmd.exp: Test ftrace.
2010-01-06 05:20:27 +01:00
/* True if a fast tracepoint can be set at an address. */
typedef int (gdbarch_fast_tracepoint_valid_at_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr, std::string *msg);
extern int gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, std::string *msg);
Add fast tracepoints. * arch-utils.h (default_fast_tracepoint_valid_at): Declare. * arch-utils.c (default_fast_tracepoint_valid_at): New function. * breakpoint.h (enum bptype): Add bp_fast_tracepoint. * breakpoint.c (tracepoint_type): New function. (ALL_TRACEPOINTS): Use it. (should_be_inserted): Ditto. (bpstat_check_location): Ditto. (print_one_breakpoint_location): Ditto. (user_settable_breakpoint): Ditto. (set_breakpoint_location_function): Ditto. (disable_breakpoints_in_shlibs): Ditto. (delete_trace_command): Ditto. (print_it_typical): Add bp_fast_tracepoint case. (bpstat_what): Ditto. (print_one_breakpoint_location): Ditto. (allocate_bp_location): Ditto. (mention): Ditto. (breakpoint_re_set_one): Ditto. (disable_command): Ditto. (enable_command): Ditto. (check_fast_tracepoint_sals): New function. (break_command_really): Call it. (ftrace_command): New function. (_initialize_breakpoint): Add ftrace command. * gdbarch.sh (fast_tracepoint_valid_at): New. * gdbarch.h, gdbarch.c: Regenerate. * i386-tdep.c (i386_fast_tracepoint_valid_at): New function. (i386_gdbarch_init): Use it. * remote.c (struct remote_state): New field fast_tracepoints. (PACKET_FastTracepoints): New packet config type. (remote_fast_tracepoint_feature): New function. (remote_protocol_features): Add FastTracepoints. (remote_supports_fast_tracepoints): New function. (_initialize_remote): Add FastTracepoints. * tracepoint.c (download_tracepoint): Add fast tracepoint option. * NEWS: Mention fast tracepoints. * gdb.texinfo (Create and Delete Tracepoints): Describe fast tracepoints. (Tracepoint Packets): Describe remote protocol for fast tracepoints. * gdb.trace/tracecmd.exp: Test ftrace.
2010-01-06 05:20:27 +01:00
extern void set_gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at);
/* Guess register state based on tracepoint location. Used for tracepoints
where no registers have been collected, but there's only one location,
allowing us to guess the PC value, and perhaps some other registers.
On entry, regcache has all registers marked as unavailable. */
typedef void (gdbarch_guess_tracepoint_registers_ftype) (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr);
extern void gdbarch_guess_tracepoint_registers (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr);
extern void set_gdbarch_guess_tracepoint_registers (struct gdbarch *gdbarch, gdbarch_guess_tracepoint_registers_ftype *guess_tracepoint_registers);
gdb 2010-03-05 Corinna Vinschen <vinschen@redhat.com> Tom Tromey <tromey@redhat.com> * utils.c (host_char_to_target): Add 'gdbarch' argument. (parse_escape): Likewise. * python/py-utils.c (unicode_to_target_string): Update. (unicode_to_target_python_string): Update. (target_string_to_unicode): Update. * printcmd.c (printf_command): Update. * p-exp.y (yylex): Update. * objc-exp.y (yylex): Update. * mi/mi-parse.c: Include charset.h. (mi_parse_escape): New function. (mi_parse_argv): Use it. * jv-exp.y (yylex): Update. * i386-cygwin-tdep.c (i386_cygwin_auto_wide_charset): New function. (i386_cygwin_init_abi): Call set_gdbarch_auto_wide_charset. * gdbarch.sh (auto_charset, auto_wide_charset): New. * gdbarch.c: Rebuild. * gdbarch.h: Rebuild. * defs.h (parse_escape): Update. * cli/cli-setshow.c: Include arch-utils.h. (do_setshow_command): Update. * cli/cli-cmds.c (echo_command): Update. * charset.h (target_charset, target_wide_charset): Update. * charset.c: Include arch-utils.h. (target_charset_name): Default to "auto". (target_wide_charset_name): Likewise. (show_target_charset_name): Handle "auto". (show_target_wide_charset_name): Likewise. (be_le_arch): New global. (set_be_le_names): Add 'gdbarch' argument. (validate): Likewise. Don't call set_be_le_names. (set_charset_sfunc, set_host_charset_sfunc) (set_target_charset_sfunc, set_target_wide_charset_sfunc): Update. (target_charset): Add 'gdbarch' argument. (target_wide_charset): Likewise. Remove 'byte_order' argument. (auto_target_charset_name): New global. (default_auto_charset, default_auto_wide_charset): New functions. (_initialize_charset): Set auto_target_charset_name. Allow "auto" for target charsets. Copy result of nl_langinfo. Use GetACP if USE_WIN32API. * c-lang.c (charset_for_string_type): Add 'gdbarch' argument, remove 'byte_order' argument. Update. (classify_type): Likewise. (c_emit_char): Update. (c_printchar): Update. (c_printstr): Update. (c_get_string): Update. (evaluate_subexp_c): Update. * arch-utils.h (default_auto_charset, default_auto_wide_charset): Declare. * python/python.c (gdbpy_target_charset): New function. (gdbpy_target_wide_charset): Likewise. (GdbMethods): Update. * NEWS: Update. gdb/doc * gdb.texinfo (Basic Python): Document target_charset and target_wide_charset. gdb/testsuite * gdb.python/py-prettyprint.py (pp_nullstr.to_string): Use gdb.target_charset. (pp_ns.to_string): Likewise.
2010-03-05 21:18:19 +01:00
/* Return the "auto" target charset. */
typedef const char * (gdbarch_auto_charset_ftype) (void);
extern const char * gdbarch_auto_charset (struct gdbarch *gdbarch);
extern void set_gdbarch_auto_charset (struct gdbarch *gdbarch, gdbarch_auto_charset_ftype *auto_charset);
/* Return the "auto" target wide charset. */
typedef const char * (gdbarch_auto_wide_charset_ftype) (void);
extern const char * gdbarch_auto_wide_charset (struct gdbarch *gdbarch);
extern void set_gdbarch_auto_wide_charset (struct gdbarch *gdbarch, gdbarch_auto_wide_charset_ftype *auto_wide_charset);
/* If non-empty, this is a file extension that will be opened in place
of the file extension reported by the shared library list.
This is most useful for toolchains that use a post-linker tool,
where the names of the files run on the target differ in extension
compared to the names of the files GDB should load for debug info. */
extern const char * gdbarch_solib_symbols_extension (struct gdbarch *gdbarch);
extern void set_gdbarch_solib_symbols_extension (struct gdbarch *gdbarch, const char * solib_symbols_extension);
/* If true, the target OS has DOS-based file system semantics. That
is, absolute paths include a drive name, and the backslash is
considered a directory separator. */
extern int gdbarch_has_dos_based_file_system (struct gdbarch *gdbarch);
extern void set_gdbarch_has_dos_based_file_system (struct gdbarch *gdbarch, int has_dos_based_file_system);
/* Generate bytecodes to collect the return address in a frame.
Since the bytecodes run on the target, possibly with GDB not even
connected, the full unwinding machinery is not available, and
typically this function will issue bytecodes for one or more likely
places that the return address may be found. */
typedef void (gdbarch_gen_return_address_ftype) (struct gdbarch *gdbarch, struct agent_expr *ax, struct axs_value *value, CORE_ADDR scope);
extern void gdbarch_gen_return_address (struct gdbarch *gdbarch, struct agent_expr *ax, struct axs_value *value, CORE_ADDR scope);
extern void set_gdbarch_gen_return_address (struct gdbarch *gdbarch, gdbarch_gen_return_address_ftype *gen_return_address);
/* Implement the "info proc" command. */
extern int gdbarch_info_proc_p (struct gdbarch *gdbarch);
typedef void (gdbarch_info_proc_ftype) (struct gdbarch *gdbarch, const char *args, enum info_proc_what what);
extern void gdbarch_info_proc (struct gdbarch *gdbarch, const char *args, enum info_proc_what what);
extern void set_gdbarch_info_proc (struct gdbarch *gdbarch, gdbarch_info_proc_ftype *info_proc);
/* Implement the "info proc" command for core files. Noe that there
are two "info_proc"-like methods on gdbarch -- one for core files,
one for live targets. */
extern int gdbarch_core_info_proc_p (struct gdbarch *gdbarch);
typedef void (gdbarch_core_info_proc_ftype) (struct gdbarch *gdbarch, const char *args, enum info_proc_what what);
extern void gdbarch_core_info_proc (struct gdbarch *gdbarch, const char *args, enum info_proc_what what);
extern void set_gdbarch_core_info_proc (struct gdbarch *gdbarch, gdbarch_core_info_proc_ftype *core_info_proc);
New "iterate_over_objfiles_in_search_order" gdbarch method. This patch introduces the "iterate_over_objfiles_in_search_order" gdbarch method, as well as its default implementation, and converts the areas where it will matter to using this gdbarch method. The default method implementation is the only one installed, and the changes should have no functional impact in terms of behavior. This only paves the way for the architectures that will need their own version. gdb/ChangeLog: * gdbarch.sh: Add generation of "iterate_over_objfiles_in_search_order_cb_ftype" typedef in gdbarch.h. Add include of "objfiles.h" in gdbarch.c. (iterate_over_objfiles_in_search_order): New gdbarch method. * gdbarch.h, gdbarch.c: Regenerate. * objfiles.h (default_iterate_over_objfiles_in_search_order): Add declaration. * objfiles.c (default_iterate_over_objfiles_in_search_order): New function. * symtab.c (lookup_symbol_aux_objfile): New function, extracted out of lookup_symbol_aux_symtabs. (lookup_symbol_aux_symtabs): Replace extracted-out code by call to lookup_symbol_aux_objfile. (struct global_sym_lookup_data): New type. (lookup_symbol_global_iterator_cb): New function. (lookup_symbol_global): Search for symbol using gdbarch_iterate_over_objfiles_in_search_order and lookup_symbol_global_iterator_cb. * findvar.c (struct minsym_lookup_data): New type. (minsym_lookup_iterator_cb): New function. (default_read_var_value) [case LOC_UNRESOLVED]: Resolve the symbol's address via gdbarch_iterate_over_objfiles_in_search_order and minsym_lookup_iterator_cb.
2012-06-05 15:50:50 +02:00
/* Iterate over all objfiles in the order that makes the most sense
for the architecture to make global symbol searches.
CB is a callback function where OBJFILE is the objfile to be searched,
and CB_DATA a pointer to user-defined data (the same data that is passed
when calling this gdbarch method). The iteration stops if this function
returns nonzero.
CB_DATA is a pointer to some user-defined data to be passed to
the callback.
If not NULL, CURRENT_OBJFILE corresponds to the objfile being
inspected when the symbol search was requested. */
typedef void (gdbarch_iterate_over_objfiles_in_search_order_ftype) (struct gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype *cb, void *cb_data, struct objfile *current_objfile);
extern void gdbarch_iterate_over_objfiles_in_search_order (struct gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype *cb, void *cb_data, struct objfile *current_objfile);
extern void set_gdbarch_iterate_over_objfiles_in_search_order (struct gdbarch *gdbarch, gdbarch_iterate_over_objfiles_in_search_order_ftype *iterate_over_objfiles_in_search_order);
/* Ravenscar arch-dependent ops. */
extern struct ravenscar_arch_ops * gdbarch_ravenscar_ops (struct gdbarch *gdbarch);
extern void set_gdbarch_ravenscar_ops (struct gdbarch *gdbarch, struct ravenscar_arch_ops * ravenscar_ops);
/* Return non-zero if the instruction at ADDR is a call; zero otherwise. */
typedef int (gdbarch_insn_is_call_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
extern int gdbarch_insn_is_call (struct gdbarch *gdbarch, CORE_ADDR addr);
extern void set_gdbarch_insn_is_call (struct gdbarch *gdbarch, gdbarch_insn_is_call_ftype *insn_is_call);
/* Return non-zero if the instruction at ADDR is a return; zero otherwise. */
typedef int (gdbarch_insn_is_ret_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
extern int gdbarch_insn_is_ret (struct gdbarch *gdbarch, CORE_ADDR addr);
extern void set_gdbarch_insn_is_ret (struct gdbarch *gdbarch, gdbarch_insn_is_ret_ftype *insn_is_ret);
/* Return non-zero if the instruction at ADDR is a jump; zero otherwise. */
typedef int (gdbarch_insn_is_jump_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
extern int gdbarch_insn_is_jump (struct gdbarch *gdbarch, CORE_ADDR addr);
extern void set_gdbarch_insn_is_jump (struct gdbarch *gdbarch, gdbarch_insn_is_jump_ftype *insn_is_jump);
/* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
Return 0 if *READPTR is already at the end of the buffer.
Return -1 if there is insufficient buffer for a whole entry.
Return 1 if an entry was read into *TYPEP and *VALP. */
extern int gdbarch_auxv_parse_p (struct gdbarch *gdbarch);
typedef int (gdbarch_auxv_parse_ftype) (struct gdbarch *gdbarch, gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp);
extern int gdbarch_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp);
extern void set_gdbarch_auxv_parse (struct gdbarch *gdbarch, gdbarch_auxv_parse_ftype *auxv_parse);
/* Print the description of a single auxv entry described by TYPE and VAL
to FILE. */
typedef void (gdbarch_print_auxv_entry_ftype) (struct gdbarch *gdbarch, struct ui_file *file, CORE_ADDR type, CORE_ADDR val);
extern void gdbarch_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file, CORE_ADDR type, CORE_ADDR val);
extern void set_gdbarch_print_auxv_entry (struct gdbarch *gdbarch, gdbarch_print_auxv_entry_ftype *print_auxv_entry);
/* Find the address range of the current inferior's vsyscall/vDSO, and
write it to *RANGE. If the vsyscall's length can't be determined, a
range with zero length is returned. Returns true if the vsyscall is
found, false otherwise. */
typedef int (gdbarch_vsyscall_range_ftype) (struct gdbarch *gdbarch, struct mem_range *range);
extern int gdbarch_vsyscall_range (struct gdbarch *gdbarch, struct mem_range *range);
extern void set_gdbarch_vsyscall_range (struct gdbarch *gdbarch, gdbarch_vsyscall_range_ftype *vsyscall_range);
/* Allocate SIZE bytes of PROT protected page aligned memory in inferior.
PROT has GDB_MMAP_PROT_* bitmask format.
Throw an error if it is not possible. Returned address is always valid. */
typedef CORE_ADDR (gdbarch_infcall_mmap_ftype) (CORE_ADDR size, unsigned prot);
extern CORE_ADDR gdbarch_infcall_mmap (struct gdbarch *gdbarch, CORE_ADDR size, unsigned prot);
extern void set_gdbarch_infcall_mmap (struct gdbarch *gdbarch, gdbarch_infcall_mmap_ftype *infcall_mmap);
compile: Use also inferior munmap Currently inferior memory is allocated by inferior mmap() but it is never deallocated; despite the injected objfile incl. its symbols is freed. This was intentional so that one can do for example: inferior: char *str = "foo"; GDB: (gdb) compile code str = "bar"; I believe later patches will be needed to introduce full control over keeping vs. discarding the injected module as being discussed in: compile: objfiles lifetime UI https://sourceware.org/ml/gdb/2015-04/msg00051.html Message-ID: <20150429135735.GA16974@host1.jankratochvil.net> https://sourceware.org/ml/gdb/2015-05/msg00007.html As decided by Phil it is better not to leak inferior pages as users can workaround the issue above for example by: (gdb) compile code str = strdup ("bar"); I have checked that in fact gdb/doc/ (written by Phil) already expects the injected code will be unmapped so that does not need to be changed: compile code int ff = 5; p = &ff; In this example, @code{p} would point to @code{ff} when the @code{compile} command is executing the source code provided to it. However, as variables in the (example) program persist with their assigned values, the variable @code{p} would point to an invalid location when the command exists. gdb/ChangeLog 2015-04-28 Jan Kratochvil <jan.kratochvil@redhat.com> * arch-utils.c (default_infcall_munmap): New. * arch-utils.h (default_infcall_munmap): New declaration. * compile/compile-object-load.c (struct munmap_list, munmap_list_add) (munmap_list_free, munmap_listp_free_cleanup): New. (struct setup_sections_data): Add field munmap_list_headp. (setup_sections): Call munmap_list_add. (compile_object_load): New variable munmap_list_head, initialize setup_sections_data.munmap_list_headp, return munmap_list_head. * compile/compile-object-load.h (struct munmap_list): New declaration. (struct compile_module): Add field munmap_list_head. (munmap_list_free): New declaration. * compile/compile-object-run.c (struct do_module_cleanup): Add field munmap_list_head. (do_module_cleanup): Call munmap_list_free. (compile_object_run): Pass munmap_list_head to do_module_cleanup. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (infcall_munmap): New. * linux-tdep.c (linux_infcall_munmap): New. (linux_init_abi): Install it. gdb/testsuite/ChangeLog 2015-04-28 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.compile/compile.exp (keep jit in memory): Rename to ... (do not keep jit in memory): ... this. (expect 5): Change it to ... (expect no 5): ... this.
2015-06-03 21:22:56 +02:00
/* Deallocate SIZE bytes of memory at ADDR in inferior from gdbarch_infcall_mmap.
Print a warning if it is not possible. */
typedef void (gdbarch_infcall_munmap_ftype) (CORE_ADDR addr, CORE_ADDR size);
extern void gdbarch_infcall_munmap (struct gdbarch *gdbarch, CORE_ADDR addr, CORE_ADDR size);
extern void set_gdbarch_infcall_munmap (struct gdbarch *gdbarch, gdbarch_infcall_munmap_ftype *infcall_munmap);
/* Return string (caller has to use xfree for it) with options for GCC
to produce code for this target, typically "-m64", "-m32" or "-m31".
These options are put before CU's DW_AT_producer compilation options so that
they can override it. Method may also return NULL. */
typedef char * (gdbarch_gcc_target_options_ftype) (struct gdbarch *gdbarch);
extern char * gdbarch_gcc_target_options (struct gdbarch *gdbarch);
extern void set_gdbarch_gcc_target_options (struct gdbarch *gdbarch, gdbarch_gcc_target_options_ftype *gcc_target_options);
add gnu_triplet_regexp gdbarch method gdb has to inform libcc1.so of the target being used, so that the correct compiler can be invoked. The compiler is invoked using the GNU configury triplet prefix, e.g., "x86_64-unknown-linux-gnu-gcc". In order for this to work we need to map the gdbarch to the GNU configury triplet arch. In most cases these are identical; however, the x86 family poses some problems, as the BFD arch names are quite different from the GNU triplet names. So, we introduce a new gdbarch method for this. A regular expression is used because there are various valid values for the arch prefix in the triplet. This patch also updates the osabi code to associate a regular expression with the OS ABI. I have only added a concrete value for Linux. Note that the "-gnu" part is optional, at least on Fedora it is omitted from the installed GCC executable's name. gdb/ChangeLog 2014-12-12 Tom Tromey <tromey@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> * osabi.h (osabi_triplet_regexp): Declare. * osabi.c (struct osabi_names): New. (gdb_osabi_names): Change type to struct osabi_names. Update values. (gdbarch_osabi_name): Update. (osabi_triplet_regexp): New function. (osabi_from_tdesc_string, _initialize_gdb_osabi): Update. * i386-tdep.c (i386_gnu_triplet_regexp): New method. (i386_elf_init_abi, i386_go32_init_abi, i386_gdbarch_init): Call set_gdbarch_gnu_triplet_regexp. * gdbarch.sh (gnu_triplet_regexp): New method. * gdbarch.c, gdbarch.h: Rebuild. * arch-utils.h (default_gnu_triplet_regexp): Declare. * arch-utils.c (default_gnu_triplet_regexp): New function.
2014-06-13 17:28:24 +02:00
/* Return a regular expression that matches names used by this
architecture in GNU configury triplets. The result is statically
allocated and must not be freed. The default implementation simply
returns the BFD architecture name, which is correct in nearly every
case. */
typedef const char * (gdbarch_gnu_triplet_regexp_ftype) (struct gdbarch *gdbarch);
extern const char * gdbarch_gnu_triplet_regexp (struct gdbarch *gdbarch);
extern void set_gdbarch_gnu_triplet_regexp (struct gdbarch *gdbarch, gdbarch_gnu_triplet_regexp_ftype *gnu_triplet_regexp);
/* Return the size in 8-bit bytes of an addressable memory unit on this
architecture. This corresponds to the number of 8-bit bytes associated to
each address in memory. */
typedef int (gdbarch_addressable_memory_unit_size_ftype) (struct gdbarch *gdbarch);
extern int gdbarch_addressable_memory_unit_size (struct gdbarch *gdbarch);
extern void set_gdbarch_addressable_memory_unit_size (struct gdbarch *gdbarch, gdbarch_addressable_memory_unit_size_ftype *addressable_memory_unit_size);
GDB: Add support for the new set/show disassembler-options commands. This commit adds support to GDB so that it can modify the disassembler-options value that is passed to the disassembler, similar to objdump's -M option. Currently, the only supported targets are ARM, PowerPC and S/390, but adding support for a new target(s) is not difficult. include/ * dis-asm.h (disasm_options_t): New typedef. (parse_arm_disassembler_option): Remove prototype. (set_arm_regname_option): Likewise. (get_arm_regnames): Likewise. (get_arm_regname_num_options): Likewise. (disassemble_init_s390): New prototype. (disassembler_options_powerpc): Likewise. (disassembler_options_arm): Likewise. (disassembler_options_s390): Likewise. (remove_whitespace_and_extra_commas): Likewise. (disassembler_options_cmp): Likewise. (next_disassembler_option): New inline function. (FOR_EACH_DISASSEMBLER_OPTION): New macro. opcodes/ * disassemble.c Include "safe-ctype.h". (disassemble_init_for_target): Handle s390 init. (remove_whitespace_and_extra_commas): New function. (disassembler_options_cmp): Likewise. * arm-dis.c: Include "libiberty.h". (NUM_ELEM): Delete. (regnames): Use long disassembler style names. Add force-thumb and no-force-thumb options. (NUM_ARM_REGNAMES): Rename from this... (NUM_ARM_OPTIONS): ...to this. Use ARRAY_SIZE. (get_arm_regname_num_options): Delete. (set_arm_regname_option): Likewise. (get_arm_regnames): Likewise. (parse_disassembler_options): Likewise. (parse_arm_disassembler_option): Rename from this... (parse_arm_disassembler_options): ...to this. Make static. Use new FOR_EACH_DISASSEMBLER_OPTION macro to scan over options. (print_insn): Use parse_arm_disassembler_options. (disassembler_options_arm): New function. (print_arm_disassembler_options): Handle updated regnames. * ppc-dis.c: Include "libiberty.h". (ppc_opts): Add "32" and "64" entries. (ppc_parse_cpu): Use ARRAY_SIZE and disassembler_options_cmp. (powerpc_init_dialect): Add break to switch statement. Use new FOR_EACH_DISASSEMBLER_OPTION macro. (disassembler_options_powerpc): New function. (print_ppc_disassembler_options): Use ARRAY_SIZE. Remove printing of "32" and "64". * s390-dis.c: Include "libiberty.h". (init_flag): Remove unneeded variable. (struct s390_options_t): New structure type. (options): New structure. (init_disasm): Rename from this... (disassemble_init_s390): ...to this. Add initializations for current_arch_mask and option_use_insn_len_bits_p. Remove init_flag. (print_insn_s390): Delete call to init_disasm. (disassembler_options_s390): New function. (print_s390_disassembler_options): Print using information from struct 'options'. * po/opcodes.pot: Regenerate. binutils/ * objdump.c (main): Use remove_whitespace_and_extra_commas. gdb/ * NEWS: Mention new set/show disassembler-options commands. * doc/gdb.texinfo: Document new set/show disassembler-options commands. * disasm.c: Include "arch-utils.h", "gdbcmd.h" and "safe-ctype.h". (prospective_options): New static variable. (gdb_disassembler::gdb_disassembler): Initialize m_di.disassembler_options. (gdb_buffered_insn_length_init_dis): Initilize di->disassembler_options. (get_disassembler_options): New function. (set_disassembler_options): Likewise. (set_disassembler_options_sfunc): Likewise. (show_disassembler_options_sfunc): Likewise. (disassembler_options_completer): Likewise. (_initialize_disasm): Likewise. * disasm.h (get_disassembler_options): New prototype. (set_disassembler_options): Likewise. * gdbarch.sh (gdbarch_disassembler_options): New variable. (gdbarch_verify_disassembler_options): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * arm-tdep.c (num_disassembly_options): Delete. (set_disassembly_style): Likewise. (arm_disassembler_options): New static variable. (set_disassembly_style_sfunc): Convert short style name into long option name. Call set_disassembler_options. (show_disassembly_style_sfunc): New function. (arm_gdbarch_init): Call set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. (_initialize_arm_tdep): Delete regnames variable and update callers. (arm_disassembler_options): Initialize. (disasm_options): New variable. (num_disassembly_options): Rename from this... (num_disassembly_styles): ...to this. Compute by scanning through disasm_options. (valid_disassembly_styles): Initialize using disasm_options. Remove calls to parse_arm_disassembler_option, get_arm_regnames and set_arm_regname_option. Pass show_disassembly_style_sfunc to the "disassembler" setshow command. * rs6000-tdep.c (powerpc_disassembler_options): New static variable. (rs6000_gdbarch_init): Call set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. * s390-tdep.c (s390_disassembler_options): New static variable. (s390_gdbarch_init):all set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. gdb/testsuite/ * gdb.arch/powerpc-power.exp: Delete test. * gdb.arch/powerpc-power.s: Likewise. * gdb.disasm/disassembler-options.exp: New test. * gdb.arch/powerpc-altivec.exp: Likewise. * gdb.arch/powerpc-altivec.s: Likewise. * gdb.arch/powerpc-altivec2.exp: Likewise. * gdb.arch/powerpc-altivec2.s: Likewise. * gdb.arch/powerpc-altivec3.exp: Likewise. * gdb.arch/powerpc-altivec3.s: Likewise. * gdb.arch/powerpc-power7.exp: Likewise. * gdb.arch/powerpc-power7.s: Likewise. * gdb.arch/powerpc-power8.exp: Likewise. * gdb.arch/powerpc-power8.s: Likewise. * gdb.arch/powerpc-power9.exp: Likewise. * gdb.arch/powerpc-power9.s: Likewise. * gdb.arch/powerpc-vsx.exp: Likewise. * gdb.arch/powerpc-vsx.s: Likewise. * gdb.arch/powerpc-vsx2.exp: Likewise. * gdb.arch/powerpc-vsx2.s: Likewise. * gdb.arch/powerpc-vsx3.exp: Likewise. * gdb.arch/powerpc-vsx3.s: Likewise. * gdb.arch/arm-disassembler-options.exp: Likewise. * gdb.arch/powerpc-disassembler-options.exp: Likewise. * gdb.arch/s390-disassembler-options.exp: Likewise.
2017-02-28 19:32:07 +01:00
/* Functions for allowing a target to modify its disassembler options. */
GDB PR tdep/8282: MIPS: Wire in `set disassembler-options' Implement MIPS target support for passing options to the disassembler, complementing commit 65b48a81404c ("GDB: Add support for the new set/show disassembler-options commands."). This includes options that expect an argument, so adjust the generic code and data structures used so as to handle such options. So as to give backends syntax flexibility no specific delimiter has been defined to separate options from their respective arguments, so it has to be included as the last character of the option name. Completion code however has not been adjusted and consequently option arguments cannot be completed at this time. Also the MIPS target has non-empty defaults for the options, so that ABI names for the general-purpose registers respect our `set mips abi ...' setting rather than always being determined from the ELF headers of the binary file selected. Handle these defaults as implicit options, never shown to the user and always prepended to the user-specified options, so that the latters can override the defaults. The resulting output for the MIPS target is as follows: (gdb) show disassembler-options The current disassembler options are '' The following disassembler options are supported for use with the 'set disassembler-options <option>[,<option>...]' command: no-aliases Use canonical instruction forms. msa Recognize MSA instructions. virt Recognize the virtualization ASE instructions. xpa Recognize the eXtended Physical Address (XPA) ASE instructions. ginv Recognize the Global INValidate (GINV) ASE instructions. gpr-names=ABI Print GPR names according to specified ABI. Default: based on binary being disassembled. fpr-names=ABI Print FPR names according to specified ABI. Default: numeric. cp0-names=ARCH Print CP0 register names according to specified architecture. Default: based on binary being disassembled. hwr-names=ARCH Print HWR names according to specified architecture. Default: based on binary being disassembled. reg-names=ABI Print GPR and FPR names according to specified ABI. reg-names=ARCH Print CP0 register and HWR names according to specified architecture. For the options above, the following values are supported for "ABI": numeric 32 n32 64 For the options above, the following values are supported for "ARCH": numeric r3000 r3900 r4000 r4010 vr4100 vr4111 vr4120 r4300 r4400 r4600 r4650 r5000 vr5400 vr5500 r5900 r6000 rm7000 rm9000 r8000 r10000 r12000 r14000 r16000 mips5 mips32 mips32r2 mips32r3 mips32r5 mips32r6 mips64 mips64r2 mips64r3 mips64r5 mips64r6 interaptiv-mr2 sb1 loongson2e loongson2f loongson3a octeon octeon+ octeon2 octeon3 xlr xlp (gdb) which corresponds to what `objdump --help' used to print for the MIPS target, with minor formatting changes, most notably option argument lists being wrapped, but also the amount of white space separating options from the respective descriptions. The relevant part the new code is now also used by `objdump --help', which means these formatting changes apply to both outputs, except for argument list wrapping, which is GDB-specific. This also adds a separating new line between the heading and option lists where descriptions are provided, hence: (gdb) set architecture s390:31-bit (gdb) show disassembler-options The current disassembler options are '' The following disassembler options are supported for use with the 'set disassembler-options <option>[,<option>...]' command: esa Disassemble in ESA architecture mode zarch Disassemble in z/Architecture mode insnlength Print unknown instructions according to length from first two bits (gdb) but: (gdb) set architecture powerpc:common (gdb) show disassembler-options The current disassembler options are '' The following disassembler options are supported for use with the 'set disassembler-options <option>[,<option>...]' command: 403, 405, 440, 464, 476, 601, 603, 604, 620, 7400, 7410, 7450, 7455, 750cl, 821, 850, 860, a2, altivec, any, booke, booke32, cell, com, e200z4, e300, e500, e500mc, e500mc64, e5500, e6500, e500x2, efs, efs2, power4, power5, power6, power7, power8, power9, ppc, ppc32, 32, ppc64, 64, ppc64bridge, ppcps, pwr, pwr2, pwr4, pwr5, pwr5x, pwr6, pwr7, pwr8, pwr9, pwrx, raw, spe, spe2, titan, vle, vsx (gdb) Existing affected target backends have been adjusted accordingly. This has been verified manually with: (gdb) set architecture arm (gdb) set architecture powerpc:common (gdb) set architecture s390:31-bit to cause no issues with the `show disassembler-options' and `set disassembler-options' commands. A test case for the MIPS target has also been provided, covering the default settings with ABI overrides as well as disassembler option overrides. 2018-07-02 Maciej W. Rozycki <macro@mips.com> Simon Marchi <simon.marchi@polymtl.ca> include/ PR tdep/8282 * dis-asm.h (disasm_option_arg_t): New typedef. (disasm_options_and_args_t): Likewise. (disasm_options_t): Add `arg' member, document members. (disassembler_options_mips): New prototype. (disassembler_options_arm, disassembler_options_powerpc) (disassembler_options_s390): Update prototypes. opcodes/ PR tdep/8282 * mips-dis.c (mips_option_arg_t): New enumeration. (mips_options): New variable. (disassembler_options_mips): New function. (print_mips_disassembler_options): Reimplement in terms of `disassembler_options_mips'. * arm-dis.c (disassembler_options_arm): Adapt to using the `disasm_options_and_args_t' structure. * ppc-dis.c (disassembler_options_powerpc): Likewise. * s390-dis.c (disassembler_options_s390): Likewise. gdb/ PR tdep/8282 * disasm.h (gdb_disassembler): Add `m_disassembler_options_holder'. member * disasm.c (get_all_disassembler_options): New function. (gdb_disassembler::gdb_disassembler): Use it. (gdb_buffered_insn_length_init_dis): Likewise. (gdb_buffered_insn_length): Adjust accordingly. (set_disassembler_options): Handle options with arguments. (show_disassembler_options_sfunc): Likewise. Add a leading new line if showing options with descriptions. (disassembler_options_completer): Adapt to using the `disasm_options_and_args_t' structure. * mips-tdep.c (mips_disassembler_options): New variable. (mips_disassembler_options_o32): Likewise. (mips_disassembler_options_n32): Likewise. (mips_disassembler_options_n64): Likewise. (gdb_print_insn_mips): Don't set `disassembler_options'. (gdb_print_insn_mips_n32, gdb_print_insn_mips_n64): Remove functions. (mips_gdbarch_init): Always set `gdbarch_print_insn' to `gdb_print_insn_mips'. Set `gdbarch_disassembler_options', `gdbarch_disassembler_options_implicit' and `gdbarch_valid_disassembler_options'. * arm-tdep.c (_initialize_arm_tdep): Adapt to using the `disasm_options_and_args_t' structure. * gdbarch.sh (disassembler_options_implicit): New `gdbarch' method. (valid_disassembler_options): Switch from `disasm_options_t' to the `disasm_options_and_args_t' structure. * NEWS: Document `set disassembler-options' support for the MIPS target. * gdbarch.h: Regenerate. * gdbarch.c: Regenerate. gdb/doc/ PR tdep/8282 * gdb.texinfo (Source and Machine Code): Document `set disassembler-options' support for the MIPS target. gdb/testsuite/ PR tdep/8282 * gdb.arch/mips-disassembler-options.exp: New test. * gdb.arch/mips-disassembler-options.s: New test source.
2018-07-03 00:57:21 +02:00
extern const char * gdbarch_disassembler_options_implicit (struct gdbarch *gdbarch);
extern void set_gdbarch_disassembler_options_implicit (struct gdbarch *gdbarch, const char * disassembler_options_implicit);
GDB: Add support for the new set/show disassembler-options commands. This commit adds support to GDB so that it can modify the disassembler-options value that is passed to the disassembler, similar to objdump's -M option. Currently, the only supported targets are ARM, PowerPC and S/390, but adding support for a new target(s) is not difficult. include/ * dis-asm.h (disasm_options_t): New typedef. (parse_arm_disassembler_option): Remove prototype. (set_arm_regname_option): Likewise. (get_arm_regnames): Likewise. (get_arm_regname_num_options): Likewise. (disassemble_init_s390): New prototype. (disassembler_options_powerpc): Likewise. (disassembler_options_arm): Likewise. (disassembler_options_s390): Likewise. (remove_whitespace_and_extra_commas): Likewise. (disassembler_options_cmp): Likewise. (next_disassembler_option): New inline function. (FOR_EACH_DISASSEMBLER_OPTION): New macro. opcodes/ * disassemble.c Include "safe-ctype.h". (disassemble_init_for_target): Handle s390 init. (remove_whitespace_and_extra_commas): New function. (disassembler_options_cmp): Likewise. * arm-dis.c: Include "libiberty.h". (NUM_ELEM): Delete. (regnames): Use long disassembler style names. Add force-thumb and no-force-thumb options. (NUM_ARM_REGNAMES): Rename from this... (NUM_ARM_OPTIONS): ...to this. Use ARRAY_SIZE. (get_arm_regname_num_options): Delete. (set_arm_regname_option): Likewise. (get_arm_regnames): Likewise. (parse_disassembler_options): Likewise. (parse_arm_disassembler_option): Rename from this... (parse_arm_disassembler_options): ...to this. Make static. Use new FOR_EACH_DISASSEMBLER_OPTION macro to scan over options. (print_insn): Use parse_arm_disassembler_options. (disassembler_options_arm): New function. (print_arm_disassembler_options): Handle updated regnames. * ppc-dis.c: Include "libiberty.h". (ppc_opts): Add "32" and "64" entries. (ppc_parse_cpu): Use ARRAY_SIZE and disassembler_options_cmp. (powerpc_init_dialect): Add break to switch statement. Use new FOR_EACH_DISASSEMBLER_OPTION macro. (disassembler_options_powerpc): New function. (print_ppc_disassembler_options): Use ARRAY_SIZE. Remove printing of "32" and "64". * s390-dis.c: Include "libiberty.h". (init_flag): Remove unneeded variable. (struct s390_options_t): New structure type. (options): New structure. (init_disasm): Rename from this... (disassemble_init_s390): ...to this. Add initializations for current_arch_mask and option_use_insn_len_bits_p. Remove init_flag. (print_insn_s390): Delete call to init_disasm. (disassembler_options_s390): New function. (print_s390_disassembler_options): Print using information from struct 'options'. * po/opcodes.pot: Regenerate. binutils/ * objdump.c (main): Use remove_whitespace_and_extra_commas. gdb/ * NEWS: Mention new set/show disassembler-options commands. * doc/gdb.texinfo: Document new set/show disassembler-options commands. * disasm.c: Include "arch-utils.h", "gdbcmd.h" and "safe-ctype.h". (prospective_options): New static variable. (gdb_disassembler::gdb_disassembler): Initialize m_di.disassembler_options. (gdb_buffered_insn_length_init_dis): Initilize di->disassembler_options. (get_disassembler_options): New function. (set_disassembler_options): Likewise. (set_disassembler_options_sfunc): Likewise. (show_disassembler_options_sfunc): Likewise. (disassembler_options_completer): Likewise. (_initialize_disasm): Likewise. * disasm.h (get_disassembler_options): New prototype. (set_disassembler_options): Likewise. * gdbarch.sh (gdbarch_disassembler_options): New variable. (gdbarch_verify_disassembler_options): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * arm-tdep.c (num_disassembly_options): Delete. (set_disassembly_style): Likewise. (arm_disassembler_options): New static variable. (set_disassembly_style_sfunc): Convert short style name into long option name. Call set_disassembler_options. (show_disassembly_style_sfunc): New function. (arm_gdbarch_init): Call set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. (_initialize_arm_tdep): Delete regnames variable and update callers. (arm_disassembler_options): Initialize. (disasm_options): New variable. (num_disassembly_options): Rename from this... (num_disassembly_styles): ...to this. Compute by scanning through disasm_options. (valid_disassembly_styles): Initialize using disasm_options. Remove calls to parse_arm_disassembler_option, get_arm_regnames and set_arm_regname_option. Pass show_disassembly_style_sfunc to the "disassembler" setshow command. * rs6000-tdep.c (powerpc_disassembler_options): New static variable. (rs6000_gdbarch_init): Call set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. * s390-tdep.c (s390_disassembler_options): New static variable. (s390_gdbarch_init):all set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. gdb/testsuite/ * gdb.arch/powerpc-power.exp: Delete test. * gdb.arch/powerpc-power.s: Likewise. * gdb.disasm/disassembler-options.exp: New test. * gdb.arch/powerpc-altivec.exp: Likewise. * gdb.arch/powerpc-altivec.s: Likewise. * gdb.arch/powerpc-altivec2.exp: Likewise. * gdb.arch/powerpc-altivec2.s: Likewise. * gdb.arch/powerpc-altivec3.exp: Likewise. * gdb.arch/powerpc-altivec3.s: Likewise. * gdb.arch/powerpc-power7.exp: Likewise. * gdb.arch/powerpc-power7.s: Likewise. * gdb.arch/powerpc-power8.exp: Likewise. * gdb.arch/powerpc-power8.s: Likewise. * gdb.arch/powerpc-power9.exp: Likewise. * gdb.arch/powerpc-power9.s: Likewise. * gdb.arch/powerpc-vsx.exp: Likewise. * gdb.arch/powerpc-vsx.s: Likewise. * gdb.arch/powerpc-vsx2.exp: Likewise. * gdb.arch/powerpc-vsx2.s: Likewise. * gdb.arch/powerpc-vsx3.exp: Likewise. * gdb.arch/powerpc-vsx3.s: Likewise. * gdb.arch/arm-disassembler-options.exp: Likewise. * gdb.arch/powerpc-disassembler-options.exp: Likewise. * gdb.arch/s390-disassembler-options.exp: Likewise.
2017-02-28 19:32:07 +01:00
extern char ** gdbarch_disassembler_options (struct gdbarch *gdbarch);
extern void set_gdbarch_disassembler_options (struct gdbarch *gdbarch, char ** disassembler_options);
GDB PR tdep/8282: MIPS: Wire in `set disassembler-options' Implement MIPS target support for passing options to the disassembler, complementing commit 65b48a81404c ("GDB: Add support for the new set/show disassembler-options commands."). This includes options that expect an argument, so adjust the generic code and data structures used so as to handle such options. So as to give backends syntax flexibility no specific delimiter has been defined to separate options from their respective arguments, so it has to be included as the last character of the option name. Completion code however has not been adjusted and consequently option arguments cannot be completed at this time. Also the MIPS target has non-empty defaults for the options, so that ABI names for the general-purpose registers respect our `set mips abi ...' setting rather than always being determined from the ELF headers of the binary file selected. Handle these defaults as implicit options, never shown to the user and always prepended to the user-specified options, so that the latters can override the defaults. The resulting output for the MIPS target is as follows: (gdb) show disassembler-options The current disassembler options are '' The following disassembler options are supported for use with the 'set disassembler-options <option>[,<option>...]' command: no-aliases Use canonical instruction forms. msa Recognize MSA instructions. virt Recognize the virtualization ASE instructions. xpa Recognize the eXtended Physical Address (XPA) ASE instructions. ginv Recognize the Global INValidate (GINV) ASE instructions. gpr-names=ABI Print GPR names according to specified ABI. Default: based on binary being disassembled. fpr-names=ABI Print FPR names according to specified ABI. Default: numeric. cp0-names=ARCH Print CP0 register names according to specified architecture. Default: based on binary being disassembled. hwr-names=ARCH Print HWR names according to specified architecture. Default: based on binary being disassembled. reg-names=ABI Print GPR and FPR names according to specified ABI. reg-names=ARCH Print CP0 register and HWR names according to specified architecture. For the options above, the following values are supported for "ABI": numeric 32 n32 64 For the options above, the following values are supported for "ARCH": numeric r3000 r3900 r4000 r4010 vr4100 vr4111 vr4120 r4300 r4400 r4600 r4650 r5000 vr5400 vr5500 r5900 r6000 rm7000 rm9000 r8000 r10000 r12000 r14000 r16000 mips5 mips32 mips32r2 mips32r3 mips32r5 mips32r6 mips64 mips64r2 mips64r3 mips64r5 mips64r6 interaptiv-mr2 sb1 loongson2e loongson2f loongson3a octeon octeon+ octeon2 octeon3 xlr xlp (gdb) which corresponds to what `objdump --help' used to print for the MIPS target, with minor formatting changes, most notably option argument lists being wrapped, but also the amount of white space separating options from the respective descriptions. The relevant part the new code is now also used by `objdump --help', which means these formatting changes apply to both outputs, except for argument list wrapping, which is GDB-specific. This also adds a separating new line between the heading and option lists where descriptions are provided, hence: (gdb) set architecture s390:31-bit (gdb) show disassembler-options The current disassembler options are '' The following disassembler options are supported for use with the 'set disassembler-options <option>[,<option>...]' command: esa Disassemble in ESA architecture mode zarch Disassemble in z/Architecture mode insnlength Print unknown instructions according to length from first two bits (gdb) but: (gdb) set architecture powerpc:common (gdb) show disassembler-options The current disassembler options are '' The following disassembler options are supported for use with the 'set disassembler-options <option>[,<option>...]' command: 403, 405, 440, 464, 476, 601, 603, 604, 620, 7400, 7410, 7450, 7455, 750cl, 821, 850, 860, a2, altivec, any, booke, booke32, cell, com, e200z4, e300, e500, e500mc, e500mc64, e5500, e6500, e500x2, efs, efs2, power4, power5, power6, power7, power8, power9, ppc, ppc32, 32, ppc64, 64, ppc64bridge, ppcps, pwr, pwr2, pwr4, pwr5, pwr5x, pwr6, pwr7, pwr8, pwr9, pwrx, raw, spe, spe2, titan, vle, vsx (gdb) Existing affected target backends have been adjusted accordingly. This has been verified manually with: (gdb) set architecture arm (gdb) set architecture powerpc:common (gdb) set architecture s390:31-bit to cause no issues with the `show disassembler-options' and `set disassembler-options' commands. A test case for the MIPS target has also been provided, covering the default settings with ABI overrides as well as disassembler option overrides. 2018-07-02 Maciej W. Rozycki <macro@mips.com> Simon Marchi <simon.marchi@polymtl.ca> include/ PR tdep/8282 * dis-asm.h (disasm_option_arg_t): New typedef. (disasm_options_and_args_t): Likewise. (disasm_options_t): Add `arg' member, document members. (disassembler_options_mips): New prototype. (disassembler_options_arm, disassembler_options_powerpc) (disassembler_options_s390): Update prototypes. opcodes/ PR tdep/8282 * mips-dis.c (mips_option_arg_t): New enumeration. (mips_options): New variable. (disassembler_options_mips): New function. (print_mips_disassembler_options): Reimplement in terms of `disassembler_options_mips'. * arm-dis.c (disassembler_options_arm): Adapt to using the `disasm_options_and_args_t' structure. * ppc-dis.c (disassembler_options_powerpc): Likewise. * s390-dis.c (disassembler_options_s390): Likewise. gdb/ PR tdep/8282 * disasm.h (gdb_disassembler): Add `m_disassembler_options_holder'. member * disasm.c (get_all_disassembler_options): New function. (gdb_disassembler::gdb_disassembler): Use it. (gdb_buffered_insn_length_init_dis): Likewise. (gdb_buffered_insn_length): Adjust accordingly. (set_disassembler_options): Handle options with arguments. (show_disassembler_options_sfunc): Likewise. Add a leading new line if showing options with descriptions. (disassembler_options_completer): Adapt to using the `disasm_options_and_args_t' structure. * mips-tdep.c (mips_disassembler_options): New variable. (mips_disassembler_options_o32): Likewise. (mips_disassembler_options_n32): Likewise. (mips_disassembler_options_n64): Likewise. (gdb_print_insn_mips): Don't set `disassembler_options'. (gdb_print_insn_mips_n32, gdb_print_insn_mips_n64): Remove functions. (mips_gdbarch_init): Always set `gdbarch_print_insn' to `gdb_print_insn_mips'. Set `gdbarch_disassembler_options', `gdbarch_disassembler_options_implicit' and `gdbarch_valid_disassembler_options'. * arm-tdep.c (_initialize_arm_tdep): Adapt to using the `disasm_options_and_args_t' structure. * gdbarch.sh (disassembler_options_implicit): New `gdbarch' method. (valid_disassembler_options): Switch from `disasm_options_t' to the `disasm_options_and_args_t' structure. * NEWS: Document `set disassembler-options' support for the MIPS target. * gdbarch.h: Regenerate. * gdbarch.c: Regenerate. gdb/doc/ PR tdep/8282 * gdb.texinfo (Source and Machine Code): Document `set disassembler-options' support for the MIPS target. gdb/testsuite/ PR tdep/8282 * gdb.arch/mips-disassembler-options.exp: New test. * gdb.arch/mips-disassembler-options.s: New test source.
2018-07-03 00:57:21 +02:00
extern const disasm_options_and_args_t * gdbarch_valid_disassembler_options (struct gdbarch *gdbarch);
extern void set_gdbarch_valid_disassembler_options (struct gdbarch *gdbarch, const disasm_options_and_args_t * valid_disassembler_options);
GDB: Add support for the new set/show disassembler-options commands. This commit adds support to GDB so that it can modify the disassembler-options value that is passed to the disassembler, similar to objdump's -M option. Currently, the only supported targets are ARM, PowerPC and S/390, but adding support for a new target(s) is not difficult. include/ * dis-asm.h (disasm_options_t): New typedef. (parse_arm_disassembler_option): Remove prototype. (set_arm_regname_option): Likewise. (get_arm_regnames): Likewise. (get_arm_regname_num_options): Likewise. (disassemble_init_s390): New prototype. (disassembler_options_powerpc): Likewise. (disassembler_options_arm): Likewise. (disassembler_options_s390): Likewise. (remove_whitespace_and_extra_commas): Likewise. (disassembler_options_cmp): Likewise. (next_disassembler_option): New inline function. (FOR_EACH_DISASSEMBLER_OPTION): New macro. opcodes/ * disassemble.c Include "safe-ctype.h". (disassemble_init_for_target): Handle s390 init. (remove_whitespace_and_extra_commas): New function. (disassembler_options_cmp): Likewise. * arm-dis.c: Include "libiberty.h". (NUM_ELEM): Delete. (regnames): Use long disassembler style names. Add force-thumb and no-force-thumb options. (NUM_ARM_REGNAMES): Rename from this... (NUM_ARM_OPTIONS): ...to this. Use ARRAY_SIZE. (get_arm_regname_num_options): Delete. (set_arm_regname_option): Likewise. (get_arm_regnames): Likewise. (parse_disassembler_options): Likewise. (parse_arm_disassembler_option): Rename from this... (parse_arm_disassembler_options): ...to this. Make static. Use new FOR_EACH_DISASSEMBLER_OPTION macro to scan over options. (print_insn): Use parse_arm_disassembler_options. (disassembler_options_arm): New function. (print_arm_disassembler_options): Handle updated regnames. * ppc-dis.c: Include "libiberty.h". (ppc_opts): Add "32" and "64" entries. (ppc_parse_cpu): Use ARRAY_SIZE and disassembler_options_cmp. (powerpc_init_dialect): Add break to switch statement. Use new FOR_EACH_DISASSEMBLER_OPTION macro. (disassembler_options_powerpc): New function. (print_ppc_disassembler_options): Use ARRAY_SIZE. Remove printing of "32" and "64". * s390-dis.c: Include "libiberty.h". (init_flag): Remove unneeded variable. (struct s390_options_t): New structure type. (options): New structure. (init_disasm): Rename from this... (disassemble_init_s390): ...to this. Add initializations for current_arch_mask and option_use_insn_len_bits_p. Remove init_flag. (print_insn_s390): Delete call to init_disasm. (disassembler_options_s390): New function. (print_s390_disassembler_options): Print using information from struct 'options'. * po/opcodes.pot: Regenerate. binutils/ * objdump.c (main): Use remove_whitespace_and_extra_commas. gdb/ * NEWS: Mention new set/show disassembler-options commands. * doc/gdb.texinfo: Document new set/show disassembler-options commands. * disasm.c: Include "arch-utils.h", "gdbcmd.h" and "safe-ctype.h". (prospective_options): New static variable. (gdb_disassembler::gdb_disassembler): Initialize m_di.disassembler_options. (gdb_buffered_insn_length_init_dis): Initilize di->disassembler_options. (get_disassembler_options): New function. (set_disassembler_options): Likewise. (set_disassembler_options_sfunc): Likewise. (show_disassembler_options_sfunc): Likewise. (disassembler_options_completer): Likewise. (_initialize_disasm): Likewise. * disasm.h (get_disassembler_options): New prototype. (set_disassembler_options): Likewise. * gdbarch.sh (gdbarch_disassembler_options): New variable. (gdbarch_verify_disassembler_options): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * arm-tdep.c (num_disassembly_options): Delete. (set_disassembly_style): Likewise. (arm_disassembler_options): New static variable. (set_disassembly_style_sfunc): Convert short style name into long option name. Call set_disassembler_options. (show_disassembly_style_sfunc): New function. (arm_gdbarch_init): Call set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. (_initialize_arm_tdep): Delete regnames variable and update callers. (arm_disassembler_options): Initialize. (disasm_options): New variable. (num_disassembly_options): Rename from this... (num_disassembly_styles): ...to this. Compute by scanning through disasm_options. (valid_disassembly_styles): Initialize using disasm_options. Remove calls to parse_arm_disassembler_option, get_arm_regnames and set_arm_regname_option. Pass show_disassembly_style_sfunc to the "disassembler" setshow command. * rs6000-tdep.c (powerpc_disassembler_options): New static variable. (rs6000_gdbarch_init): Call set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. * s390-tdep.c (s390_disassembler_options): New static variable. (s390_gdbarch_init):all set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. gdb/testsuite/ * gdb.arch/powerpc-power.exp: Delete test. * gdb.arch/powerpc-power.s: Likewise. * gdb.disasm/disassembler-options.exp: New test. * gdb.arch/powerpc-altivec.exp: Likewise. * gdb.arch/powerpc-altivec.s: Likewise. * gdb.arch/powerpc-altivec2.exp: Likewise. * gdb.arch/powerpc-altivec2.s: Likewise. * gdb.arch/powerpc-altivec3.exp: Likewise. * gdb.arch/powerpc-altivec3.s: Likewise. * gdb.arch/powerpc-power7.exp: Likewise. * gdb.arch/powerpc-power7.s: Likewise. * gdb.arch/powerpc-power8.exp: Likewise. * gdb.arch/powerpc-power8.s: Likewise. * gdb.arch/powerpc-power9.exp: Likewise. * gdb.arch/powerpc-power9.s: Likewise. * gdb.arch/powerpc-vsx.exp: Likewise. * gdb.arch/powerpc-vsx.s: Likewise. * gdb.arch/powerpc-vsx2.exp: Likewise. * gdb.arch/powerpc-vsx2.s: Likewise. * gdb.arch/powerpc-vsx3.exp: Likewise. * gdb.arch/powerpc-vsx3.s: Likewise. * gdb.arch/arm-disassembler-options.exp: Likewise. * gdb.arch/powerpc-disassembler-options.exp: Likewise. * gdb.arch/s390-disassembler-options.exp: Likewise.
2017-02-28 19:32:07 +01:00
gdb: Restructure type_align and gdbarch_type_align This commit restructures the relationship between the type_align function and the gdbarch_type_align method. The problem being addressed with this commit is this; previously the type_align function was structured so that for "basic" types (int, float, etc) the gdbarch_type_align hook was called, which for "compound" types (arrays, structs, etc) the common type_align code has a fixed method for how to extract a "basic" type and would then call itself on that "basic" type. The problem is that if an architecture wants to modify the alignment rules for a "compound" type then this is not currently possible. In the revised structure, all types pass through the gdbarch_type_align method. If this method returns 0 then this indicates that the architecture has no special rules for this type, and GDB should apply the default rules for alignment. However, the architecture is free to provide an alignment for any type, both "basic" and "compound". After this commit the default alignment rules now all live in the type_align function, the default_type_align only ever returns 0, meaning apply the default rules. I've updated the 3 targets (arc, i386, and nios2) that already override the gdbarch_type_align method to fit the new scheme. Tested on X86-64/GNU Linux with no regressions. gdb/ChangeLog: * arc-tdep.c (arc_type_align): Provide alignment for basic types, return 0 for other types. * arch-utils.c (default_type_align): Always return 0. * gdbarch.h: Regenerate. * gdbarch.sh (type_align): Extend comment. * gdbtypes.c (type_align): Add additional comments, always call gdbarch_type_align before applying the default rules. * i386-tdep.c (i386_type_align): Return 0 as the default rule, generic code will then apply a suitable default. * nios2-tdep.c (nios2_type_align): Provide alignment for basic types, return 0 for other types.
2019-02-22 21:49:04 +01:00
/* Type alignment override method. Return the architecture specific
alignment required for TYPE. If there is no special handling
required for TYPE then return the value 0, GDB will then apply the
default rules as laid out in gdbtypes.c:type_align. */
typedef ULONGEST (gdbarch_type_align_ftype) (struct gdbarch *gdbarch, struct type *type);
extern ULONGEST gdbarch_type_align (struct gdbarch *gdbarch, struct type *type);
extern void set_gdbarch_type_align (struct gdbarch *gdbarch, gdbarch_type_align_ftype *type_align);
1999-08-31 03:14:27 +02:00
extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
1999-06-14 20:08:47 +02:00
/* Mechanism for co-ordinating the selection of a specific
architecture.
GDB targets (*-tdep.c) can register an interest in a specific
architecture. Other GDB components can register a need to maintain
per-architecture data.
The mechanisms below ensures that there is only a loose connection
between the set-architecture command and the various GDB
components. Each component can independently register their need
1999-06-14 20:08:47 +02:00
to maintain architecture specific data with gdbarch.
Pragmatics:
Previously, a single TARGET_ARCHITECTURE_HOOK was provided. It
didn't scale.
The more traditional mega-struct containing architecture specific
data for all the various GDB components was also considered. Since
GDB is built from a variable number of (fairly independent)
1999-06-14 20:08:47 +02:00
components it was determined that the global aproach was not
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
applicable. */
1999-06-14 20:08:47 +02:00
/* Register a new architectural family with GDB.
Register support for the specified ARCHITECTURE with GDB. When
gdbarch determines that the specified architecture has been
selected, the corresponding INIT function is called.
--
The INIT function takes two parameters: INFO which contains the
information available to gdbarch about the (possibly new)
architecture; ARCHES which is a list of the previously created
``struct gdbarch'' for this architecture.
The INFO parameter is, as far as possible, be pre-initialized with
information obtained from INFO.ABFD or the global defaults.
The ARCHES parameter is a linked list (sorted most recently used)
of all the previously created architures for this architecture
family. The (possibly NULL) ARCHES->gdbarch can used to access
values from the previously selected architecture for this
architecture family.
1999-06-14 20:08:47 +02:00
The INIT function shall return any of: NULL - indicating that it
doesn't recognize the selected architecture; an existing ``struct
1999-06-14 20:08:47 +02:00
gdbarch'' from the ARCHES list - indicating that the new
architecture is just a synonym for an earlier architecture (see
gdbarch_list_lookup_by_info()); a newly created ``struct gdbarch''
- that describes the selected architecture (see gdbarch_alloc()).
The DUMP_TDEP function shall print out all target specific values.
Care should be taken to ensure that the function works in both the
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
multi-arch and non- multi-arch cases. */
1999-06-14 20:08:47 +02:00
1999-07-20 01:30:11 +02:00
struct gdbarch_list
{
struct gdbarch *gdbarch;
struct gdbarch_list *next;
};
1999-06-14 20:08:47 +02:00
1999-07-20 01:30:11 +02:00
struct gdbarch_info
{
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
/* Use default: NULL (ZERO). */
1999-07-20 01:30:11 +02:00
const struct bfd_arch_info *bfd_arch_info;
1999-06-14 20:08:47 +02:00
/* Use default: BFD_ENDIAN_UNKNOWN (NB: is not ZERO). */
enum bfd_endian byte_order;
1999-06-14 20:08:47 +02:00
enum bfd_endian byte_order_for_code;
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
/* Use default: NULL (ZERO). */
1999-07-20 01:30:11 +02:00
bfd *abfd;
1999-06-14 20:08:47 +02:00
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
/* Use default: NULL (ZERO). */
2017-08-07 16:53:54 +02:00
union
{
/* Architecture-specific information. The generic form for targets
that have extra requirements. */
struct gdbarch_tdep_info *tdep_info;
/* Architecture-specific target description data. Numerous targets
need only this, so give them an easy way to hold it. */
struct tdesc_arch_data *tdesc_data;
/* SPU file system ID. This is a single integer, so using the
generic form would only complicate code. Other targets may
reuse this member if suitable. */
int *id;
};
/* Use default: GDB_OSABI_UNINITIALIZED (-1). */
enum gdb_osabi osabi;
/* Use default: NULL (ZERO). */
const struct target_desc *target_desc;
1999-07-20 01:30:11 +02:00
};
1999-06-14 20:08:47 +02:00
1999-08-31 03:14:27 +02:00
typedef struct gdbarch *(gdbarch_init_ftype) (struct gdbarch_info info, struct gdbarch_list *arches);
typedef void (gdbarch_dump_tdep_ftype) (struct gdbarch *gdbarch, struct ui_file *file);
1999-06-14 20:08:47 +02:00
/* DEPRECATED - use gdbarch_register() */
1999-08-31 03:14:27 +02:00
extern void register_gdbarch_init (enum bfd_architecture architecture, gdbarch_init_ftype *);
1999-06-14 20:08:47 +02:00
extern void gdbarch_register (enum bfd_architecture architecture,
gdbarch_init_ftype *,
gdbarch_dump_tdep_ftype *);
1999-06-14 20:08:47 +02:00
/* Return a freshly allocated, NULL terminated, array of the valid
architecture names. Since architectures are registered during the
_initialize phase this function only returns useful information
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
once initialization has been completed. */
extern const char **gdbarch_printable_names (void);
1999-06-14 20:08:47 +02:00
/* Helper function. Search the list of ARCHES for a GDBARCH that
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
matches the information provided by INFO. */
1999-06-14 20:08:47 +02:00
extern struct gdbarch_list *gdbarch_list_lookup_by_info (struct gdbarch_list *arches, const struct gdbarch_info *info);
1999-06-14 20:08:47 +02:00
/* Helper function. Create a preliminary ``struct gdbarch''. Perform
basic initialization using values obtained from the INFO and TDEP
1999-06-14 20:08:47 +02:00
parameters. set_gdbarch_*() functions are called to complete the
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
initialization of the object. */
1999-06-14 20:08:47 +02:00
1999-08-31 03:14:27 +02:00
extern struct gdbarch *gdbarch_alloc (const struct gdbarch_info *info, struct gdbarch_tdep *tdep);
1999-06-14 20:08:47 +02:00
/* Helper function. Free a partially-constructed ``struct gdbarch''.
It is assumed that the caller freeds the ``struct
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
gdbarch_tdep''. */
extern void gdbarch_free (struct gdbarch *);
Introduce obstack_new, poison other "typed" obstack functions Since we use obstacks with objects that are not default constructible, we sometimes need to manually call the constructor by hand using placement new: foo *f = obstack_alloc (obstack, sizeof (foo)); f = new (f) foo; It's possible to use allocate_on_obstack instead, but there are types that we sometimes want to allocate on an obstack, and sometimes on the regular heap. This patch introduces a utility to make this pattern simpler if allocate_on_obstack is not an option: foo *f = obstack_new<foo> (obstack); Right now there's only one usage (in tdesc_data_init). To help catch places where we would forget to call new when allocating such an object on an obstack, this patch also poisons some other methods of allocating an instance of a type on an obstack: - OBSTACK_ZALLOC/OBSTACK_CALLOC - XOBNEW/XOBNEW - GDBARCH_OBSTACK_ZALLOC/GDBARCH_OBSTACK_CALLOC Unfortunately, there's no way to catch wrong usages of obstack_alloc. By pulling on that string though, it tripped on allocating struct template_symbol using OBSTACK_ZALLOC. The criterion currently used to know whether it's safe to "malloc" an instance of a struct is whether it is a POD. Because it inherits from struct symbol, template_symbol is not a POD. This criterion is a bit too strict however, it should still safe to allocate memory for a template_symbol and memset it to 0. We didn't use is_trivially_constructible as the criterion in the first place only because it is not available in gcc < 5. So here I considered two alternatives: 1. Relax that criterion to use std::is_trivially_constructible and add a bit more glue code to make it work with gcc < 5 2. Continue pulling on the string and change how the symbol structures are allocated and initialized I managed to do both, but I decided to go with #1 to keep this patch simpler and more focused. When building with a compiler that does not have is_trivially_constructible, the check will just not be enforced. gdb/ChangeLog: * common/traits.h (HAVE_IS_TRIVIALLY_COPYABLE): Define if compiler supports std::is_trivially_constructible. * common/poison.h: Include obstack.h. (IsMallocable): Define to is_trivially_constructible if the compiler supports it, define to true_type otherwise. (xobnew): New. (XOBNEW): Redefine. (xobnewvec): New. (XOBNEWVEC): Redefine. * gdb_obstack.h (obstack_zalloc): New. (OBSTACK_ZALLOC): Redefine. (obstack_calloc): New. (OBSTACK_CALLOC): Redefine. (obstack_new): New. * gdbarch.sh: Include gdb_obstack in gdbarch.h. (gdbarch_obstack): New declaration in gdbarch.h, definition in gdbarch.c. (GDBARCH_OBSTACK_CALLOC, GDBARCH_OBSTACK_ZALLOC): Use obstack_calloc/obstack_zalloc. (gdbarch_obstack_zalloc): Remove. * target-descriptions.c (tdesc_data_init): Use obstack_new.
2018-05-21 03:06:03 +02:00
/* Get the obstack owned by ARCH. */
extern obstack *gdbarch_obstack (gdbarch *arch);
/* Helper function. Allocate memory from the ``struct gdbarch''
obstack. The memory is freed when the corresponding architecture
is also freed. */
Introduce obstack_new, poison other "typed" obstack functions Since we use obstacks with objects that are not default constructible, we sometimes need to manually call the constructor by hand using placement new: foo *f = obstack_alloc (obstack, sizeof (foo)); f = new (f) foo; It's possible to use allocate_on_obstack instead, but there are types that we sometimes want to allocate on an obstack, and sometimes on the regular heap. This patch introduces a utility to make this pattern simpler if allocate_on_obstack is not an option: foo *f = obstack_new<foo> (obstack); Right now there's only one usage (in tdesc_data_init). To help catch places where we would forget to call new when allocating such an object on an obstack, this patch also poisons some other methods of allocating an instance of a type on an obstack: - OBSTACK_ZALLOC/OBSTACK_CALLOC - XOBNEW/XOBNEW - GDBARCH_OBSTACK_ZALLOC/GDBARCH_OBSTACK_CALLOC Unfortunately, there's no way to catch wrong usages of obstack_alloc. By pulling on that string though, it tripped on allocating struct template_symbol using OBSTACK_ZALLOC. The criterion currently used to know whether it's safe to "malloc" an instance of a struct is whether it is a POD. Because it inherits from struct symbol, template_symbol is not a POD. This criterion is a bit too strict however, it should still safe to allocate memory for a template_symbol and memset it to 0. We didn't use is_trivially_constructible as the criterion in the first place only because it is not available in gcc < 5. So here I considered two alternatives: 1. Relax that criterion to use std::is_trivially_constructible and add a bit more glue code to make it work with gcc < 5 2. Continue pulling on the string and change how the symbol structures are allocated and initialized I managed to do both, but I decided to go with #1 to keep this patch simpler and more focused. When building with a compiler that does not have is_trivially_constructible, the check will just not be enforced. gdb/ChangeLog: * common/traits.h (HAVE_IS_TRIVIALLY_COPYABLE): Define if compiler supports std::is_trivially_constructible. * common/poison.h: Include obstack.h. (IsMallocable): Define to is_trivially_constructible if the compiler supports it, define to true_type otherwise. (xobnew): New. (XOBNEW): Redefine. (xobnewvec): New. (XOBNEWVEC): Redefine. * gdb_obstack.h (obstack_zalloc): New. (OBSTACK_ZALLOC): Redefine. (obstack_calloc): New. (OBSTACK_CALLOC): Redefine. (obstack_new): New. * gdbarch.sh: Include gdb_obstack in gdbarch.h. (gdbarch_obstack): New declaration in gdbarch.h, definition in gdbarch.c. (GDBARCH_OBSTACK_CALLOC, GDBARCH_OBSTACK_ZALLOC): Use obstack_calloc/obstack_zalloc. (gdbarch_obstack_zalloc): Remove. * target-descriptions.c (tdesc_data_init): Use obstack_new.
2018-05-21 03:06:03 +02:00
#define GDBARCH_OBSTACK_CALLOC(GDBARCH, NR, TYPE) obstack_calloc<TYPE> (gdbarch_obstack ((GDBARCH)), (NR))
#define GDBARCH_OBSTACK_ZALLOC(GDBARCH, TYPE) obstack_zalloc<TYPE> (gdbarch_obstack ((GDBARCH)))
/* Duplicate STRING, returning an equivalent string that's allocated on the
obstack associated with GDBARCH. The string is freed when the corresponding
architecture is also freed. */
extern char *gdbarch_obstack_strdup (struct gdbarch *arch, const char *string);
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
/* Helper function. Force an update of the current architecture.
1999-06-14 20:08:47 +02:00
The actual architecture selected is determined by INFO, ``(gdb) set
architecture'' et.al., the existing architecture and BFD's default
architecture. INFO should be initialized to zero and then selected
fields should be updated.
1999-06-14 20:08:47 +02:00
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
Returns non-zero if the update succeeds. */
extern int gdbarch_update_p (struct gdbarch_info info);
1999-06-14 20:08:47 +02:00
/* Helper function. Find an architecture matching info.
INFO should be initialized using gdbarch_info_init, relevant fields
set, and then finished using gdbarch_info_fill.
Returns the corresponding architecture, or NULL if no matching
architecture was found. */
extern struct gdbarch *gdbarch_find_by_info (struct gdbarch_info info);
/* Helper function. Set the target gdbarch to "gdbarch". */
extern void set_target_gdbarch (struct gdbarch *gdbarch);
1999-06-14 20:08:47 +02:00
/* Register per-architecture data-pointer.
Reserve space for a per-architecture data-pointer. An identifier
for the reserved data-pointer is returned. That identifer should
be saved in a local static variable.
1999-06-14 20:08:47 +02:00
Memory for the per-architecture data shall be allocated using
gdbarch_obstack_zalloc. That memory will be deleted when the
corresponding architecture object is deleted.
1999-06-14 20:08:47 +02:00
When a previously created architecture is re-selected, the
per-architecture data-pointer for that previous architecture is
restored. INIT() is not re-called.
1999-06-14 20:08:47 +02:00
Multiple registrarants for any architecture are allowed (and
strongly encouraged). */
struct gdbarch_data;
1999-06-14 20:08:47 +02:00
2004-03-15 Andrew Cagney <cagney@redhat.com> * gdbarch.sh (gdbarch_data_pre_init_fytpe) (gdbarch_data_register_pre_init, gdbarch_data_post_init_fytpe) (gdbarch_data_register_post_init): Replace gdbarch_data_init_ftype and register_gdbarch_data. (deprecated_set_gdbarch_data): Rename set_gdbarch_data. (struct gdbarch_data): Replace "init" by "pre_init" and "post_init". * gdbarch.h, gdbarch.c: Re-generate. * dwarf2-frame.c (dwarf2_frame_init): Replace "gdbarch" paramter with"obstack", use OBSTACK_ZALLOC. (dwarf2_frame_ops): Delete. (dwarf2_frame_set_init_reg): Use gdbarch_data. (dwarf2_frame_init_reg): Use gdbarch_data. (_initialize_dwarf2_frame): Use gdbarch_data_register_pre_init. * solib-svr4.c (set_solib_svr4_fetch_link_map_offsets) (_initialize_svr4_solib): Update. * user-regs.c (_initialize_user_regs): Update. * reggroups.c (_initialize_reggroup): Update. * regcache.c (_initialize_regcache): Update. * mips-linux-tdep.c (_initialize_mips_linux_tdep): Update. * libunwind-frame.c (_initialize_libunwind_frame): Update. * gnu-v3-abi.c (init_gnuv3_ops): Update. * frame-unwind.c (_initialize_frame_unwind): Update. * frame-base.c (_initialize_frame_base): Update. * user-regs.c (user_reg_add): Update. * reggroups.c (reggroup_add): Update. * mips-linux-tdep.c (set_mips_linux_register_addr): Update. * libunwind-frame.c (libunwind_frame_set_descr): Update. * frame-unwind.c (frame_unwind_append_sniffer): Update. * frame-base.c (frame_base_table): Update. * remote.c (_initialize_remote): Update. * gdb_obstack.h (OBSTACK_ZALLOC, OBSTACK_CALLOC): Define.
2004-03-15 21:38:08 +01:00
typedef void *(gdbarch_data_pre_init_ftype) (struct obstack *obstack);
extern struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *init);
typedef void *(gdbarch_data_post_init_ftype) (struct gdbarch *gdbarch);
extern struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *init);
extern void deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
struct gdbarch_data *data,
void *pointer);
1999-06-14 20:08:47 +02:00
extern void *gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *);
1999-06-14 20:08:47 +02:00
/* Set the dynamic target-system-dependent parameters (architecture,
2011-01-07 Michael Snyder <msnyder@vmware.com> * ada-lang.c: Comment cleanup, mostly periods and spaces. * ada-lang.h: Ditto. * ada-tasks.c: Ditto. * ada-valprint.c: Ditto. * aix-threads.c: Ditto. * alpha-linux-nat.c: Ditto. * alpha-linux-tdep.c: Ditto. * alpha-mdebug-tdep.c: Ditto. * alpha-nat.c: Ditto. * alpha-osf1-tdep.c: Ditto. * alpha-tdep.c: Ditto. * alphabsd-nat.c: Ditto. * alphabsd-tdep.c: Ditto. * amd64-darwin-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * amd64-sol2-tdep.c: Ditto. * amd64-tdep.c: Ditto. * amd64-fbsd-tdep.c: Ditto. * amd64-nbsd-tdep.c: Ditto. * amd64-obsd-tdep.c: Ditto. * amd64-linux-nat.c: Ditto. * amd64-linux-tdep.c: Ditto. * arm-tdep.c: Ditto. * arm-tdep.h: Ditto. * armnbsd-nat.c: Ditto. * avr-tdep.c: Ditto. * bfin-tdep.c: Ditto. * bsd-kvm.c: Ditto. * c-typeprintc: Ditto. * c-valprint.c: Ditto. * coff-pe-read.h: Ditto. * coffreead.c: Ditto. * cris-tdep.c: Ditto. * d-lang.c: Ditto. * darwin-nat-info.c: Ditto. * darwin-nat.c: Ditto. * dbug-rom.c: Ditto. * dbxread.c: Ditto. * dcache.c: Ditto. * dcache.h: Ditto. * dec-thread.c: Ditto. * defs.h: Ditto. * demangle.c: Ditto. * dicos-tdep.c: Ditto. * dictionary.c: Ditto. * dictionary.h: Ditto. * dink32-rom.c: Ditto. * disasm.c: Ditto. * doublest.c: Ditto. * dsrec.c: Ditto. * dummy-frame.c: Ditto. * dwarf2-frame.c: Ditto. * dwarf2expr.c: Ditto. * dwarf2loc.c: Ditto. * dwarf2read.c: Ditto. * elfread.c: Ditto. * environ.c: Ditto. * eval.c: Ditto. * event-top.h: Ditto. * exceptions.c: Ditto. * exceptions.h: Ditto. * exec.c: Ditto. * expprint.c: Ditto. * expression.h: Ditto. * f-exp.y: Ditto. * f-lang.c: Ditto. * f-lang.h: Ditto. * f-typeprint.c: Ditto. * f-valprint.c: Ditto. * fbsd-nat.c: Ditto. * findvar.c: Ditto. * fork-child.c: Ditto. * frame.c: Ditto. * frame.h: Ditto. * frv-linux-tdep.c: Ditto. * frv-tdep.c: Ditto. * gcore.c: Ditto. * gdb-stabs.h: Ditto. * gdb_assert.h: Ditto. * gdb_string.h: Ditto. * gdb_thread_db.h: Ditto. * gdb_wait.h: Ditto. * gdbarch.sh: Ditto. * gdbcore.h: Ditto. * gdbthread.h: Ditto. * gdbtypes.c: Ditto. * gdbtypes.h: Ditto. * gnu-nat.c: Ditto. * gnu-nat.h: Ditto. * gnu-v2-abi.c: Ditto. * gnu-v3-abi.c: Ditto. * go32-nat.c: Ditto. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate.
2011-01-07 20:36:19 +01:00
byte-order, ...) using information found in the BFD. */
1999-08-31 03:14:27 +02:00
extern void set_gdbarch_from_file (bfd *);
1999-10-26 05:43:48 +02:00
/* Initialize the current architecture to the "first" one we find on
our list. */
extern void initialize_current_architecture (void);
/* gdbarch trace variable */
gdb/ * dwarf2loc.c (entry_values_debug): Add 'unsigned'. (_initialize_dwarf2loc): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * dwarf2loc.h: Update the declaration of 'entry_values_debug'. * dwarf2read.c (dwarf2_die_debug): Add 'unsigned'. (_initialize_dwarf2_read): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * darwin-nat.c (dwarwin_debug_flag): Add 'unsigned'. (_initialize_darwin_inferior): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * frame.c (frame_debug): Add 'unsigned'. (_intialize_frame): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * frame.h: Update the declaration of 'frame_debug'. * gdbtypes.c (overload_debug): Add 'unsigned'. (_initialize_gdbtypes): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * inferior.h: Update declaration of 'debug_infrun'. * infrun.c (debug_infrun): Add 'unsigned'. (_initialize_infrun): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * jit.c (jit_debug): Add 'unsigned'. (_initialize_jit): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * linux-nat.c (debug_linux_nat): Add 'unsigned'. (_initialize_linux_nat): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * linux-thread-db.c (libthread_db_debug): Add 'unsigned'. (_initialize_thread_db): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * machoread.c (mach_o_debug_level): Add 'unsigned'. (_initialize_machoread): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * mi/mi-cmd-var.c: Update the declaration of 'varobjdebug'. * microblaze-tdep.c (microblaze_debug_flag): Add 'unsigned'. (_initialize_microblaze_tdep): Call add_setshow_zuinteger_cmd intead of add_setshow_zinteger_cmd. * mips-tdep.c (mips_debug): Add 'unsigned'. (_initialize_mips_tdep): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * monitor.c (monitor_debug): Add 'unsigned'. (_initialize_remote_monitors): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * observer.c (observer_debug): Add 'unsigned'. (_initialize_observer): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * parse.c (expressiondebug): Add 'unsigned'. (_initialize_parse): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * record.c (record_debug): Add 'unsigned'. (_initialize_record): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * record.h: Update the declaration of 'record_debug'. * stap-probe.c (stap_expression_debug): Add 'unsigned'. (_initialize_stap_probe): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * serial.c (global_serial_debug_p): Add 'unsigned'. (_initialize_serial): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * solib-dsbt.c (solib_dsbt_debug): Add 'unsigned'. (_initialize_dsbt_solib): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * solib-frv.c (solib_frv_debug): Add 'unsigned'. (_initialize_frv_solib): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * target.c (targetdebug): Add 'unsigned'. (initialize_targets): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * valops.c (overload_debug): Add 'unsigned'. * varobj.c (varobjdebug): Add 'unsigned'. (_initialize_varobj): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * xtensa-tdep.c (xtensa_debug_level): Add 'unsigned'. (_initialize_xtensa_tdep): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * arch-utils.h: Remove the declaration of 'gdbarch_debug'. * gdbarch.sh (gdbarch_debug): Add 'unsigned'. (extern void _initialize_gdbarch): Call add_setshow_zuinteger_cmd instead of add_setshow_zinteger_cmd. * gdbarch.c, gdbarch.h: Re-generated.
2012-08-02 11:36:40 +02:00
extern unsigned int gdbarch_debug;
extern void gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file);
1999-06-14 20:08:47 +02:00
Introduce gdbarch_num_cooked_regs The expression gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch) is used quite often to find the number of cooked registers (raw + pseudo registers). This patch introduces gdbarch_num_cooked_regs, which does the equivalent. It substantially reduces required wrapping in some places, so should improve readability. There is a for loop in m68hc11_frame_unwind_cache that had iterated until (the equivalent of) gdbarch_num_cooked_regs (gdbarch) - 1. During review, we concluded that this is most likely an off-by-one mistake, so I replaced it with gdbarch_num_cooked_regs (gdbarch). gdb/ChangeLog: * gdbarch.sh (gdbarch_num_cooked_regs): New. * gdbarch.h: Re-generate. * ax-gdb.c (gen_expr): Use gdbarch_num_cooked_regs. * dwarf2-frame.c (dwarf2_frame_cache): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * findvar.c (value_of_register): Likewise. (value_of_register_lazy): Likewise. (address_from_register): Likewise. * frame.c (get_frame_register_bytes): Likewise. * gdbarch-selftests.c (register_to_value_test): Likewise. * h8300-tdep.c (h8300_register_type): Likewise. * i386-tdep.c (i386_dbx_reg_to_regnum): Likewise. (i386_svr4_reg_to_regnum): Likewise. * infcmd.c (default_print_registers_info): Likewise. (registers_info): Likewise. (print_vector_info): Likewise. (default_print_float_info): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise. * mdebugread.c (mdebug_reg_to_regnum): Likewise. * mi/mi-main.c (mi_cmd_data_list_register_names): Likewise. (mi_cmd_data_list_changed_registers): Likewise. (mi_cmd_data_list_register_values): Likewise. (mi_cmd_data_write_register_values): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mips-tdep.c (print_gp_register_row): Likewise. (mips_print_registers_info): Likewise. * nds32-tdep.c (nds32_gdbarch_init): Likewise. * regcache.c (init_regcache_descr): Likewise. (register_size): Likewise. (register_dump::dump): Likewise. (cooked_read_test): Likewise. (cooked_write_test): Likewise. * rs6000-tdep.c (rs6000_register_sim_regno): Likewise. (rs6000_gdbarch_init): Likewise. * stabsread.c (stab_reg_to_regnum): Likewise. * stack.c (info_frame_command): Likewise. * target-descriptions.c (tdesc_register_name): Likewise. * trad-frame.c (trad_frame_alloc_saved_regs): Likewise. * tui/tui-regs.c (tui_show_register_group): Likewise. * user-regs.c (user_reg_map_name_to_regnum): Likewise. (user_reg_map_regnum_to_name): Likewise. (value_of_user_reg): Likewise. (maintenance_print_user_registers): Likewise. * xtensa-tdep.c (xtensa_find_register_by_name): Likewise. (xtensa_register_name): Likewise. (xtensa_register_type): Likewise. (xtensa_reg_to_regnum): Likewise. (xtensa_pseudo_register_read): Likewise. (xtensa_pseudo_register_write): Likewise.
2018-10-22 04:29:21 +02:00
/* Return the number of cooked registers (raw + pseudo) for ARCH. */
static inline int
gdbarch_num_cooked_regs (gdbarch *arch)
{
return gdbarch_num_regs (arch) + gdbarch_num_pseudo_regs (arch);
}
#endif