aboutsummaryrefslogtreecommitdiff
path: root/gdb/common
AgeCommit message (Collapse)AuthorFilesLines
2014-06-20Move shared native target specific code to gdb/natGary Benson14-4477/+0
https://sourceware.org/gdb/wiki/Common describes the following directory structure: gdb/nat/ Native target backend files. Code that interfaces with the host debug API. E.g., ptrace code, Windows debug API code, procfs code should go here. gdb/target/ Host-independent, target vector specific code (target_ops). gdb/common/ All other shared code. This commit moves all native target backend files currently in gdb/common to gdb/nat. gdb/ 2014-06-20 Gary Benson <gbenson@redhat.com> * common/gdb_thread_db.h: Moved to nat. All includes updated. * common/glibc_thread_db.h: Likewise. * common/i386-cpuid.h: Likewise. * common/i386-gcc-cpuid.h: Likewise. * common/linux-btrace.h: Likewise. * common/linux-osdata.h: Likewise. * common/linux-procfs.h: Likewise. * common/linux-ptrace.h: Likewise. * common/mips-linux-watch.h: Likewise. * common/linux-btrace.c: Moved to nat. * common/linux-osdata.c: Likewise. * common/linux-procfs.c: Likewise. * common/linux-ptrace.c: Likewise. * common/mips-linux-watch.c: Likewise. * nat/gdb_thread_db.h: Moved from common. * nat/glibc_thread_db.h: Likewise. * nat/i386-cpuid.h: Likewise. * nat/i386-gcc-cpuid.h: Likewise. * nat/linux-btrace.c: Likewise. * nat/linux-btrace.h: Likewise. * nat/linux-osdata.c: Likewise. * nat/linux-osdata.h: Likewise. * nat/linux-procfs.c: Likewise. * nat/linux-procfs.h: Likewise. * nat/linux-ptrace.c: Likewise. * nat/linux-ptrace.h: Likewise. * nat/mips-linux-watch.c: Likewise. * nat/mips-linux-watch.h: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Reflect new locations. (object file files): Reordered. * gdb/copyright.py (EXCLUDE_LIST): Reflect new location of glibc_thread_db.h. gdb/gdbserver/ 2014-06-20 Gary Benson <gbenson@redhat.com> * Makefile.in (SFILES): Update locations for files moved from common to nat. (object file files): Reordered. gdb/testsuite/ 2014-06-20 Gary Benson <gbenson@redhat.com> * gdb.arch/i386-avx.exp: Fix include file location. * gdb.arch/i386-sse.exp: Likewise.
2014-06-09Separate out ANSI-standard signalsGary Benson1-26/+41
This commit reorders various pieces of code to separate ANSI-standard signals from other signals that need checking. Comments are added to document this, and to document the ordering of the signals. gdb/ 2014-06-09 Gary Benson <gbenson@redhat.com> * common/signals.c (gdb_signal_from_host): Reorder to separate the always-available ANSI-standard signals from the signals that require checking. (do_gdb_signal_to_host): Likewise. * proc-events.c (signal_table): Likewise. gdb/testsuite/ 2014-06-09 Gary Benson <gbenson@redhat.com> * gdb.base/sigall.c [Functions to send signals]: Reorder to separate the always-available ANSI-standard signals from the signals that require checking. (main): Likewise. * gdb.reverse/sigall-reverse.c [Functions to send signals]: Likewise. (main): Likewise.
2014-06-08Fix gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw) (timeout) ↵Hui Zhu2-0/+10
with Linux 2.6.32 and older version https://sourceware.org/ml/gdb-patches/2014-04/msg00047.html Got gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw) (timeout) with Linux 2.6.32 and older version. The rootcause is after the test use "set can-use-hw-watchpoints 0" let GDB doesn't use hardware breakpoint and set a watchpoint on "global", GDB continue will keep single step inside function "vfork". The Linux 2.6.32 and older version doesn't have commit 6580807da14c423f0d0a708108e6df6ebc8bc83d (get more info please goto http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=6580807da14c423f0d0a708108e6df6ebc8bc83d). When the function "vfork" do syscall, the single step flag TIF_SINGLESTEP will copy to child process. Then GDB detach it, child process and parent process will be hanged. So I make a patch that do a single step before detach. Then TIF_SINGLESTEP of child process in old Linux kernel will be cleared before detach. Child process in new Linux kernel will not be affected by this single step. 2014-06-08 Hui Zhu <hui@codesourcery.com> * common/linux-ptrace.c (linux_disable_event_reporting): New function. * common/linux-ptrace.h (linux_disable_event_reporting): New declaration. * linux-nat.c (linux_child_follow_fork): Do a single step before detach.
2014-06-06Remove preprocessor conditionals for ANSI-standard signalsGary Benson1-24/+0
The six signals SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV and SIGTERM are ANSI-standard and thus guaranteed to be available. This patch removes all preprocessor conditionals relating to these symbols. gdb/ 2014-06-06 Gary Benson <gbenson@redhat.com> * common/signals.c: Remove preprocessor conditionals for always-defined signals SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV and SIGTERM. * proc-events.c: Likewise. gdb/testsuite/ 2014-06-06 Gary Benson <gbenson@redhat.com> * gdb.base/call-signals.c: Remove preprocessor conditionals for always-defined signals SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV and SIGTERM. * gdb.base/sigall.c: Likewise. * gdb.base/unwindonsignal.c: Likewise. * gdb.reverse/sigall-reverse.c: Likewise.
2014-05-22Add new infrun.h header.Pedro Alves1-1/+1
Move infrun.c declarations out of inferior.h to a new infrun.h file. Tested by building on: i686-w64-mingw32, enable-targets=all x86_64-linux, enable-targets=all i586-pc-msdosdjgpp And also grepped the whole tree for each symbol moved to find where infrun.h might be necessary. gdb/ 2014-05-22 Pedro Alves <palves@redhat.com> * inferior.h (debug_infrun, debug_displaced, stop_on_solib_events) (sync_execution, sched_multi, step_stop_if_no_debug, non_stop) (disable_randomization, enum exec_direction_kind) (execution_direction, stop_registers, start_remote) (clear_proceed_status, proceed, resume, user_visible_resume_ptid) (wait_for_inferior, normal_stop, get_last_target_status) (prepare_for_detach, fetch_inferior_event, init_wait_for_inferior) (insert_step_resume_breakpoint_at_sal) (follow_inferior_reset_breakpoints, stepping_past_instruction_at) (set_step_info, print_stop_event, signal_stop_state) (signal_print_state, signal_pass_state, signal_stop_update) (signal_print_update, signal_pass_update) (update_signals_program_target, clear_exit_convenience_vars) (displaced_step_dump_bytes, update_observer_mode) (signal_catch_update, gdb_signal_from_command): Move declarations ... * infrun.h: ... to this new file. * amd64-tdep.c: Include infrun.h. * annotate.c: Include infrun.h. * arch-utils.c: Include infrun.h. * arm-linux-tdep.c: Include infrun.h. * arm-tdep.c: Include infrun.h. * break-catch-sig.c: Include infrun.h. * breakpoint.c: Include infrun.h. * common/agent.c: Include infrun.h instead of inferior.h. * corelow.c: Include infrun.h. * event-top.c: Include infrun.h. * go32-nat.c: Include infrun.h. * i386-tdep.c: Include infrun.h. * inf-loop.c: Include infrun.h. * infcall.c: Include infrun.h. * infcmd.c: Include infrun.h. * infrun.c: Include infrun.h. * linux-fork.c: Include infrun.h. * linux-nat.c: Include infrun.h. * linux-thread-db.c: Include infrun.h. * monitor.c: Include infrun.h. * nto-tdep.c: Include infrun.h. * procfs.c: Include infrun.h. * record-btrace.c: Include infrun.h. * record-full.c: Include infrun.h. * remote-m32r-sdi.c: Include infrun.h. * remote-mips.c: Include infrun.h. * remote-notif.c: Include infrun.h. * remote-sim.c: Include infrun.h. * remote.c: Include infrun.h. * reverse.c: Include infrun.h. * rs6000-tdep.c: Include infrun.h. * s390-linux-tdep.c: Include infrun.h. * solib-irix.c: Include infrun.h. * solib-osf.c: Include infrun.h. * solib-svr4.c: Include infrun.h. * target.c: Include infrun.h. * top.c: Include infrun.h. * windows-nat.c: Include infrun.h. * mi/mi-interp.c: Include infrun.h. * mi/mi-main.c: Include infrun.h. * python/py-threadevent.c: Include infrun.h.
2014-04-25PR server/16255: gdbserver cannot attach to a second inferior that is ↵Pedro Alves2-9/+9
multi-threaded. On Linux, we need to explicitly ptrace attach to all lwps of a process. Because GDB might not be connected yet when an attach is requested, and thus it may not be possible to activate thread_db, as that requires access to symbols (IOW, gdbserver --attach), a while ago we make linux_attach loop over the lwps as listed by /proc/PID/task to find the lwps to attach to. linux_attach_lwp_1 has: ... if (initial) /* If lwp is the tgid, we handle adding existing threads later. Otherwise we just add lwp without bothering about any other threads. */ ptid = ptid_build (lwpid, lwpid, 0); else { /* Note that extracting the pid from the current inferior is safe, since we're always called in the context of the same process as this new thread. */ int pid = pid_of (current_inferior); ptid = ptid_build (pid, lwpid, 0); } That "safe" comment referred to linux_attach_lwp being called by thread-db.c. But this was clearly missed when a new call to linux_attach_lwp_1 was added to linux_attach. As a result, current_inferior will be set to some random process, and non-initial lwps of the second inferior get assigned the pid of the wrong inferior. E.g., in the case of attaching to two inferiors, for the second inferior (and so on), non-initial lwps of the second inferior get assigned the pid of the first inferior. This doesn't trigger on the first inferior, when current_inferior is NULL, add_thread switches the current inferior to the newly added thread. Rather than making linux_attach switch current_inferior temporarily (thus avoiding further reliance on global state), or making linux_attach_lwp_1 get the tgid from /proc, which add extra syscalls, and will be wrong in case of the user having originally attached directly to a non-tgid lwp, and then that lwp spawning new clones (the ptid.pid field of further new clones should be the same as the original lwp's pid, which is not the tgid), we note that callers of linux_attach_lwp/linux_attach_lwp_1 always have the right pid handy already, so they can pass it down along with the lwpid. The only other reason for the "initial" parameter is to error out instead of warn in case of attach failure, when we're first attaching to a process. There are only three callers of linux_attach_lwp/linux_attach_lwp_1, and each wants to print a different warn/error string, so we can just move the error/warn out of linux_attach_lwp_1 to the callers, thus getting rid of the "initial" parameter. There really nothing gdbserver-specific about attaching to two threaded processes, so this adds a new test under gdb.multi/. The test passes cleanly against the native GNU/Linux target, but fails/triggers the bug against GDBserver (before the patch), with the native-extended-remote board (as plain remote doesn't support multi-process). Tested on x86_64 Fedora 17, with the native-extended-gdbserver board. gdb/gdbserver/ 2014-04-25 Pedro Alves <palves@redhat.com> PR server/16255 * linux-low.c (linux_attach_fail_reason_string): New function. (linux_attach_lwp): Delete. (linux_attach_lwp_1): Rename to ... (linux_attach_lwp): ... this. Take a ptid instead of a pid as argument. Remove "initial" parameter. Return int instead of void. Don't error or warn here. (linux_attach): Adjust to call linux_attach_lwp. Call error on failure to attach to the tgid. Call warning when failing to attach to an lwp. * linux-low.h (linux_attach_lwp): Take a ptid instead of a pid as argument. Remove "initial" parameter. Return int instead of void. Don't error or warn here. (linux_attach_fail_reason_string): New declaration. * thread-db.c (attach_thread): Adjust to linux_attach_lwp's interface change. Use linux_attach_fail_reason_string. gdb/ 2014-04-25 Pedro Alves <palves@redhat.com> PR server/16255 * common/linux-ptrace.c (linux_ptrace_attach_warnings): Rename to ... (linux_ptrace_attach_fail_reason): ... this. Remove "warning: " and newline from built string. * common/linux-ptrace.h (linux_ptrace_attach_warnings): Rename to ... (linux_ptrace_attach_fail_reason): ... this. * linux-nat.c (linux_nat_attach): Adjust to use linux_ptrace_attach_fail_reason. gdb/testsuite/ 2014-04-25 Simon Marchi <simon.marchi@ericsson.com> Pedro Alves <palves@redhat.com> PR server/16255 * gdb.multi/multi-attach.c: New file. * gdb.multi/multi-attach.exp: New file.
2014-04-24Add AVX512 registers support to GDB and GDBserver.Michael Sturm1-4/+16
This patch adds support for the Intel(R) Advanced Vector Extensions 512 (Intel(R) AVX-512) registers. Native and remote debugging are covered by this patch. Intel(R) AVX-512 is an extension to AVX to support 512-bit wide SIMD registers in 64-bit mode (XMM0-XMM31, YMM0-YMM31, ZMM0-ZMM31). The number of available registers in 32-bit mode is still 8 (XMM0-7, YMM0-7, ZMM0-7). The lower 256-bits of the ZMM registers are aliased to the respective 256-bit YMM registers. The lower 128-bits are aliased to the respective 128-bit XMM registers. There are also 8 new, dedicated mask registers (K0-K7) in both 32-bit mode and 64-bit mode. For more information please see Intel(R) Developer Zone: Intel(R) AVX http://software.intel.com/en-us/intel-isa-extensions#pid-16007-1495 Intel(R) Architecture Instruction Set Extensions Programming Reference: http://software.intel.com/en-us/file/319433-017pdf 2014-04-24 Michael Sturm <michael.sturm@mintel.com> Walfred Tedeschi <walfred.tedeschi@intel.com> * amd64-linux-nat.c (amd64_linux_gregset32_reg_offset): Add AVX512 registers. (amd64_linux_read_description): Add code to handle AVX512 xstate mask and return respective tdesc. * amd64-linux-tdep.c: Include features/i386/amd64-avx512-linux.c and features/i386/x32-avx512-linux.c. (amd64_linux_gregset_reg_offset): Add AVX512 registers. (amd64_linux_core_read_description): Add code to handle AVX512 xstate mask and return respective tdesc. (_initialize_amd64_linux_tdep): Initialize AVX512 tdesc. * amd64-linux-tdep.h (AMD64_LINUX_ORIG_RAX_REGNUM): Adjust regnum calculation. (AMD64_LINUX_NUM_REGS): Adjust to new number of registers. (tdesc_amd64_avx512_linux): New prototype. (tdesc_x32_avx512_linux): Likewise. * amd64-tdep.c: Include features/i386/amd64-avx512.c and features/i386/x32-avx512.c. (amd64_ymm_avx512_names): New register names for pseudo registers YMM16-31. (amd64_ymmh_avx512_names): New register names for raw registers YMMH16-31. (amd64_k_names): New register names for K registers. (amd64_zmmh_names): New register names for ZMM raw registers. (amd64_zmm_names): New registers names for ZMM pseudo registers. (amd64_xmm_avx512_names): New register names for XMM16-31 registers. (amd64_pseudo_register_name): Add code to return AVX512 pseudo registers. (amd64_init_abi): Add code to intitialize AVX512 tdep variables if feature is present. (_initialize_amd64_tdep): Call AVX512 tdesc initializers. * amd64-tdep.h (enum amd64_regnum): Add AVX512 registers. (AMD64_NUM_REGS): Adjust to new number of registers. * i386-linux-nat.c (GETXSTATEREGS_SUPPLIES): Extend range of registers supplied via XSTATE by AVX512 registers. (i386_linux_read_description): Add case for AVX512. * i386-linux-tdep.c: Include i386-avx512-linux.c. (i386_linux_gregset_reg_offset): Add AVX512 registers. (i386_linux_core_read_description): Add case for AVX512. (i386_linux_init_abi): Install supported register note section for AVX512. (_initialize_i386_linux_tdep): Add call to tdesc init function for AVX512. * i386-linux-tdep.h (I386_LINUX_NUM_REGS): Set number of registers to be number of zmm7h + 1. (tdesc_i386_avx512_linux): Add tdesc for AVX512 registers. * i386-tdep.c: Include features/i386/i386-avx512.c. (i386_zmm_names): Add ZMM pseudo register names array. (i386_zmmh_names): Add ZMM raw register names array. (i386_k_names): Add K raw register names array. (num_lower_zmm_regs): Add constant for the number of lower ZMM registers. AVX512 has 16 more ZMM registers than there are YMM registers. (i386_zmmh_regnum_p): Add function to look up register number of ZMM raw registers. (i386_zmm_regnum_p): Likewise for ZMM pseudo registers. (i386_k_regnum_p): Likewise for K raw registers. (i386_ymmh_avx512_regnum_p): Likewise for additional YMM raw registers added by AVX512. (i386_ymm_avx512_regnum_p): Likewise for additional YMM pseudo registers added by AVX512. (i386_xmm_avx512_regnum_p): Likewise for additional XMM registers added by AVX512. (i386_register_name): Add code to hide YMMH16-31 and ZMMH0-31. (i386_pseudo_register_name): Add ZMM pseudo registers. (i386_zmm_type): Construct and return vector registers type for ZMM registers. (i386_pseudo_register_type): Return appropriate type for YMM16-31, ZMM0-31 pseudo registers and K registers. (i386_pseudo_register_read_into_value): Add code to read K, ZMM and YMM16-31 registers from register cache. (i386_pseudo_register_write): Add code to write K, ZMM and YMM16-31 registers. (i386_register_reggroup_p): Add code to include/exclude AVX512 registers in/from respective register groups. (i386_validate_tdesc_p): Handle AVX512 feature, add AVX512 registers if feature is present in xcr0. (i386_gdbarch_init): Add code to initialize AVX512 feature variables in tdep structure, wire in pseudo registers and call initialize_tdesc_i386_avx512. * i386-tdep.h (struct gdbarch_tdep): Add AVX512 related variables. (i386_regnum): Add AVX512 registers. (I386_SSE_NUM_REGS): New define for number of SSE registers. (I386_AVX_NUM_REGS): Likewise for AVX registers. (I386_AVX512_NUM_REGS): Likewise for AVX512 registers. (I386_MAX_REGISTER_SIZE): Change to 64 bytes, ZMM registers are 512 bits wide. (i386_xmm_avx512_regnum_p): New prototype for register look up. (i386_ymm_avx512_regnum_p): Likewise. (i386_k_regnum_p): Likewise. (i386_zmm_regnum_p): Likewise. (i386_zmmh_regnum_p): Likewise. * i387-tdep.c : Update year in copyright notice. (xsave_ymm_avx512_offset): New table for YMM16-31 offsets in XSAVE buffer. (XSAVE_YMM_AVX512_ADDR): New macro. (xsave_xmm_avx512_offset): New table for XMM16-31 offsets in XSAVE buffer. (XSAVE_XMM_AVX512_ADDR): New macro. (xsave_avx512_k_offset): New table for K register offsets in XSAVE buffer. (XSAVE_AVX512_K_ADDR): New macro. (xsave_avx512_zmm_h_offset): New table for ZMM register offsets in XSAVE buffer. (XSAVE_AVX512_ZMM_H_ADDR): New macro. (i387_supply_xsave): Add code to supply AVX512 registers to XSAVE buffer. (i387_collect_xsave): Add code to collect AVX512 registers from XSAVE buffer. * i387-tdep.h (I387_NUM_XMM_AVX512_REGS): New define for number of XMM16-31 registers. (I387_NUM_K_REGS): New define for number of K registers. (I387_K0_REGNUM): New define for K0 register number. (I387_NUM_ZMMH_REGS): New define for number of ZMMH registers. (I387_ZMM0H_REGNUM): New define for ZMM0H register number. (I387_NUM_YMM_AVX512_REGS): New define for number of YMM16-31 registers. (I387_YMM16H_REGNUM): New define for YMM16H register number. (I387_XMM16_REGNUM): New define for XMM16 register number. (I387_YMM0_REGNUM): New define for YMM0 register number. (I387_KEND_REGNUM): New define for last K register number. (I387_ZMMENDH_REGNUM): New define for last ZMMH register number. (I387_YMMH_AVX512_END_REGNUM): New define for YMM31 register number. (I387_XMM_AVX512_END_REGNUM): New define for XMM31 register number. * common/i386-xstate.h: Add AVX 3.1 feature bits, mask and XSTATE size. * features/Makefile: Add AVX512 related files. * features/i386/32bit-avx512.xml: New file. * features/i386/64bit-avx512.xml: Likewise. * features/i386/amd64-avx512-linux.c: Likewise. * features/i386/amd64-avx512-linux.xml: Likewise. * features/i386/amd64-avx512.c: Likewise. * features/i386/amd64-avx512.xml: Likewise. * features/i386/i386-avx512-linux.c: Likewise. * features/i386/i386-avx512-linux.xml: Likewise. * features/i386/i386-avx512.c: Likewise. * features/i386/i386-avx512.xml: Likewise. * features/i386/x32-avx512-linux.c: Likewise. * features/i386/x32-avx512-linux.xml: Likewise. * features/i386/x32-avx512.c: Likewise. * features/i386/x32-avx512.xml: Likewise. * regformats/i386/amd64-avx512-linux.dat: New file. * regformats/i386/amd64-avx512.dat: Likewise. * regformats/i386/i386-avx512-linux.dat: Likewise. * regformats/i386/i386-avx512.dat: Likewise. * regformats/i386/x32-avx512-linux.dat: Likewise. * regformats/i386/x32-avx512.dat: Likewise. * NEWS: Add note about new support for AVX512. testsuite/ * Makefile.in (EXECUTABLES): Added i386-avx512. * gdb.arch/i386-avx512.c: New file. * gdb.arch/i386-avx512.exp: Likewise. gdbserver/ * Makefile.in: Added rules to handle new files i386-avx512.c i386-avx512-linux.c amd64-avx512.c amd64-avx512-linux.c x32-avx512.c x32-avx512-linux.c. * configure.srv (srv_i386_regobj): Add i386-avx512.o. (srv_i386_linux_regobj): Add i386-avx512-linux.o. (srv_amd64_regobj): Add amd64-avx512.o and x32-avx512.o. (srv_amd64_linux_regobj): Add amd64-avx512-linux.o and x32-avx512-linux.o. (srv_i386_32bit_xmlfiles): Add i386/32bit-avx512.xml. (srv_i386_64bit_xmlfiles): Add i386/64bit-avx512.xml. (srv_amd64_xmlfiles): Add i386/amd64-avx512.xml and i386/x32-avx512.xml. (srv_i386_linux_xmlfiles): Add i386/i386-avx512-linux.xml. (srv_amd64_linux_xmlfiles): Add i386/amd64-avx512-linux.xml and i386/x32-avx512-linux.xml. * i387-fp.c (num_avx512_k_registers): New constant for number of K registers. (num_avx512_zmmh_low_registers): New constant for number of lower ZMM registers (0-15). (num_avx512_zmmh_high_registers): New constant for number of higher ZMM registers (16-31). (num_avx512_ymmh_registers): New contant for number of higher YMM registers (ymm16-31 added by avx521 on x86_64). (num_avx512_xmm_registers): New constant for number of higher XMM registers (xmm16-31 added by AVX512 on x86_64). (struct i387_xsave): Add space for AVX512 registers. (i387_cache_to_xsave): Change raw buffer size to 64 characters. Add code to handle AVX512 registers. (i387_xsave_to_cache): Add code to handle AVX512 registers. * linux-x86-low.c (init_registers_amd64_avx512_linux): New prototypei from generated file. (tdesc_amd64_avx512_linux): Likewise. (init_registers_x32_avx512_linux): Likewise. (tdesc_x32_avx512_linux): Likewise. (init_registers_i386_avx512_linux): Likewise. (tdesc_i386_avx512_linux): Likewise. (x86_64_regmap): Add AVX512 registers. (x86_linux_read_description): Add code to handle AVX512 XSTATE mask. (initialize_low_arch): Add code to initialize AVX512 registers. doc/ * gdb.texinfo (i386 Features): Add description of AVX512 registers. Change-Id: Ifc4c08c76b85dbec18d02efdbe6182e851584438 Signed-off-by: Michael Sturm <michael.sturm@intel.com>
2014-02-27Move ptid_match to common/ptid.c.Hui Zhu2-0/+24
So that gdbserver can use it too. gdb/ 2014-02-27 Hui Zhu <hui@codesourcery.com> PR 12702 * infrun.c (ptid_match): Move ... * common/ptid.c (ptid_match): ... here. * inferior.h (ptid_match): Move ... * common/ptid.h (ptid_match): ... here.
2014-02-26start change to progspace independenceTom Tromey1-1/+2
This patch starts changing minimal symbols to be independent of the program space. Specifically, it adds a new objfile parameter to MSYMBOL_VALUE_ADDRESS and changes all the code to use it. This is needed so we can change gdb to apply the section offset when a minsym's address is computed, as opposed to baking the offsets into the symbol itself. A few spots still need the unrelocated address. For these, we introduce MSYMBOL_VALUE_RAW_ADDRESS. As a convenience, we also add the new macro BMSYMBOL_VALUE_ADDRESS, which computes the address of a bound minimal symbol. This just does the obvious thing with the fields. Note that this change does not actually enable program space independence. That requires more changes to gdb. However, to ensure that these changes compile properly, this patch does add the needed section lookup code to MSYMBOL_VALUE_ADDRESS -- it just ensures it has no effect at runtime by multiplying the offset by 0. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_main_name): Update. (ada_add_standard_exceptions): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (skip_prologue_function, arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * blockframe.c (get_pc_function_start) (find_pc_partial_function_gnu_ifunc): Update. * breakpoint.c (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-valprint.c (c_val_print): Update. * coff-pe-read.c (add_pe_forwarded_sym): Update. * common/agent.c (agent_look_up_symbols): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * dwarf2read.c (dw2_find_pc_sect_symtab): Update. * elfread.c (elf_gnu_ifunc_record_cache) (elf_gnu_ifunc_resolve_by_got): Update. * findvar.c (default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * hppa-hpux-tdep.c (hppa64_hpux_search_dummy_call_sequence) (hppa_hpux_find_dummy_bpaddr): Update. * hppa-tdep.c (hppa_symbol_address): Update. * infcmd.c (until_next_command): Update. * jit.c (jit_read_descriptor, jit_breakpoint_re_set_internal): Update. * linespec.c (minsym_found, add_minsym): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update. * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * maint.c (maintenance_translate_address): Update. * minsyms.c (lookup_minimal_symbol_by_pc_name): Update. (frob_address): New function. (lookup_minimal_symbol_by_pc_section_1): Use raw addresses, frob_address. Rename parameter to "pc_in". (compare_minimal_symbols, compact_minimal_symbols): Use raw addresses. (find_solib_trampoline_target, minimal_symbol_upper_bound): Update. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * mips-tdep.c (mips_skip_pic_trampoline_code): Update. * objc-lang.c (find_objc_msgsend): Update. * objfiles.c (objfile_relocate1): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-valprint.c (pascal_val_print): Update. * parse.c (write_exp_msymbol): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup) (ppc_elfv2_skip_entrypoint): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * printcmd.c (build_address_symbolic, msym_info) (address_info): Update. * proc-service.c (ps_pglobal_lookup): Update. * psymtab.c (find_pc_sect_psymtab_closer) (find_pc_sect_psymtab, find_pc_sect_symtab_from_partial): Change msymbol parameter to bound_minimal_symbol. * ravenscar-thread.c (get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sh64-tdep.c (sh64_elf_make_msymbol_special): Use raw address. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, main_got): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (link_map_start): Update. * solib-spu.c (spu_enable_break, ocl_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol, scan_file_globals): Update. * stack.c (find_frame_funname): Update. * symfile-debug.c (debug_qf_expand_symtabs_matching) (debug_qf_find_pc_sect_symtab): Update. * symfile.c (simple_read_overlay_table) (simple_overlay_update): Update. * symfile.h (struct quick_symbol_functions) <find_pc_sect_symtab>: Change type of msymbol to bound_minimal_symbol. * symmisc.c (dump_msymbols): Update. * symtab.c (find_pc_sect_symtab_via_partial) (find_pc_sect_psymtab, find_pc_sect_line, skip_prologue_sal) (search_symbols, print_msymbol_info): Update. * symtab.h (MSYMBOL_VALUE_RAW_ADDRESS): New macro. (MSYMBOL_VALUE_ADDRESS): Redefine. (BMSYMBOL_VALUE_ADDRESS): New macro. * tracepoint.c (scope_info): Update. * tui/tui-disasm.c (tui_find_disassembly_address) (tui_get_begin_asm_address): Update. * valops.c (find_function_in_inferior): Update. * value.c (value_static_field, value_fn_field): Update.
2014-02-26use bound_minsym as result for lookup_minimal_symbol et alTom Tromey1-3/+3
This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2014-02-26change minsym representationTom Tromey1-1/+1
In a later patch we're going to change the minimal symbol address calculation to apply section offsets at the point of use. To make it simpler to catch potential problem spots, this patch changes the representation of minimal symbols and introduces new minimal-symbol-specific variants of the various accessors. This is necessary because it would be excessively ambitious to try to convert all the symbol types at once. The core of this change is just renaming a field in minimal_symbol; the rest is just a fairly mechanical rewording. 2014-02-26 Tom Tromey <tromey@redhat.com> * symtab.h (struct minimal_symbol) <mginfo>: Rename from ginfo. (MSYMBOL_VALUE, MSYMBOL_VALUE_ADDRESS, MSYMBOL_VALUE_BYTES) (MSYMBOL_BLOCK_VALUE, MSYMBOL_VALUE_CHAIN, MSYMBOL_LANGUAGE) (MSYMBOL_SECTION, MSYMBOL_OBJ_SECTION, MSYMBOL_NATURAL_NAME) (MSYMBOL_LINKAGE_NAME, MSYMBOL_PRINT_NAME, MSYMBOL_DEMANGLED_NAME) (MSYMBOL_SET_LANGUAGE, MSYMBOL_SEARCH_NAME) (MSYMBOL_MATCHES_SEARCH_NAME, MSYMBOL_SET_NAMES): New macros. * ada-lang.c (ada_main_name): Update. (ada_lookup_simple_minsym): Update. (ada_make_symbol_completion_list): Update. (ada_add_standard_exceptions): Update. * ada-tasks.c (read_atcb, ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * amd64-windows-tdep.c (amd64_skip_main_prologue): Update. * arm-tdep.c (skip_prologue_function): Update. (arm_skip_stack_protector, arm_skip_stub): Update. * arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update. (arm_wince_skip_main_prologue): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * block.c (call_site_for_pc): Update. * blockframe.c (get_pc_function_start): Update. (find_pc_partial_function_gnu_ifunc): Update. * breakpoint.c (create_overlay_event_breakpoint): Update. (create_longjmp_master_breakpoint): Update. (create_std_terminate_master_breakpoint): Update. (create_exception_master_breakpoint): Update. (resolve_sal_pc): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * btrace.c (ftrace_print_function_name, ftrace_function_switched): Update. * c-valprint.c (c_val_print): Update. * coff-pe-read.c (add_pe_forwarded_sym): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * dbxread.c (find_stab_function_addr): Update. (end_psymtab): Update. * dwarf2loc.c (call_site_to_target_addr): Update. (func_verify_no_selftailcall): Update. (tailcall_dump): Update. (call_site_find_chain_1): Update. (dwarf_expr_reg_to_entry_parameter): Update. * elfread.c (elf_gnu_ifunc_record_cache): Update. (elf_gnu_ifunc_resolve_by_got): Update. * f-valprint.c (info_common_command): Update. * findvar.c (read_var_value): Update. * frame.c (get_prev_frame_1): Update. (inside_main_func): Update. * frv-tdep.c (frv_skip_main_prologue): Update. (frv_frame_this_id): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v2-abi.c (gnuv2_value_rtti_type): Update. * gnu-v3-abi.c (gnuv3_rtti_type): Update. (gnuv3_skip_trampoline): Update. * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline): Update. (hppa64_hpux_in_solib_call_trampoline): Update. (hppa_hpux_skip_trampoline_code): Update. (hppa64_hpux_search_dummy_call_sequence): Update. (hppa_hpux_find_import_stub_for_addr): Update. (hppa_hpux_find_dummy_bpaddr): Update. * hppa-tdep.c (hppa_symbol_address) (hppa_lookup_stub_minimal_symbol): Update. * i386-tdep.c (i386_skip_main_prologue): Update. (i386_pe_skip_trampoline_code): Update. * ia64-tdep.c (ia64_convert_from_func_ptr_addr): Update. * infcall.c (get_function_name): Update. * infcmd.c (until_next_command): Update. * jit.c (jit_breakpoint_re_set_internal): Update. (jit_inferior_init): Update. * linespec.c (minsym_found): Update. (add_minsym): Update. * linux-fork.c (info_checkpoints_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update. * m32c-tdep.c (m32c_return_value): Update. (m32c_m16c_address_to_pointer): Update. (m32c_m16c_pointer_to_address): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * maint.c (maintenance_translate_address): Update. * minsyms.c (add_minsym_to_hash_table): Update. (add_minsym_to_demangled_hash_table): Update. (msymbol_objfile): Update. (lookup_minimal_symbol): Update. (iterate_over_minimal_symbols): Update. (lookup_minimal_symbol_text): Update. (lookup_minimal_symbol_by_pc_name): Update. (lookup_minimal_symbol_solib_trampoline): Update. (lookup_minimal_symbol_by_pc_section_1): Update. (lookup_minimal_symbol_and_objfile): Update. (prim_record_minimal_symbol_full): Update. (compare_minimal_symbols): Update. (compact_minimal_symbols): Update. (build_minimal_symbol_hash_tables): Update. (install_minimal_symbols): Update. (terminate_minimal_symbol_table): Update. (find_solib_trampoline_target): Update. (minimal_symbol_upper_bound): Update. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * mips-tdep.c (mips_stub_frame_sniffer): Update. (mips_skip_pic_trampoline_code): Update. * msp430-tdep.c (msp430_skip_trampoline_code): Update. * objc-lang.c (selectors_info): Update. (classes_info): Update. (find_methods): Update. (find_imps): Update. (find_objc_msgsend): Update. * objfiles.c (objfile_relocate1): Update. * objfiles.h (ALL_OBJFILE_MSYMBOLS): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-valprint.c (pascal_val_print): Update. * parse.c (write_exp_msymbol): Update. * ppc-linux-tdep.c (powerpc_linux_in_dynsym_resolve_code) (ppc_linux_spe_context_lookup, ppc_elfv2_skip_entrypoint): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * printcmd.c (build_address_symbolic): Update. (sym_info): Update. (address_info): Update. * proc-service.c (ps_pglobal_lookup): Update. * psymtab.c (find_pc_sect_psymtab_closer): Update. (find_pc_sect_psymtab): Update. * python/py-framefilter.c (py_print_frame): Update. * ravenscar-thread.c (get_running_thread_id): Update. * record-btrace.c (btrace_call_history, btrace_get_bfun_name): Update. * remote.c (remote_check_symbols): Update. * rs6000-tdep.c (rs6000_skip_main_prologue): Update. (rs6000_skip_trampoline_code): Update. * sh64-tdep.c (sh64_elf_make_msymbol_special): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base): Update. (main_got): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook): Update. (som_solib_desire_dynamic_linker_symbols): Update. (link_map_start): Update. * solib-spu.c (spu_enable_break): Update. (ocl_enable_break): Update. * solib-svr4.c (elf_locate_base): Update. (enable_break): Update. * spu-tdep.c (spu_get_overlay_table): Update. (spu_catch_start): Update. (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. (scan_file_globals): Update. * stack.c (find_frame_funname): Update. (frame_info): Update. * symfile.c (simple_read_overlay_table): Update. (simple_overlay_update): Update. * symmisc.c (dump_msymbols): Update. * symtab.c (fixup_section): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (search_symbols): Update. (print_msymbol_info): Update. (rbreak_command): Update. (MCOMPLETION_LIST_ADD_SYMBOL): New macro. (completion_list_objc_symbol): Update. (default_make_symbol_completion_list_break_on): Update. * tracepoint.c (scope_info): Update. * tui/tui-disasm.c (tui_find_disassembly_address): Update. (tui_get_begin_asm_address): Update. * valops.c (find_function_in_inferior): Update. * value.c (value_static_field): Update. (value_fn_field): Update.
2014-02-21Fix crash on process name "(sd-pam)" (PR 16594).Jan Kratochvil1-10/+6
info os processes -fsanitize=address error https://sourceware.org/bugzilla/show_bug.cgi?id=16594 info os processes ================================================================= ==5795== ERROR: AddressSanitizer: heap-use-after-free on address 0x600600214974 at pc 0x757a92 bp 0x7fff95dd9f00 sp 0x7fff95dd9ef0 READ of size 4 at 0x600600214974 thread T0 #0 0x757a91 in get_cores_used_by_process (.../gdb/gdb+0x757a91) At least Fedora 20 has process(es): 6678 ? Ss 0:00 /usr/lib/systemd/systemd --user 6680 ? S 0:00 \_ (sd-pam) and GDB "info os processes" crashes on it as /proc/6680/stat contains: 6680 ((sd-pam)) S 6678 6678 6678 0 -1 1077961024 33 0 0 0 0 0 0 0 20 0 1 0 18568 73768960 120 18446744073709551615 1 1 0 0 0 0 0 4096 0 18446744073709551615 0 0 17 6 0 0 0 0 0 0 0 0 0 0 0 0 0 and GDB fails to find the proper end of the process name "((sd-pam))". Therefore it reads core number off-by-one (it reads 17 instead of 6) and overruns the array. (1) Make the process name parsing more foolproof. (2) Do not trust the parsed number from /proc/PID/stat and verify it against the array size. I noticed that 'ps' gets this right, so I've peeked at its sources, and it just looks for the first ')' starting at the end. https://gitorious.org/procps/procps/source/dc072aced7250fed9b01fb05f0d672678752a63e:proc/readproc.c Look for stat2proc. Given ps does that, I believe the kernel won't ever be changed in a way that would break it. So it sounds like could do strrchr from the end of stat just as well without worry, which is simpler. gdb/ 2014-02-21 Jan Kratochvil <jan.kratochvil@redhat.com> PR gdb/16594 * common/linux-osdata.c (linux_common_core_of_thread): Find the end of process name. (get_cores_used_by_process): New parameter num_cores, use it. (linux_xfer_osdata_processes): Pass num_cores to it. * linux-tdep.c (linux_info_proc, linux_fill_prpsinfo): Find the end of process name. Message-ID: <20140217212826.GA15080@host2.jankratochvil.net>
2014-02-19common/ptid.h: Mention that process_stratum targets should prefer ptid.lwp.Pedro Alves1-1/+6
It's best that we standardize on process_stratum targets using the ptid.lwp field to store thread ids. The idea being leave the ptid.tid field free for any thread_stratum target that might want to sit on top. This patch adds a comment in that direction to struct ptid's definition. gdb/ 2014-02-19 Pedro Alves <palves@redhat.com> * common/ptid.h (struct ptid): Mention that process_stratum targets should prefer ptid.lwp.
2014-02-19convert to_supports_btraceTom Tromey2-3/+3
This adds a "self" argument to to_supports_btrace. Due to how one implementation of this method is shared with gdbserver this required a small change to gdbserver as well. 2014-02-19 Tom Tromey <tromey@redhat.com> * common/linux-btrace.c (linux_supports_btrace): Add "ops" argument. * common/linux-btrace.h (linux_supports_btrace): Update. * remote.c (remote_supports_btrace): Add "self" argument. * target-delegates.c: Rebuild. * target.c (target_supports_btrace): Remove. * target.h (struct target_ops) <to_supports_btrace>: Add target_ops argument. (target_supports_btrace): New define. 2014-02-19 Tom Tromey <tromey@redhat.com> * target.h (struct target_ops) <supports_btrace>: Add target_ops argument. (target_supports_btrace): Update.
2014-02-12update rsp-low commentsTom Tromey2-1/+38
This updates all the comments in rsp-low.[ch], now that the unification has been completed. 2014-02-12 Tom Tromey <tromey@redhat.com> * common/rsp-low.c: Update comments. * common/rsp-low.h: Update comments.
2014-02-12replace convert_ascii_to_int with hex2binTom Tromey2-14/+0
convert_ascii_to_int is identical to hex2bin. This removes the former. 2014-02-12 Tom Tromey <tromey@redhat.com> * common/rsp-low.c (convert_ascii_to_int): Remove. * common/rsp-low.h (convert_ascii_to_int): Don't declare. 2014-02-12 Tom Tromey <tromey@redhat.com> * ax.c (gdb_parse_agent_expr): Use hex2bin, not convert_ascii_to_int. * regcache.c (registers_to_string): Likewise. * remote-utils.c (decode_M_packet): Likewise. * server.c (process_serial_event): Likewise.
2014-02-12replace unhexify with hex2binTom Tromey2-21/+0
unhexify and hex2bin are identical, so this removes unhexify. The particular choice of which to keep was made on the basis of parallelism with the earlier patch that removed hexify. 2014-02-12 Tom Tromey <tromey@redhat.com> * common/rsp-low.h (unhexify): Don't declare. * common/rsp-low.c (unhexify): Remove. 2014-02-12 Tom Tromey <tromey@redhat.com> * server.c (handle_query, handle_v_run): Use hex2bin, not unhexify. * tracepoint.c (cmd_qtdpsrc, cmd_qtdv, cmd_qtnotes): Likewise.
2014-02-12replace convert_int_to_ascii with bin2hexTom Tromey2-18/+0
convert_int_to_ascii is identical to bin2hex. This removes the former. In this case I made the choice of which to keep on the basis that I consider the name bin2hex to be superior to convert_int_to_ascii. 2014-02-12 Tom Tromey <tromey@redhat.com> * common/rsp-low.h (convert_int_to_ascii): Don't declare. * common/rsp-low.c (convert_int_to_ascii): Remove. 2014-02-12 Tom Tromey <tromey@redhat.com> * ax.c (gdb_unparse_agent_expr): Use bin2hex, not convert_int_to_ascii. * regcache.c (registers_to_string, collect_register_as_string): Likewise. * remote-utils.c (look_up_one_symbol, relocate_instruction): Likewise. * server.c (process_serial_event): Likewise. * tracepoint.c (cmd_qtstatus, response_source, response_tsv) (cmd_qtbuffer, cstr_to_hexstr): Likewise.
2014-02-12replace hexify with bin2hexTom Tromey2-16/+0
This removes hexify in favor of bin2hex. The choice of which to keep was arbitrary. 2014-02-12 Tom Tromey <tromey@redhat.com> * common/rsp-low.h (hexify): Don't declare. * common/rsp-low.c (hexify): Remove. 2014-02-12 Tom Tromey <tromey@redhat.com> * remote-utils.c (look_up_one_symbol, monitor_output): Use bin2hex, not hexify. * tracepoint.c (cmd_qtstatus): Likewise.
2014-02-12don't let hexify call strlenTom Tromey1-4/+0
hexify had the same issue as bin2hex; and the fix is the same. 2014-02-12 Tom Tromey <tromey@redhat.com> * common/rsp-low.c (hexify): Never take strlen of argument. 2014-02-12 Tom Tromey <tromey@redhat.com> * remote-utils.c (monitor_output): Pass explicit length to hexify.
2014-02-12don't let bin2hex call strlenTom Tromey1-4/+0
Currently bin2hex may call strlen if the length argument is zero. This prevents some function unification; and also it seems cleaner to me not to have a special meaning for a zero length. 2014-02-12 Tom Tromey <tromey@redhat.com> * common/rsp-low.c (bin2hex): Never take strlen of argument. * remote.c (extended_remote_run, remote_rcmd) (remote_download_trace_state_variable, remote_save_trace_data) (remote_set_trace_notes): Update. * tracepoint.c (encode_source_string, tfile_write_status) (tfile_write_uploaded_tsv): Update.
2014-02-12move some rsp bits into rsp-low.hTom Tromey2-0/+347
This moves various low-level remote serial protocol bits into common/rsp-low.[ch]. This is as close to a pure move as possible. There are some redundancies remaining but those will be dealt with in a subsequent patch. Note that the two variants of remote_escape_output disagreed on the treatment of "*". On the theory that quoting cannot hurt but the absence possibly can, I chose the gdbserver variant to be the canonical one. 2014-02-12 Tom Tromey <tromey@redhat.com> * tracepoint.c: Include rsp-low.h. * remote.h (hex2bin, bin2hex, unpack_varlen_hex): Don't declare. * remote.c: Include rsp-low.h. (hexchars, ishex, unpack_varlen_hex, pack_nibble, pack_hex_byte) (fromhex, hex2bin, tohex, bin2hex, remote_escape_output) (remote_unescape_input): Move to common/rsp-low.c. * common/rsp-low.h: New file. * common/rsp-low.c: New file. * Makefile.in (SFILES): Add common/rsp-low.c. (HFILES_NO_SRCDIR): Add common/rsp-low.h. (COMMON_OBS): Add rsp-low.o. (rsp-low.o): New target. 2014-02-12 Tom Tromey <tromey@redhat.com> * tracepoint.c: Include rsp-low.h. * server.c: Include rsp-low.h. * remote-utils.h (convert_ascii_to_int, convert_int_to_ascii) (unhexify, hexify, remote_escape_output, unpack_varlen_hex): Don't declare. * remote-utils.c: Include rsp-low.h. (fromhex, hexchars, ishex, unhexify, tohex, hexify) (remote_escape_output, remote_unescape_input, unpack_varlen_hex) (convert_int_to_ascii, convert_ascii_to_int): Move to common/rsp-low.c. * regcache.c: Include rsp-low.h. * ax.c: Include rsp-low.h. * Makefile.in (SFILES): Add common/rsp-low.c. (OBS): Add rsp-low.o. (rsp-low.o): New target.
2014-02-12share "cell" codeTom Tromey2-0/+404
The "cell"-based printing code, like phex, was duplicated in both gdb and gdbserver. This patch merges the two implementations into a new file in common/. 2014-02-12 Tom Tromey <tromey@redhat.com> * utils.h: Include print-utils.h. (host_address_to_string, plongest, pulongest, phex, phex_nz) (int_string, core_addr_to_string, core_addr_to_string_nz) (hex_string, hex_string_custom): Don't declare. * utils.c (NUMCELLS, CELLSIZE, get_cell, decimal2str, pulongest) (plongest, thirty_two, phex, phex_nz, octal2str, hex_string) (hex_string_custom, int_string, core_addr_to_string) (core_addr_to_string_nz, host_address_to_string): Move to common/print-utils.c. * common/print-utils.h: New file. * common/print-utils.c: New file * Makefile.in (SFILES): Add common/print-utils.c. (HFILES_NO_SRCDIR): Add common/print-utils.h. (COMMON_OBS): Add print-utils.o. (print-utils.o): New target. 2014-02-12 Tom Tromey <tromey@redhat.com> * utils.h (pulongest, plongest, phex_nz): Don't declare. Include print-utils.h. * utils.c (NUMCELLS, CELLSIZE, get_cell, decimal2str, pulongest) (plongest, thirty_two, phex_nz): Remove. * Makefile.in (SFILES): Add common/print-utils.c. (OBS): Add print-utils.o. (print-utils-ipa.o): New target. (print-utils.o): New target. (IPA_OBJS): Add print-utils-ipa.o.
2014-01-22Add ARI (ok) marker for __func__ reference in common-utils.hJoel Brobecker1-1/+1
The ARI script flagged the use of the __func__ variable, which is normally not allowed (not defined in C90). However, this particular use is OK, as the reference is only made when __STDC_VERSION__ >= 199901L. So, add an "ARI:" comment to explicitly OK this use. gdb/ChangeLog: * common/common-utils.h: Add "ARI:" comment beside __func__ reference.
2014-01-22Expand documentation of common-utils.h::FUNCTION_NAMEJoel Brobecker1-1/+6
While looking at this macro, I noticed that it wasn't always necessarily defined. That prompted me to search the current sources to make sure that all uses were adequately protected, which they were. But to help prevent future uses to be made unprotected, this patch expands the current macro documentation a bit. gdb/ChangeLog: * common/common-utils.h (FUNCTION_NAME): Expand the macro's documentation a bit.
2014-01-17Add delim_string_to_char_ptr_vec.Doug Evans2-17/+45
* common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): New function, contents of dirnames_to_char_ptr_vec_append moved here. (delim_string_to_char_ptr_vec): New function. (dirnames_to_char_ptr_vec_append): Rewrite. * common/gdb_vecs.h (delim_string_to_char_ptr_vec): Declare.
2014-01-17Move ASSERT_FUNCTION to FUNCTION_NAME.Doug Evans3-18/+20
* common/common-utils.h (FUNCTION_NAME): Renamed from ASSERT_FUNCTION, and moved here ... * common/gdb_assert.h (ASSERT_FUNCTION): ... from here. #include "common-utils.h". (gdb_assert, gdb_assert_fail, gdb_assert_not_reached): Update. * common/vec.h (VEC_ASSERT_PASS): Update. * darwin-nat.h: Replace #include of gdb_assert.h with common-utils.h. (MACH_CHECK_ERROR): Update.
2014-01-16btrace, gdbserver: read branch trace incrementallyMarkus Metzger3-38/+101
Read branch trace data incrementally and extend the current trace rather than discarding it and reading the entire trace buffer each time. If the branch trace buffer overflowed, we can't extend the current trace so we discard it and start anew by reading the entire branch trace buffer. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (perf_event_read_bts, linux_read_btrace): Support delta reads. (linux_disable_btrace): Change return type. * common/linux-btrace.h (linux_read_btrace): Change parameters and return type to allow error reporting. Update users. (linux_disable_btrace): Change return type. Update users. * common/btrace-common.h (btrace_read_type) <BTRACE_READ_DELTA>: New. (btrace_error): New. (btrace_block) <begin>: Comment on BEGIN == 0. * btrace.c (btrace_compute_ftrace): Start from the end of the current trace. (btrace_stitch_trace, btrace_clear_history): New. (btrace_fetch): Read delta trace, return if replaying. (btrace_clear): Move clear history code to btrace_clear_history. (parse_xml_btrace): Throw an error if parsing failed. * target.h (struct target_ops) <to_read_btrace>: Change parameters and return type to allow error reporting. (target_read_btrace): Change parameters and return type to allow error reporting. * target.c (target_read_btrace): Update. * remote.c (remote_read_btrace): Support delta reads. Pass errors on. * NEWS: Announce it. gdbserver/ * target.h (target_ops) <read_btrace>: Change parameters and return type to allow error reporting. * server.c (handle_qxfer_btrace): Support delta reads. Pass trace reading errors on. * linux-low.c (linux_low_read_btrace): Pass trace reading errors on. (linux_low_disable_btrace): New.
2014-01-16btrace: increase buffer sizeMarkus Metzger1-10/+15
Try to allocate as much buffer as we can for each thread with a maximum of 64KB. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (linux_enable_btrace): Enlarge buffer.
2014-01-16btrace: uppercase btrace_read_typeMarkus Metzger2-3/+3
2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/btrace-common.h (btrace_read_type) <btrace_read_all>: Change to ... (btrace_read_type) <BTRACE_READ_ALL>: ... this. Update users. (btrace_read_type) <btrace_read_new>: Change to ... (btrace_read_type) <BTRACE_READ_NEW>: ... this. Update users.
2014-01-16btrace, linux: fix memory leak when reading branch traceMarkus Metzger1-0/+3
When it takes more than one iteration to read the BTS trace, the trace from the previous iteration is leaked. Fix it. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * common/linux-btrace.c (linux_read_btrace): Free trace from previous iteration.
2014-01-14Change 'len' of linux_common_xfer_osdata to ULONGEST.Yao Qi2-12/+12
gdb: 2014-01-14 Yao Qi <yao@codesourcery.com> * common/linux-osdata.c (linux_xfer_osdata_processes): Change type of 'len' to ULONGEST. (linux_xfer_osdata_processgroups): Likewise. (linux_xfer_osdata_threads): Likewise. (linux_xfer_osdata_fds): Likewise. (linux_xfer_osdata_isockets): Likewise. (linux_xfer_osdata_shm): Likewise. (linux_xfer_osdata_sem): Likewise. (linux_xfer_osdata_msg): Likewise. (linux_common_xfer_osdata): Likewise. (struct osdata_type) <getter>: Likewise. * common/linux-osdata.h (linux_common_xfer_osdata): Update the declaration.
2014-01-01Update Copyright year range in all files maintained by GDB.Joel Brobecker44-44/+44
2013-12-02Fix filestuff.c build error if RLIMIT_NOFILE not defined.Joel Brobecker1-1/+1
Not all systems supporting getrlimit also support RLIMIT_NOFILE (Eg. All LynxOS systems appear to be lacking support for this). So check its existance before using it. gdb/ChangeLog: * common/filestuff.c (fdwalk): Add "defined(RLIMIT_NOFILE)" preprocessor check.
2013-11-26Fix PR16193 - gdbserver aborts.Walfred Tedeschi1-7/+8
The MPX patch has broken the I386_XSTATE_SIZE macro. For AVX machines, it ends up returning I386_XSTATE_SSE_SIZE. Where it first reads I386_XSTATE_AVX_SIZE, it should have read I386_XSTATE_AVX: #define I386_XSTATE_SIZE(XCR0) \ (((XCR0) & I386_XSTATE_BNDCFG) != 0 ? I386_XSTATE_BNDCFG_SIZE \ : (((XCR0) & I386_XSTATE_BNDREGS) != 0 ? I386_XSTATE_BNDCFG_SIZE \ - : (((XCR0) & I386_XSTATE_AVX_SIZE) != 0 ? I386_XSTATE_AVX_SIZE \ + : (((XCR0) & I386_XSTATE_AVX) != 0 ? I386_XSTATE_AVX_SIZE \ : I386_XSTATE_SSE_SIZE))) The patch goes a step further and improves readability of the macro, by adding a couple other auxiliary macros. 2013-11-26 Walfred Tedeschi <walfred.tedeschi@intel.com> * i386-xstate.h (I386_XSTATE_MPX): New Macro. (I386_XSTATE_MPX_MASK): Makes use of I386_XSTATE_MPX. (HAS_MPX): New macro. (HAS_AVX): New macro. (I386_XSTATE_SIZE): Uses HAS_MPX and HAS_AVX.
2013-11-20Add MPX registers tests.Walfred Tedeschi1-1/+7
2013-11-20 Walfred Tedeschi <walfred.tedeschi@intel.com> * common/i386-gcc-cpuid.h (bit_MPX): Synchronize with gcc file. testsuite/ * gdb.arch/i386-mpx.c: New file * gdb.arch/i386-mpx.exp: New file. Change-Id: Ica4c9ee823c8210ca876e31f27dcd8583b660a9f Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
2013-11-20Add MPX support for i386Walfred Tedeschi1-4/+16
2013-11-20 Walfred Tedeschi <walfred.tedeschi@intel.com> * i386-linux-nat.c (GETXSTATEREGS_SUPPLIES): Add MPX registers on the range of registers to be read from xsave buffer. (i386_linux_read_description): Add case for MPX. * i386-linux-tdep.c: Include features/i386/i386-mpx-linux.c. (i386_linux_gregset_reg_offset): Add MPX registers. (i386_linux_core_read_description): Initialize also MPX. (_initialize_i386_linux_tdep): Add mpx initialization. * i386-tdep.h (gdbarch_tdep): Add fields bnd0r_regnum, bnd0_regnum, mpx_register_names. (i386_regnum): Add MPX registers. (I386_MPX_NUM_REGS): New macro. (i386_bnd_regnum_p): New function. * i386-linux-tdep.h (I386_LINUX_NUM_REGS): Set number of registers to be the number of BNDSTATUS. (tdesc_i386_mpx_linux): Add description for MPX Linux registers. * i386-tdep.c: Include features/i386/i386-mpx.c. (i386_mpx_names): Add MPX register names array. (i386_bnd_names): Add bnd pseudo register names array. (i386_bndr_regnum_p): Lookup register numbers for bnd raw registers. (i386_bndr_regnum_p): Lookup register numbers for bnd raw registers. (386_mpx_ctrl_regnum_p): Lookup register numbers for MPX control registers. (i386_bnd_type): New function. (i386_pseudo_register_type): Use i386_bnd_type for bnd pseudo register types. (i386_pseudo_register_read_into_value): Add bnd case. (i386_pseudo_register_write): Add bnd pseudo registers. (i386_register_reggroup_p): Add MPX register to the group all. (i386_validate_tdesc_p): Add MPX to the target description validation. (i386_pseudo_register_name): Add bnd pseudo registers. (i386_gdbarch_init): Add MPX for architecture initialization. (_initia_initialize_i386_tdep): Add mpx initialization. * i387-tdep.c (xsave_mpx_offset): New vector for MPX offsets on XSAVE buffer. (XSAVE_MPX_ADDR): New macro. (i387_supply_xsave): Add MPX case. (i387_collect_xsave): Add MPX case. * i387-tdep.h (I387_BND0R_REGNUM): New macro. (I387_BNDCFGU_REGNUM): New macro. (I387_NUM_MPX_REGS): New macro. (I387_NUM_BND_REGS): New macro. (I387_NUM_MPX_CTRL_REGS): New macro. (I387_MPXEND_REGNUM): New macro. * common/i386-xstate.h (I386_XSTATE_BNDREGS): New macro. (I386_XSTATE_BNDCFG): Likewise. (I386_XSTATE_MPX_MASK): Likewise. (I386_XSTATE_ALL_MASK): New macro represents flags for all states. (I386_XSTATE_BNDREGS_SIZE): New macro. (I386_XSTATE_BNDCFG_SIZE): Likewise. (I386_XSTATE_SIZE): Adapt for MPX. (I386_XSTATE_MAX_SIZE): Likewise. Change-Id: I9ddb7d49434d86fa18eb6b99515203d7c567aefd Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com> Conflicts: gdb/ChangeLog
2013-11-18remove gdb_stat.hTom Tromey3-61/+2
This patch is purely mechanical. It removes gdb_stat.h and changes the code to use sys/stat.h. 2013-11-18 Tom Tromey <tromey@redhat.com> * common/gdb_stat.h: Remove. * ada-lang.c: Use sys/stat.h, not gdb_stat.h. * common/filestuff.c: Use sys/stat.h, not gdb_stat.h. * common/linux-osdata.c: Use sys/stat.h, not gdb_stat.h. * corefile.c: Use sys/stat.h, not gdb_stat.h. * ctf.c: Use sys/stat.h, not gdb_stat.h. * darwin-nat.c: Use sys/stat.h, not gdb_stat.h. * dbxread.c: Use sys/stat.h, not gdb_stat.h. * dwarf2read.c: Use sys/stat.h, not gdb_stat.h. * exec.c: Use sys/stat.h, not gdb_stat.h. * gdbserver/linux-low.c: Use sys/stat.h, not gdb_stat.h. * gdbserver/remote-utils.c: Use sys/stat.h, not gdb_stat.h. * inf-child.c: Use sys/stat.h, not gdb_stat.h. * jit.c: Use sys/stat.h, not gdb_stat.h. * linux-nat.c: Use sys/stat.h, not gdb_stat.h. * m68klinux-nat.c: Use sys/stat.h, not gdb_stat.h. * main.c: Use sys/stat.h, not gdb_stat.h. * mdebugread.c: Use sys/stat.h, not gdb_stat.h. * mi/mi-cmd-env.c: Use sys/stat.h, not gdb_stat.h. * nto-tdep.c: Use sys/stat.h, not gdb_stat.h. * objfiles.c: Use sys/stat.h, not gdb_stat.h. * procfs.c: Use sys/stat.h, not gdb_stat.h. * remote-fileio.c: Use sys/stat.h, not gdb_stat.h. * remote-mips.c: Use sys/stat.h, not gdb_stat.h. * remote.c: Use sys/stat.h, not gdb_stat.h. * rs6000-nat.c: Use sys/stat.h, not gdb_stat.h. * sol-thread.c: Use sys/stat.h, not gdb_stat.h. * solib-spu.c: Use sys/stat.h, not gdb_stat.h. * source.c: Use sys/stat.h, not gdb_stat.h. * symfile.c: Use sys/stat.h, not gdb_stat.h. * symmisc.c: Use sys/stat.h, not gdb_stat.h. * symtab.c: Use sys/stat.h, not gdb_stat.h. * top.c: Use sys/stat.h, not gdb_stat.h. * xcoffread.c: Use sys/stat.h, not gdb_stat.h.
2013-11-18remove gdb_dirent.hTom Tromey4-43/+4
This removes gdb_dirent.h and updates the code to use dirent.h instead. It also removes the now-useless configure checks. 2013-11-18 Tom Tromey <tromey@redhat.com> * common/common.m4 (GDB_AC_COMMON): Don't use AC_HEADER_DIRENT. * common/gdb_dirent.h: Remove. * common/filestuff.c: Use dirent.h. * common/linux-osdata.c: Use dirent.h. (NAMELEN): Define. * config.in: Rebuild. * configure: Rebuild. * configure.ac: Don't use AC_HEADER_DIRENT. * linux-fork.c: Use dirent.h * linux-nat.c: Use dirent.h. * nto-procfs.c: Use dirent.h. * procfs.c: Use dirent.h. 2013-11-18 Tom Tromey <tromey@redhat.com> * config.in: Rebuild. * configure: Rebuild. * configure.ac: Don't use AC_HEADER_DIRENT.
2013-11-18don't check for string.h or strings.hTom Tromey1-1/+0
Now that we are using the gnulib string.h module, we don't need to check for string.h or strings.h. This removes the last few checks from the source and from the configure scripts. 2013-11-18 Tom Tromey <tromey@redhat.com> * configure: Rebuild. * common/common.m4 (GDB_AC_COMMON): Don't check for string.h or strings.h. 2013-11-18 Tom Tromey <tromey@redhat.com> * server.h: Don't check HAVE_STRING_H. * gdbreplay.c: Don't check HAVE_STRING_H. * configure: Rebuild.
2013-11-18remove gdb_string.hTom Tromey7-75/+6
This removes gdb_string.h. This patch is purely mechanical. I created it by running the two commands: git rm common/gdb_string.h perl -pi -e's/"gdb_string.h"/<string.h>/;' *.[chyl] */*.[chyl] 2013-11-18 Tom Tromey <tromey@redhat.com> * common/gdb_string.h: Remove. * aarch64-tdep.c: Use string.h, not gdb_string.h. * ada-exp.y: Use string.h, not gdb_string.h. * ada-lang.c: Use string.h, not gdb_string.h. * ada-lex.l: Use string.h, not gdb_string.h. * ada-typeprint.c: Use string.h, not gdb_string.h. * ada-valprint.c: Use string.h, not gdb_string.h. * aix-thread.c: Use string.h, not gdb_string.h. * alpha-linux-tdep.c: Use string.h, not gdb_string.h. * alpha-mdebug-tdep.c: Use string.h, not gdb_string.h. * alpha-nat.c: Use string.h, not gdb_string.h. * alpha-osf1-tdep.c: Use string.h, not gdb_string.h. * alpha-tdep.c: Use string.h, not gdb_string.h. * alphanbsd-tdep.c: Use string.h, not gdb_string.h. * amd64-dicos-tdep.c: Use string.h, not gdb_string.h. * amd64-linux-nat.c: Use string.h, not gdb_string.h. * amd64-linux-tdep.c: Use string.h, not gdb_string.h. * amd64-nat.c: Use string.h, not gdb_string.h. * amd64-sol2-tdep.c: Use string.h, not gdb_string.h. * amd64fbsd-tdep.c: Use string.h, not gdb_string.h. * amd64obsd-tdep.c: Use string.h, not gdb_string.h. * arch-utils.c: Use string.h, not gdb_string.h. * arm-linux-nat.c: Use string.h, not gdb_string.h. * arm-linux-tdep.c: Use string.h, not gdb_string.h. * arm-tdep.c: Use string.h, not gdb_string.h. * arm-wince-tdep.c: Use string.h, not gdb_string.h. * armbsd-tdep.c: Use string.h, not gdb_string.h. * armnbsd-nat.c: Use string.h, not gdb_string.h. * armnbsd-tdep.c: Use string.h, not gdb_string.h. * armobsd-tdep.c: Use string.h, not gdb_string.h. * avr-tdep.c: Use string.h, not gdb_string.h. * ax-gdb.c: Use string.h, not gdb_string.h. * ax-general.c: Use string.h, not gdb_string.h. * bcache.c: Use string.h, not gdb_string.h. * bfin-tdep.c: Use string.h, not gdb_string.h. * breakpoint.c: Use string.h, not gdb_string.h. * build-id.c: Use string.h, not gdb_string.h. * buildsym.c: Use string.h, not gdb_string.h. * c-exp.y: Use string.h, not gdb_string.h. * c-lang.c: Use string.h, not gdb_string.h. * c-typeprint.c: Use string.h, not gdb_string.h. * c-valprint.c: Use string.h, not gdb_string.h. * charset.c: Use string.h, not gdb_string.h. * cli-out.c: Use string.h, not gdb_string.h. * cli/cli-cmds.c: Use string.h, not gdb_string.h. * cli/cli-decode.c: Use string.h, not gdb_string.h. * cli/cli-dump.c: Use string.h, not gdb_string.h. * cli/cli-interp.c: Use string.h, not gdb_string.h. * cli/cli-logging.c: Use string.h, not gdb_string.h. * cli/cli-script.c: Use string.h, not gdb_string.h. * cli/cli-setshow.c: Use string.h, not gdb_string.h. * cli/cli-utils.c: Use string.h, not gdb_string.h. * coffread.c: Use string.h, not gdb_string.h. * common/common-utils.c: Use string.h, not gdb_string.h. * common/filestuff.c: Use string.h, not gdb_string.h. * common/linux-procfs.c: Use string.h, not gdb_string.h. * common/linux-ptrace.c: Use string.h, not gdb_string.h. * common/signals.c: Use string.h, not gdb_string.h. * common/vec.h: Use string.h, not gdb_string.h. * core-regset.c: Use string.h, not gdb_string.h. * corefile.c: Use string.h, not gdb_string.h. * corelow.c: Use string.h, not gdb_string.h. * cp-abi.c: Use string.h, not gdb_string.h. * cp-support.c: Use string.h, not gdb_string.h. * cp-valprint.c: Use string.h, not gdb_string.h. * cris-tdep.c: Use string.h, not gdb_string.h. * d-lang.c: Use string.h, not gdb_string.h. * dbxread.c: Use string.h, not gdb_string.h. * dcache.c: Use string.h, not gdb_string.h. * demangle.c: Use string.h, not gdb_string.h. * dicos-tdep.c: Use string.h, not gdb_string.h. * disasm.c: Use string.h, not gdb_string.h. * doublest.c: Use string.h, not gdb_string.h. * dsrec.c: Use string.h, not gdb_string.h. * dummy-frame.c: Use string.h, not gdb_string.h. * dwarf2-frame.c: Use string.h, not gdb_string.h. * dwarf2loc.c: Use string.h, not gdb_string.h. * dwarf2read.c: Use string.h, not gdb_string.h. * elfread.c: Use string.h, not gdb_string.h. * environ.c: Use string.h, not gdb_string.h. * eval.c: Use string.h, not gdb_string.h. * event-loop.c: Use string.h, not gdb_string.h. * exceptions.c: Use string.h, not gdb_string.h. * exec.c: Use string.h, not gdb_string.h. * expprint.c: Use string.h, not gdb_string.h. * f-exp.y: Use string.h, not gdb_string.h. * f-lang.c: Use string.h, not gdb_string.h. * f-typeprint.c: Use string.h, not gdb_string.h. * f-valprint.c: Use string.h, not gdb_string.h. * fbsd-nat.c: Use string.h, not gdb_string.h. * findcmd.c: Use string.h, not gdb_string.h. * findvar.c: Use string.h, not gdb_string.h. * fork-child.c: Use string.h, not gdb_string.h. * frame.c: Use string.h, not gdb_string.h. * frv-linux-tdep.c: Use string.h, not gdb_string.h. * frv-tdep.c: Use string.h, not gdb_string.h. * gdb.c: Use string.h, not gdb_string.h. * gdb_bfd.c: Use string.h, not gdb_string.h. * gdbarch.c: Use string.h, not gdb_string.h. * gdbtypes.c: Use string.h, not gdb_string.h. * gnu-nat.c: Use string.h, not gdb_string.h. * gnu-v2-abi.c: Use string.h, not gdb_string.h. * gnu-v3-abi.c: Use string.h, not gdb_string.h. * go-exp.y: Use string.h, not gdb_string.h. * go-lang.c: Use string.h, not gdb_string.h. * go32-nat.c: Use string.h, not gdb_string.h. * hppa-hpux-tdep.c: Use string.h, not gdb_string.h. * hppa-linux-nat.c: Use string.h, not gdb_string.h. * hppanbsd-tdep.c: Use string.h, not gdb_string.h. * hppaobsd-tdep.c: Use string.h, not gdb_string.h. * i386-cygwin-tdep.c: Use string.h, not gdb_string.h. * i386-dicos-tdep.c: Use string.h, not gdb_string.h. * i386-linux-nat.c: Use string.h, not gdb_string.h. * i386-linux-tdep.c: Use string.h, not gdb_string.h. * i386-nto-tdep.c: Use string.h, not gdb_string.h. * i386-sol2-tdep.c: Use string.h, not gdb_string.h. * i386-tdep.c: Use string.h, not gdb_string.h. * i386bsd-tdep.c: Use string.h, not gdb_string.h. * i386gnu-nat.c: Use string.h, not gdb_string.h. * i386nbsd-tdep.c: Use string.h, not gdb_string.h. * i386obsd-tdep.c: Use string.h, not gdb_string.h. * i387-tdep.c: Use string.h, not gdb_string.h. * ia64-libunwind-tdep.c: Use string.h, not gdb_string.h. * ia64-linux-nat.c: Use string.h, not gdb_string.h. * inf-child.c: Use string.h, not gdb_string.h. * inf-ptrace.c: Use string.h, not gdb_string.h. * inf-ttrace.c: Use string.h, not gdb_string.h. * infcall.c: Use string.h, not gdb_string.h. * infcmd.c: Use string.h, not gdb_string.h. * inflow.c: Use string.h, not gdb_string.h. * infrun.c: Use string.h, not gdb_string.h. * interps.c: Use string.h, not gdb_string.h. * iq2000-tdep.c: Use string.h, not gdb_string.h. * irix5-nat.c: Use string.h, not gdb_string.h. * jv-exp.y: Use string.h, not gdb_string.h. * jv-lang.c: Use string.h, not gdb_string.h. * jv-typeprint.c: Use string.h, not gdb_string.h. * jv-valprint.c: Use string.h, not gdb_string.h. * language.c: Use string.h, not gdb_string.h. * linux-fork.c: Use string.h, not gdb_string.h. * linux-nat.c: Use string.h, not gdb_string.h. * lm32-tdep.c: Use string.h, not gdb_string.h. * m2-exp.y: Use string.h, not gdb_string.h. * m2-typeprint.c: Use string.h, not gdb_string.h. * m32c-tdep.c: Use string.h, not gdb_string.h. * m32r-linux-nat.c: Use string.h, not gdb_string.h. * m32r-linux-tdep.c: Use string.h, not gdb_string.h. * m32r-rom.c: Use string.h, not gdb_string.h. * m32r-tdep.c: Use string.h, not gdb_string.h. * m68hc11-tdep.c: Use string.h, not gdb_string.h. * m68k-tdep.c: Use string.h, not gdb_string.h. * m68kbsd-tdep.c: Use string.h, not gdb_string.h. * m68klinux-nat.c: Use string.h, not gdb_string.h. * m68klinux-tdep.c: Use string.h, not gdb_string.h. * m88k-tdep.c: Use string.h, not gdb_string.h. * macrocmd.c: Use string.h, not gdb_string.h. * main.c: Use string.h, not gdb_string.h. * mdebugread.c: Use string.h, not gdb_string.h. * mem-break.c: Use string.h, not gdb_string.h. * memattr.c: Use string.h, not gdb_string.h. * memory-map.c: Use string.h, not gdb_string.h. * mep-tdep.c: Use string.h, not gdb_string.h. * mi/mi-cmd-break.c: Use string.h, not gdb_string.h. * mi/mi-cmd-disas.c: Use string.h, not gdb_string.h. * mi/mi-cmd-env.c: Use string.h, not gdb_string.h. * mi/mi-cmd-stack.c: Use string.h, not gdb_string.h. * mi/mi-cmd-var.c: Use string.h, not gdb_string.h. * mi/mi-cmds.c: Use string.h, not gdb_string.h. * mi/mi-console.c: Use string.h, not gdb_string.h. * mi/mi-getopt.c: Use string.h, not gdb_string.h. * mi/mi-interp.c: Use string.h, not gdb_string.h. * mi/mi-main.c: Use string.h, not gdb_string.h. * mi/mi-parse.c: Use string.h, not gdb_string.h. * microblaze-rom.c: Use string.h, not gdb_string.h. * microblaze-tdep.c: Use string.h, not gdb_string.h. * mingw-hdep.c: Use string.h, not gdb_string.h. * minidebug.c: Use string.h, not gdb_string.h. * minsyms.c: Use string.h, not gdb_string.h. * mips-irix-tdep.c: Use string.h, not gdb_string.h. * mips-linux-tdep.c: Use string.h, not gdb_string.h. * mips-tdep.c: Use string.h, not gdb_string.h. * mips64obsd-tdep.c: Use string.h, not gdb_string.h. * mipsnbsd-tdep.c: Use string.h, not gdb_string.h. * mipsread.c: Use string.h, not gdb_string.h. * mn10300-linux-tdep.c: Use string.h, not gdb_string.h. * mn10300-tdep.c: Use string.h, not gdb_string.h. * monitor.c: Use string.h, not gdb_string.h. * moxie-tdep.c: Use string.h, not gdb_string.h. * mt-tdep.c: Use string.h, not gdb_string.h. * nbsd-tdep.c: Use string.h, not gdb_string.h. * nios2-linux-tdep.c: Use string.h, not gdb_string.h. * nto-procfs.c: Use string.h, not gdb_string.h. * nto-tdep.c: Use string.h, not gdb_string.h. * objc-lang.c: Use string.h, not gdb_string.h. * objfiles.c: Use string.h, not gdb_string.h. * opencl-lang.c: Use string.h, not gdb_string.h. * osabi.c: Use string.h, not gdb_string.h. * osdata.c: Use string.h, not gdb_string.h. * p-exp.y: Use string.h, not gdb_string.h. * p-lang.c: Use string.h, not gdb_string.h. * p-typeprint.c: Use string.h, not gdb_string.h. * parse.c: Use string.h, not gdb_string.h. * posix-hdep.c: Use string.h, not gdb_string.h. * ppc-linux-nat.c: Use string.h, not gdb_string.h. * ppc-sysv-tdep.c: Use string.h, not gdb_string.h. * ppcfbsd-tdep.c: Use string.h, not gdb_string.h. * ppcnbsd-tdep.c: Use string.h, not gdb_string.h. * ppcobsd-tdep.c: Use string.h, not gdb_string.h. * printcmd.c: Use string.h, not gdb_string.h. * procfs.c: Use string.h, not gdb_string.h. * prologue-value.c: Use string.h, not gdb_string.h. * python/py-auto-load.c: Use string.h, not gdb_string.h. * python/py-gdb-readline.c: Use string.h, not gdb_string.h. * ravenscar-thread.c: Use string.h, not gdb_string.h. * regcache.c: Use string.h, not gdb_string.h. * registry.c: Use string.h, not gdb_string.h. * remote-fileio.c: Use string.h, not gdb_string.h. * remote-m32r-sdi.c: Use string.h, not gdb_string.h. * remote-mips.c: Use string.h, not gdb_string.h. * remote-sim.c: Use string.h, not gdb_string.h. * remote.c: Use string.h, not gdb_string.h. * reverse.c: Use string.h, not gdb_string.h. * rs6000-aix-tdep.c: Use string.h, not gdb_string.h. * ser-base.c: Use string.h, not gdb_string.h. * ser-go32.c: Use string.h, not gdb_string.h. * ser-mingw.c: Use string.h, not gdb_string.h. * ser-pipe.c: Use string.h, not gdb_string.h. * ser-tcp.c: Use string.h, not gdb_string.h. * ser-unix.c: Use string.h, not gdb_string.h. * serial.c: Use string.h, not gdb_string.h. * sh-tdep.c: Use string.h, not gdb_string.h. * sh64-tdep.c: Use string.h, not gdb_string.h. * shnbsd-tdep.c: Use string.h, not gdb_string.h. * skip.c: Use string.h, not gdb_string.h. * sol-thread.c: Use string.h, not gdb_string.h. * solib-dsbt.c: Use string.h, not gdb_string.h. * solib-frv.c: Use string.h, not gdb_string.h. * solib-osf.c: Use string.h, not gdb_string.h. * solib-spu.c: Use string.h, not gdb_string.h. * solib-target.c: Use string.h, not gdb_string.h. * solib.c: Use string.h, not gdb_string.h. * somread.c: Use string.h, not gdb_string.h. * source.c: Use string.h, not gdb_string.h. * sparc-nat.c: Use string.h, not gdb_string.h. * sparc-sol2-tdep.c: Use string.h, not gdb_string.h. * sparc-tdep.c: Use string.h, not gdb_string.h. * sparc64-tdep.c: Use string.h, not gdb_string.h. * sparc64fbsd-tdep.c: Use string.h, not gdb_string.h. * sparc64nbsd-tdep.c: Use string.h, not gdb_string.h. * sparcnbsd-tdep.c: Use string.h, not gdb_string.h. * spu-linux-nat.c: Use string.h, not gdb_string.h. * spu-multiarch.c: Use string.h, not gdb_string.h. * spu-tdep.c: Use string.h, not gdb_string.h. * stabsread.c: Use string.h, not gdb_string.h. * stack.c: Use string.h, not gdb_string.h. * std-regs.c: Use string.h, not gdb_string.h. * symfile.c: Use string.h, not gdb_string.h. * symmisc.c: Use string.h, not gdb_string.h. * symtab.c: Use string.h, not gdb_string.h. * target.c: Use string.h, not gdb_string.h. * thread.c: Use string.h, not gdb_string.h. * tilegx-linux-nat.c: Use string.h, not gdb_string.h. * tilegx-tdep.c: Use string.h, not gdb_string.h. * top.c: Use string.h, not gdb_string.h. * tracepoint.c: Use string.h, not gdb_string.h. * tui/tui-command.c: Use string.h, not gdb_string.h. * tui/tui-data.c: Use string.h, not gdb_string.h. * tui/tui-disasm.c: Use string.h, not gdb_string.h. * tui/tui-file.c: Use string.h, not gdb_string.h. * tui/tui-layout.c: Use string.h, not gdb_string.h. * tui/tui-out.c: Use string.h, not gdb_string.h. * tui/tui-regs.c: Use string.h, not gdb_string.h. * tui/tui-source.c: Use string.h, not gdb_string.h. * tui/tui-stack.c: Use string.h, not gdb_string.h. * tui/tui-win.c: Use string.h, not gdb_string.h. * tui/tui-windata.c: Use string.h, not gdb_string.h. * tui/tui-winsource.c: Use string.h, not gdb_string.h. * typeprint.c: Use string.h, not gdb_string.h. * ui-file.c: Use string.h, not gdb_string.h. * ui-out.c: Use string.h, not gdb_string.h. * user-regs.c: Use string.h, not gdb_string.h. * utils.c: Use string.h, not gdb_string.h. * v850-tdep.c: Use string.h, not gdb_string.h. * valarith.c: Use string.h, not gdb_string.h. * valops.c: Use string.h, not gdb_string.h. * valprint.c: Use string.h, not gdb_string.h. * value.c: Use string.h, not gdb_string.h. * varobj.c: Use string.h, not gdb_string.h. * vax-tdep.c: Use string.h, not gdb_string.h. * vaxnbsd-tdep.c: Use string.h, not gdb_string.h. * vaxobsd-tdep.c: Use string.h, not gdb_string.h. * windows-nat.c: Use string.h, not gdb_string.h. * xcoffread.c: Use string.h, not gdb_string.h. * xml-support.c: Use string.h, not gdb_string.h. * xstormy16-tdep.c: Use string.h, not gdb_string.h. * xtensa-linux-nat.c: Use string.h, not gdb_string.h.
2013-11-08introduce common.m4Tom Tromey1-0/+38
It has bothered me for a while that files in common/ use macros defined via autoconf checks, but rely on each configure.ac doing the proper checks independently. This patch introduces common/common.m4 which consolidates the checks assumed by code in common. The rule I propose is that if something is needed or used by common, it should be checked for by common.m4. However, if the check is also needed by gdb or gdbserver, then it should be duplicated there. Built and regtested on x86-64 Fedora 18 (though this is hardly the most strenuous case) and using the Fedora 18 mingw cross compilers. I also examined the config.in diffs to ensure that symbols did not go missing. 2013-11-08 Tom Tromey <tromey@redhat.com> * acinclude.m4: Include common.m4. * common/common.m4: New file. * configure, config.in: Rebuild. * configure.ac: Use GDB_AC_COMMON. 2013-11-08 Tom Tromey <tromey@redhat.com> * acinclude.m4: Include common.m4, codeset.m4. * configure, config.in: Rebuild. * configure.ac: Use GDB_AC_COMMON.
2013-10-25infrun debug output: print enum gdb_signal symbol names instead of POSIX ↵Pedro Alves2-1/+14
signal names. The other day while debugging something related to random signals, I got confused with "set debug infrun 1" output, for it said: infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc = 0x323d4e8b94 infrun: random signal 20 On GNU/Linux, 20 is SIGTSTP. For some reason, it took me a few minutes to realize that 20 is actually a GDB signal number, not a target signal number (duh!). In any case, I propose making GDB's output clearer here: One way would be to use gdb_signal_to_name, like already used elsewhere: infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc = 0x323d4e8b94 infrun: random signal SIGCHLD (20) but I think that might confuse someone too ("20? Why does GDB believe SIGCHLD is 20?"). So I thought of printing the enum string instead: infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc = 0x323d4e8b94 infrun: random signal GDB_SIGNAL_CHLD (20) Looking at a more complete infrun debug log, we had actually printed the (POSIX) signal name name a bit before: infrun: target_wait (-1, status) = infrun: 9300 [Thread 0x7ffff7fcb740 (LWP 9300)], infrun: status->kind = stopped, signal = SIGCHLD ... infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc = 0x323d4e8b94 infrun: random signal 20 So I'm now thinking that it'd be even better to make infrun output consistently use the enum symbol string, like so: infrun: clear_proceed_status_thread (Thread 0x7ffff7fca700 (LWP 25663)) infrun: clear_proceed_status_thread (Thread 0x7ffff7fcb740 (LWP 25659)) - infrun: proceed (addr=0xffffffffffffffff, signal=144, step=1) + infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT, step=1) - infrun: resume (step=1, signal=0), trap_expected=0, current thread [Thread 0x7ffff7fcb740 (LWP 25659)] at 0x400700 + infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0x7ffff7fcb740 (LWP 25659)] at 0x400700 infrun: wait_for_inferior () infrun: target_wait (-1, status) = infrun: 25659 [Thread 0x7ffff7fcb740 (LWP 25659)], - infrun: status->kind = stopped, signal = SIGCHLD + infrun: status->kind = stopped, signal = GDB_SIGNAL_CHLD infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc = 0x400700 - infrun: random signal 20 + infrun: random signal (GDB_SIGNAL_CHLD) infrun: random signal, keep going - infrun: resume (step=1, signal=20), trap_expected=0, current thread [Thread 0x7ffff7fcb740 (LWP 25659)] at 0x400700 + infrun: resume (step=1, signal=GDB_SIGNAL_CHLD), trap_expected=0, current thread [Thread 0x7ffff7fcb740 (LWP 25659)] at 0x400700 infrun: prepare_to_wait infrun: target_wait (-1, status) = infrun: 25659 [Thread 0x7ffff7fcb740 (LWP 25659)], - infrun: status->kind = stopped, signal = SIGTRAP + infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc = 0x400704 infrun: stepi/nexti infrun: stop_stepping GDB's signal numbers are public and hardcoded (see include/gdb/signals.h), so there's really no need to clutter the output with numeric values in some places while others not. Replacing the magic "144" with GDB_SIGNAL_DEFAULT in "proceed"'s debug output (see above) I think is quite nice. I posit that all this makes it clearer to newcomers that GDB has its own signal numbering (and that there must be some mapping going on). Tested on x86_64 Fedora 17. gdb/ 2013-10-23 Pedro Alves <palves@redhat.com> * common/gdb_signals.h (gdb_signal_to_symbol_string): Declare. * common/signals.c: Include "gdb_assert.h". (signals): New field 'symbol'. (SET): Use the 'symbol' parameter. (gdb_signal_to_symbol_string): New function. * infrun.c (handle_inferior_event) <random signal>: In debug output, print the random signal enum as string in addition to its number. * target/waitstatus.c (target_waitstatus_to_string): Print the signal's enum value as string instead of the (POSIX) signal name.
2013-10-25Fix off-by-one errors in *scanf format strings.Gary Benson1-25/+41
In the first hunk, the format string was off-by-one for cmd, and cmd itself was larger than the maximum size required. cmd was reduced in size and the format string adjusted. In the second hunk, the format string was off-by-one for local_address, remote_address and extra, although the buffers for the two addresses were large enough for this not to matter. The specifiers for the two addresses was corrected, and a number of unused variables including extra were suppressed from parsing. In the third hunk, the format string was off-by-one for name, dependencies and status. This code was rewritten using strtok since dependencies can be arbitrarily long. gdb/ 2013-10-23 Gary Benson <gbenson@redhat.com> PR 16013 * common/linux-osdata.c (command_from_pid): Reduced size of cmd from 32 to 18. Adjusted fscanf format string accordingly. (Avoids leaving cmd unterminated.) (print_sockets): Do not parse tlen, inode, sl, timeout, txq, rxq, trun, retn or extra. (Avoids leaving extra unterminated.) Check that local_address and remote_address will not overflow. (linux_xfer_osdata_modules): Parse lines using strtok to avoid leaving dependencies unterminated. Parse size as "%u" to match definition.
2013-10-25Fix up a couple oddities in GDB's signal names and strings.Pedro Alves1-12/+12
- The Mach exception/signals escaped the TARGET_ -> GDB_ prefix change done a while ago, but there's no real reason for that. I grepped for TARGET_EXC and fixed all found, which unsurprisingly, means darwin-nat.c needed fixing. I think the change there is as obvious and trivial as it can get, so I'd be quite surprised if this broke anything there somehow. - GDB_SIGNAL_LAST's description string was unnecessarily inconsistent with the enum name. Built on x86_64 Fedora 17. gdb/ 2013-10-22 Pedro Alves <palves@redhat.com> * include/gdb/signals.def (TARGET_EXC_BAD_ACCESS): Rename to GDB_EXC_BAD_ACCESS. (TARGET_EXC_BAD_INSTRUCTION): Rename to GDB_EXC_BAD_INSTRUCTION. (TARGET_EXC_ARITHMETIC): Rename to GDB_EXC_ARITHMETIC. (TARGET_EXC_EMULATION): Rename to GDB_EXC_EMULATION. (TARGET_EXC_SOFTWARE): Rename to GDB_EXC_SOFTWARE. (TARGET_EXC_BREAKPOINT): Rename to GDB_EXC_BREAKPOINT. (GDB_SIGNAL_LAST): Change description string. * common/signals.c (gdb_signal_from_host, do_gdb_signal_to_host): Adjust to signal renaming. * darwin-nat.c (darwin_decode_message): Likewise.
2013-10-09Minor O_CLOEXEC optimization, "regression" fixJan Kratochvil1-10/+11
gdb/ 2013-10-09 Jan Kratochvil <jan.kratochvil@redhat.com> * common/filestuff.c (gdb_fopen_cloexec): Remove initialization of result variable. Rename variable fopen_e_ever_failed to fopen_e_ever_failed_einval. Retry fopen only for errno EINVAL.
2013-10-04Clean up ptid.h/ptid.c.Pedro Alves2-49/+37
The ptid_t contructors, accessors and predicates are documented in _three_ places, and each place uses a different wording. E.g, the descriptions in the .c file of the new ptid_lwp_p, ptid_tid_p weren't updated in the final revision like the descriptions in the .h file were. Clearly, switching to a style that has a single central description avoids such issues. Worse, some of the existing descriptions are plain wrong, such as: /* Attempt to find and return an existing ptid with the given PID, LWP, and TID components. If none exists, create a new one and return that. */ ptid_t ptid_build (int pid, long lwp, long tid); The function does nothing that complicated. It's just a simple constructor. So this gets rid of all the unnecessary descriptions, leaving only the ones near the function declarations in the header file, and fixes/clarifies those that remain. gdb/ 2013-10-04 Pedro Alves <palves@redhat.com> * common/ptid.c (null_ptid, minus_one_ptid, ptid_build) (pid_to_ptid, ptid_get_pid, ptid_get_lwp, ptid_get_tid) (ptid_equal, ptid_is_pid, ptid_lwp_p, ptid_tid_p): Replace describing comments with references to ptid.h. * common/ptid.h: Remove intro description of constructors, accessors and predicates. (struct ptid): Reformat. (minus_one_ptid, ptid_build, pid_to_ptid, ptid_get_pid) (ptid_get_lwp, ptid_get_tid, ptid_equal, ptid_is_pid): Change describing comments.
2013-10-03Always run the PTRACE_O_TRACESYSGOOD tests even if PTRACE_O_TRACEFORK is not ↵Pedro Alves1-37/+46
supported. If enabling PTRACE_O_TRACEFORK fails, we never test for PTRACE_O_TRACESYSGOOD support. Before PTRACE_O_TRACESYSGOOD is checked, we have: /* First, set the PTRACE_O_TRACEFORK option. If this fails, we know for sure that it is not supported. */ ret = ptrace (PTRACE_SETOPTIONS, child_pid, (PTRACE_TYPE_ARG3) 0, (PTRACE_TYPE_ARG4) PTRACE_O_TRACEFORK); if (ret != 0) { ret = ptrace (PTRACE_KILL, child_pid, (PTRACE_TYPE_ARG3) 0, (PTRACE_TYPE_ARG4) 0); if (ret != 0) { warning (_("linux_check_ptrace_features: failed to kill child")); return; } ret = my_waitpid (child_pid, &status, 0); if (ret != child_pid) warning (_("linux_check_ptrace_features: failed " "to wait for killed child")); else if (!WIFSIGNALED (status)) warning (_("linux_check_ptrace_features: unexpected " "wait status 0x%x from killed child"), status); return; <<<<<<<<<<<<<<<<< } Note that early return. If PTRACE_O_TRACEFORK isn't supported, we're not checking PTRACE_O_TRACESYSGOOD. This didn't use to be a problem before the unification of this whole detection business in linux-ptrace.c. Before, the sysgood detection was completely separate: static void linux_test_for_tracesysgood (int original_pid) { int ret; sigset_t prev_mask; /* We don't want those ptrace calls to be interrupted. */ block_child_signals (&prev_mask); linux_supports_tracesysgood_flag = 0; ret = ptrace (PTRACE_SETOPTIONS, original_pid, 0, PTRACE_O_TRACESYSGOOD); if (ret != 0) goto out; linux_supports_tracesysgood_flag = 1; out: restore_child_signals_mask (&prev_mask); } So we need to get back the decoupling somehow. I think it's cleaner to split the seperate feature detections to separate functions. This patch does that. The new functions are named for their counterparts that existed before this code was moved to linux-ptrace.c. Note I've used forward declarations for the new functions to make the patch clearer, as otherwise the patch would look like I'd be adding a bunch of new code. A reorder can be done in a follow up patch. Tested on x86_64 Fedora 17. gdb/ 2013-10-03 Pedro Alves <palves@redhat.com> * common/linux-ptrace.c (linux_check_ptrace_features): Factor out the PTRACE_O_TRACESYSGOOD and PTRACE_O_TRACEFORK to separate functions. Always test for PTRACE_O_TRACESYSGOOD even if PTRACE_O_TRACEFORK is not supported. (linux_test_for_tracesysgood): New function. (linux_test_for_tracefork): New function, factored out from linux_check_ptrace_features, and also don't kill child_pid here.
2013-09-30 * aarch64-linux-nat.c: Replace PIDGET with ptid_get_pid.Luis Machado2-3/+35
Replace TIDGET with ptid_get_lwp. Replace GET_LWP with ptid_get_lwp. * aix-thread.c (BUILD_THREAD, BUILD_LWP): Remove. Replace BUILD_THREAD with ptid_build. Replace BUILD_LWP with ptid_build. Replace PIDGET with ptid_get_pid. Replace TIDGET with ptid_get_lwp. * alphabsd-nat.c: Replace PIDGET with ptid_get_pid. * amd64-linux-nat.c: Replace PIDGET with ptid_get_pid. Replace TIDGET with ptid_get_lwp. * amd64bsd-nat.c: Replace PIDGET with ptid_get_pid. * arm-linux-nat.c: Replace PIDGET with ptid_get_pid. Replace TIDGET with ptid_get_lwp. Replace GET_LWP with ptid_get_lwp. * armnbsd-nat.c: Replace PIDGET with ptid_get_pid. * auxv.c: Likewise. * breakpoint.c: Likewise. * common/ptid.c (ptid_is_pid): Condense check for null_ptid and minus_one_ptid. (ptid_lwp_p): New function. (ptid_tid_p): New function. * common/ptid.h: Update comments for accessors. (ptid_lwp_p): New prototype. (ptid_tid_p): New prototype. * defs.h (PIDGET, TIDGET, MERGEPID): Do not define. * gcore.c: Replace PIDGET with ptid_get_pid. * gdbthread.h: Likewise. * gnu-nat.c: Likewise. * hppa-linux-nat.c: Replace PIDGET with ptid_get_pid. Replace TIDGET with ptid_get_lwp. * hppabsd-nat.c: Replace PIDGET with ptid_get_pid. * hppanbsd-nat.c: Likewise. * i386-linux-nat.c: Replace PIDGET with ptid_get_pid. Replace TIDGET with ptid_get_lwp. * i386bsd-nat.c: Replace PIDGET with ptid_get_pid. * ia64-linux-nat.c: Replace PIDGET with ptid_get_pid. * infcmd.c: Likewise. * inferior.h: Likewise. * inflow.c: Likewise. * infrun.c: Likewise. * linux-fork.c: Likewise. * linux-nat.c: Replace PIDGET with ptid_get_pid. Replace GET_PID with ptid_get_pid. Replace is_lwp with ptid_lwp_p. Replace GET_LWP with ptid_get_lwp. Replace BUILD_LWP with ptid_build.
2013-09-29gdb: btrace: fix build errors on older glibc buildsMike Frysinger1-2/+5
It is possible to have a build of glibc where SYS_perf_event_open is not defined (because when the glibc was compiled, the syscall did not exist), but have newer kernel headers installed so that linux/perf_event.h is available. In this setup, you get a build failure: ./common/linux-btrace.c: In function 'kernel_supports_btrace': ./common/linux-btrace.c:316:23: error: 'SYS_perf_event_open' undeclared (first use in this function) Update the ifdef check to also see if the syscall is available. URL: https://bugs.gentoo.org/473522 Reported-by: William Throwe <wtt6@cornell.edu> Signed-off-by: Mike Frysinger <vapier@gentoo.org>