binutils-gdb/gdb/record-btrace.c

2377 lines
60 KiB
C
Raw Normal View History

/* Branch trace support for GDB, the GNU debugger.
Copyright (C) 2013-2015 Free Software Foundation, Inc.
Contributed by Intel Corp. <markus.t.metzger@intel.com>
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "record.h"
#include "gdbthread.h"
#include "target.h"
#include "gdbcmd.h"
#include "disasm.h"
#include "observer.h"
#include "cli/cli-utils.h"
#include "source.h"
#include "ui-out.h"
#include "symtab.h"
#include "filenames.h"
#include "regcache.h"
#include "frame-unwind.h"
#include "hashtab.h"
Add new infrun.h header. 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-05-22 13:29:11 +02:00
#include "infrun.h"
#include "event-loop.h"
#include "inf-loop.h"
/* The target_ops of record-btrace. */
static struct target_ops record_btrace_ops;
/* A new thread observer enabling branch tracing for the new thread. */
static struct observer *record_btrace_thread_observer;
/* Memory access types used in set/show record btrace replay-memory-access. */
static const char replay_memory_access_read_only[] = "read-only";
static const char replay_memory_access_read_write[] = "read-write";
static const char *const replay_memory_access_types[] =
{
replay_memory_access_read_only,
replay_memory_access_read_write,
NULL
};
/* The currently allowed replay memory access type. */
static const char *replay_memory_access = replay_memory_access_read_only;
/* Command lists for "set/show record btrace". */
static struct cmd_list_element *set_record_btrace_cmdlist;
static struct cmd_list_element *show_record_btrace_cmdlist;
/* The execution direction of the last resume we got. See record-full.c. */
static enum exec_direction_kind record_btrace_resume_exec_dir = EXEC_FORWARD;
/* The async event handler for reverse/replay execution. */
static struct async_event_handler *record_btrace_async_inferior_event_handler;
/* A flag indicating that we are currently generating a core file. */
static int record_btrace_generating_corefile;
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
/* The current branch trace configuration. */
static struct btrace_config record_btrace_conf;
/* Command list for "record btrace". */
static struct cmd_list_element *record_btrace_cmdlist;
record-btrace: add bts buffer size configuration option Allow the size of the branch trace ring buffer to be defined by the user. The specified buffer size will be used when BTS tracing is enabled for new threads. The obtained buffer size may differ from the requested size. The actual buffer size for the current thread is shown in the "info record" command. Bigger buffers mean longer traces, but also longer processing time. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (parse_xml_btrace_conf_bts): Add size. (btrace_conf_bts_attributes): New. (btrace_conf_children): Add attributes. * common/btrace-common.h (btrace_config_bts): New. (btrace_config)<bts>: New. (btrace_config): Update comment. * nat/linux-btrace.c (linux_enable_btrace, linux_enable_bts): Use config. * features/btrace-conf.dtd: Increment version. Add size attribute to bts element. * record-btrace.c (set_record_btrace_bts_cmdlist, show_record_btrace_bts_cmdlist): New. (record_btrace_adjust_size, record_btrace_print_bts_conf, record_btrace_print_conf, cmd_set_record_btrace_bts, cmd_show_record_btrace_bts): New. (record_btrace_info): Call record_btrace_print_conf. (_initialize_record_btrace): Add commands. * remote.c: Add PACKET_Qbtrace_conf_bts_size enum. (remote_protocol_features): Add Qbtrace-conf:bts:size packet. (btrace_sync_conf): Synchronize bts size. (_initialize_remote): Add Qbtrace-conf:bts:size packet. * NEWS: Announce new commands and new packets. doc/ * gdb.texinfo (Branch Trace Configuration Format): Add size. (Process Record and Replay): Describe new set|show commands. (General Query Packets): Describe Qbtrace-conf:bts:size packet. testsuite/ * gdb.btrace/buffer-size: New. gdbserver/ * linux-low.c (linux_low_btrace_conf): Print size. * server.c (handle_btrace_conf_general_set): New. (hanle_general_set): Call handle_btrace_conf_general_set. (handle_query): Report Qbtrace-conf:bts:size as supported.
2013-11-28 16:39:12 +01:00
/* Command lists for "set/show record btrace". */
static struct cmd_list_element *set_record_btrace_cmdlist;
static struct cmd_list_element *show_record_btrace_cmdlist;
/* Command lists for "set/show record btrace bts". */
static struct cmd_list_element *set_record_btrace_bts_cmdlist;
static struct cmd_list_element *show_record_btrace_bts_cmdlist;
/* Print a record-btrace debug message. Use do ... while (0) to avoid
ambiguities when used in if statements. */
#define DEBUG(msg, args...) \
do \
{ \
if (record_debug != 0) \
fprintf_unfiltered (gdb_stdlog, \
"[record-btrace] " msg "\n", ##args); \
} \
while (0)
/* Update the branch trace for the current thread and return a pointer to its
thread_info.
Throws an error if there is no thread or no trace. This function never
returns NULL. */
static struct thread_info *
require_btrace_thread (void)
{
struct thread_info *tp;
DEBUG ("require");
tp = find_thread_ptid (inferior_ptid);
if (tp == NULL)
error (_("No thread."));
btrace_fetch (tp);
if (btrace_is_empty (tp))
error (_("No trace."));
return tp;
}
/* Update the branch trace for the current thread and return a pointer to its
branch trace information struct.
Throws an error if there is no thread or no trace. This function never
returns NULL. */
static struct btrace_thread_info *
require_btrace (void)
{
struct thread_info *tp;
tp = require_btrace_thread ();
return &tp->btrace;
}
/* Enable branch tracing for one thread. Warn on errors. */
static void
record_btrace_enable_warn (struct thread_info *tp)
{
volatile struct gdb_exception error;
TRY_CATCH (error, RETURN_MASK_ERROR)
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
btrace_enable (tp, &record_btrace_conf);
if (error.message != NULL)
warning ("%s", error.message);
}
/* Callback function to disable branch tracing for one thread. */
static void
record_btrace_disable_callback (void *arg)
{
struct thread_info *tp;
tp = arg;
btrace_disable (tp);
}
/* Enable automatic tracing of new threads. */
static void
record_btrace_auto_enable (void)
{
DEBUG ("attach thread observer");
record_btrace_thread_observer
= observer_attach_new_thread (record_btrace_enable_warn);
}
/* Disable automatic tracing of new threads. */
static void
record_btrace_auto_disable (void)
{
/* The observer may have been detached, already. */
if (record_btrace_thread_observer == NULL)
return;
DEBUG ("detach thread observer");
observer_detach_new_thread (record_btrace_thread_observer);
record_btrace_thread_observer = NULL;
}
/* The record-btrace async event handler function. */
static void
record_btrace_handle_async_inferior_event (gdb_client_data data)
{
inferior_event_handler (INF_REG_EVENT, NULL);
}
/* The to_open method of target record-btrace. */
static void
record_btrace_open (const char *args, int from_tty)
{
struct cleanup *disable_chain;
struct thread_info *tp;
DEBUG ("open");
Fix "is a record target open" checks. RECORD_IS_USED and record_full_open look at current_target.to_stratum to determine whether a record target is in use. This is wrong because arch_stratum is greater than record_stratum, so if an arch_stratum target is pushed, RECORD_IS_USED and record_full_open will miss it. To fix this, we can use the existing find_record_target instead, which looks up for a record stratum target across the target stack. Since that means exporting find_record_target in record.h, RECORD_IS_USED ends up redundant, so the patch eliminates it. That exercise then reveals other issues: - adjust_pc_after_break is gating record_full_... calls based on RECORD_IS_USED. But, record_full_ calls shouldn't be made when recording with the record-btrace target. So this adds a new record_full_is_used predicate to be used in that spot. - record_full_open says "Process record target already running", even if the recording target is record-btrace ("process record" is the original complete name of the record-full target). record_btrace_open only says "The process is already being recorded." and does not suggest "record stop", like record-full does. The patch factors out and merges that error to a new record_preopen function that all record targets call in their open routine. Tested on x86_64 Fedora 17. gdb/ 2014-01-14 Pedro Alves <palves@redhat.com> Tom Tromey <tromey@redhat.com> * infrun.c (use_displaced_stepping): Use find_record_target instead of RECORD_IS_USED. (adjust_pc_after_break): Use record_full_is_used instead of RECORD_IS_USED. * record-btrace.c (record_btrace_open): Call record_preopen instead of checking RECORD_IS_USED. * record-full.c (record_full_shortname) (record_full_core_shortname): New globals. (record_full_is_used): New function. (find_full_open): Call record_preopen instead of checking RECORD_IS_USED. (init_record_full_ops): Set the target's shortname to record_full_shortname. (init_record_full_core_ops): Set the target's shortname to record_full_core_shortname. * record-full.h (record_full_is_used): Declare. * record.c (find_record_target): Make extern. (record_preopen): New function. * record.h (RECORD_IS_USED): Delete macro. (find_record_target, record_preopen): Declare functions.
2014-01-14 17:12:19 +01:00
record_preopen ();
if (!target_has_execution)
error (_("The program is not being run."));
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
if (non_stop)
error (_("Record btrace can't debug inferior in non-stop mode."));
gdb_assert (record_btrace_thread_observer == NULL);
disable_chain = make_cleanup (null_cleanup, NULL);
Fix next over threaded execl with "set scheduler-locking step". Running gdb.threads/thread-execl.exp with scheduler-locking set to "step" reveals a problem: (gdb) next^M [Thread 0x7ffff7fda700 (LWP 27168) exited]^M [New LWP 27168]^M [Thread 0x7ffff74ee700 (LWP 27174) exited]^M process 27168 is executing new program: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/thread-execl^M [Thread debugging using libthread_db enabled]^M Using host libthread_db library "/lib64/libthread_db.so.1".^M infrun.c:5225: internal-error: switch_back_to_stepped_thread: Assertion `!schedlock_applies (1)' failed.^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M Quit this debugging session? (y or n) FAIL: gdb.threads/thread-execl.exp: schedlock step: get to main in new image (GDB internal error) The assertion is correct. The issue is that GDB is mistakenly trying to switch back to an exited thread, that was previously stepping when it exited. This is exactly the sort of thing the test wants to make sure doesn't happen: # Now set a breakpoint at `main', and step over the execl call. The # breakpoint at main should be reached. GDB should not try to revert # back to the old thread from the old image and resume stepping it We don't see this bug with schedlock off only because a different sequence of events makes GDB manage to delete the thread instead of marking it exited. This particular internal error can be fixed by making the loop over all threads in switch_back_to_stepped_thread skip exited threads. But, looking over other ALL_THREADS users, all either can or should be skipping exited threads too. So for simplicity, this patch replaces ALL_THREADS with a new macro that skips exited threads itself, and updates everything to use it. Tested on x86_64 Fedora 20. gdb/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_THREADS): Delete. (ALL_NON_EXITED_THREADS): New macro. * btrace.c (btrace_free_objfile): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * infrun.c (find_thread_needs_step_over) (switch_back_to_stepped_thread): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * record-btrace.c (record_btrace_open) (record_btrace_stop_recording, record_btrace_close) (record_btrace_is_replaying, record_btrace_resume) (record_btrace_find_thread_to_move, record_btrace_wait): Likewise. * remote.c (append_pending_thread_resumptions): Likewise. * thread.c (thread_apply_all_command): Likewise. gdb/testsuite/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdb.threads/thread-execl.exp (do_test): New procedure, factored out from ... (top level): ... here. Iterate running tests under different scheduler-locking settings.
2014-06-19 12:59:03 +02:00
ALL_NON_EXITED_THREADS (tp)
if (args == NULL || *args == 0 || number_is_in_list (args, tp->num))
{
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
btrace_enable (tp, &record_btrace_conf);
make_cleanup (record_btrace_disable_callback, tp);
}
record_btrace_auto_enable ();
push_target (&record_btrace_ops);
record_btrace_async_inferior_event_handler
= create_async_event_handler (record_btrace_handle_async_inferior_event,
NULL);
record_btrace_generating_corefile = 0;
observer_notify_record_changed (current_inferior (), 1);
discard_cleanups (disable_chain);
}
/* The to_stop_recording method of target record-btrace. */
static void
record_btrace_stop_recording (struct target_ops *self)
{
struct thread_info *tp;
DEBUG ("stop recording");
record_btrace_auto_disable ();
Fix next over threaded execl with "set scheduler-locking step". Running gdb.threads/thread-execl.exp with scheduler-locking set to "step" reveals a problem: (gdb) next^M [Thread 0x7ffff7fda700 (LWP 27168) exited]^M [New LWP 27168]^M [Thread 0x7ffff74ee700 (LWP 27174) exited]^M process 27168 is executing new program: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/thread-execl^M [Thread debugging using libthread_db enabled]^M Using host libthread_db library "/lib64/libthread_db.so.1".^M infrun.c:5225: internal-error: switch_back_to_stepped_thread: Assertion `!schedlock_applies (1)' failed.^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M Quit this debugging session? (y or n) FAIL: gdb.threads/thread-execl.exp: schedlock step: get to main in new image (GDB internal error) The assertion is correct. The issue is that GDB is mistakenly trying to switch back to an exited thread, that was previously stepping when it exited. This is exactly the sort of thing the test wants to make sure doesn't happen: # Now set a breakpoint at `main', and step over the execl call. The # breakpoint at main should be reached. GDB should not try to revert # back to the old thread from the old image and resume stepping it We don't see this bug with schedlock off only because a different sequence of events makes GDB manage to delete the thread instead of marking it exited. This particular internal error can be fixed by making the loop over all threads in switch_back_to_stepped_thread skip exited threads. But, looking over other ALL_THREADS users, all either can or should be skipping exited threads too. So for simplicity, this patch replaces ALL_THREADS with a new macro that skips exited threads itself, and updates everything to use it. Tested on x86_64 Fedora 20. gdb/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_THREADS): Delete. (ALL_NON_EXITED_THREADS): New macro. * btrace.c (btrace_free_objfile): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * infrun.c (find_thread_needs_step_over) (switch_back_to_stepped_thread): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * record-btrace.c (record_btrace_open) (record_btrace_stop_recording, record_btrace_close) (record_btrace_is_replaying, record_btrace_resume) (record_btrace_find_thread_to_move, record_btrace_wait): Likewise. * remote.c (append_pending_thread_resumptions): Likewise. * thread.c (thread_apply_all_command): Likewise. gdb/testsuite/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdb.threads/thread-execl.exp (do_test): New procedure, factored out from ... (top level): ... here. Iterate running tests under different scheduler-locking settings.
2014-06-19 12:59:03 +02:00
ALL_NON_EXITED_THREADS (tp)
if (tp->btrace.target != NULL)
btrace_disable (tp);
}
/* The to_close method of target record-btrace. */
static void
record_btrace_close (struct target_ops *self)
{
struct thread_info *tp;
if (record_btrace_async_inferior_event_handler != NULL)
delete_async_event_handler (&record_btrace_async_inferior_event_handler);
/* Make sure automatic recording gets disabled even if we did not stop
recording before closing the record-btrace target. */
record_btrace_auto_disable ();
/* We should have already stopped recording.
Tear down btrace in case we have not. */
Fix next over threaded execl with "set scheduler-locking step". Running gdb.threads/thread-execl.exp with scheduler-locking set to "step" reveals a problem: (gdb) next^M [Thread 0x7ffff7fda700 (LWP 27168) exited]^M [New LWP 27168]^M [Thread 0x7ffff74ee700 (LWP 27174) exited]^M process 27168 is executing new program: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/thread-execl^M [Thread debugging using libthread_db enabled]^M Using host libthread_db library "/lib64/libthread_db.so.1".^M infrun.c:5225: internal-error: switch_back_to_stepped_thread: Assertion `!schedlock_applies (1)' failed.^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M Quit this debugging session? (y or n) FAIL: gdb.threads/thread-execl.exp: schedlock step: get to main in new image (GDB internal error) The assertion is correct. The issue is that GDB is mistakenly trying to switch back to an exited thread, that was previously stepping when it exited. This is exactly the sort of thing the test wants to make sure doesn't happen: # Now set a breakpoint at `main', and step over the execl call. The # breakpoint at main should be reached. GDB should not try to revert # back to the old thread from the old image and resume stepping it We don't see this bug with schedlock off only because a different sequence of events makes GDB manage to delete the thread instead of marking it exited. This particular internal error can be fixed by making the loop over all threads in switch_back_to_stepped_thread skip exited threads. But, looking over other ALL_THREADS users, all either can or should be skipping exited threads too. So for simplicity, this patch replaces ALL_THREADS with a new macro that skips exited threads itself, and updates everything to use it. Tested on x86_64 Fedora 20. gdb/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_THREADS): Delete. (ALL_NON_EXITED_THREADS): New macro. * btrace.c (btrace_free_objfile): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * infrun.c (find_thread_needs_step_over) (switch_back_to_stepped_thread): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * record-btrace.c (record_btrace_open) (record_btrace_stop_recording, record_btrace_close) (record_btrace_is_replaying, record_btrace_resume) (record_btrace_find_thread_to_move, record_btrace_wait): Likewise. * remote.c (append_pending_thread_resumptions): Likewise. * thread.c (thread_apply_all_command): Likewise. gdb/testsuite/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdb.threads/thread-execl.exp (do_test): New procedure, factored out from ... (top level): ... here. Iterate running tests under different scheduler-locking settings.
2014-06-19 12:59:03 +02:00
ALL_NON_EXITED_THREADS (tp)
btrace_teardown (tp);
}
When disabling target async, remove all target event sources from the event loop The sigall-reverse.exp test occasionally fails with something like this: (gdb) PASS: gdb.reverse/sigall-reverse.exp: send signal TERM continue Continuing. The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?([y] or n) FAIL: gdb.reverse/sigall-reverse.exp: continue to signal exit (timeout) FAIL: gdb.reverse/sigall-reverse.exp: reverse to handler of TERM (timeout) FAIL: gdb.reverse/sigall-reverse.exp: reverse to gen_TERM (timeout) This is another event-loop/async related problem exposed by the patch that made 'query' use gdb_readline_wrapper (588dcc3edbde19f9). The problem is that even though gdb_readline_wrapper disables target-async while the secondary prompt is in progress, the record target's async event source is left marked. So when gdb_readline_wrapper nests an event loop to process input, it may happen that that event loop ends up processing a target event while GDB is not really ready for it. Here's the relevant part of the backtrace showing the root issue in action: ... #14 0x000000000061cb48 in fetch_inferior_event (client_data=0x0) at src/gdb/infrun.c:4158 #15 0x0000000000642917 in inferior_event_handler (event_type=INF_REG_EVENT, client_data=0x0) at src/gdb/inf-loop.c:57 #16 0x000000000077ca5c in record_full_async_inferior_event_handler (data=0x0) at src/gdb/record-full.c:791 #17 0x0000000000640fdf in invoke_async_event_handler (data=...) at src/gdb/event-loop.c:1067 #18 0x000000000063fb01 in process_event () at src/gdb/event-loop.c:339 #19 0x000000000063fb2a in gdb_do_one_event () at src/gdb/event-loop.c:360 #20 0x000000000074d607 in gdb_readline_wrapper (prompt=0x3588f40 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?([y] or n) ") at src/gdb/top.c:842 #21 0x0000000000750bd9 in defaulted_query (ctlstr=0x8c6588 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?", defchar=121 'y', args=0x7fff70524410) at src/gdb/utils.c:1279 #22 0x0000000000750e4c in yquery (ctlstr=0x8c6588 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?") at src/gdb/utils.c:1358 #23 0x00000000004b020e in record_linux_system_call (syscall=gdb_sys_exit_group, regcache=0x3529450, tdep=0xd6c840 <amd64_linux_record_tdep>) at src/gdb/linux-record.c:1933 With my all-stop-on-top-of-non-stop series, I'm also seeing gdb.server/ext-attach.exp fail occasionally due to the same issue. The first part of the fix is for target_async implementations to make sure to remove/unmark all target-related event sources from the event loop. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ 2015-02-03 Pedro Alves <palves@redhat.com> * event-loop.c (clear_async_event_handler): New function. * event-loop.h (clear_async_event_handler): New declaration. * record-btrace.c (record_btrace_async): New function. (init_record_btrace_ops): Install record_btrace_async. * record-full.c (record_full_async): New function. (record_full_resume): Don't mark the async event source here. (init_record_full_ops): Install record_full_async. (record_full_core_resume): Don't mark the async event source here. (init_record_full_core_ops): Install record_full_async. * remote.c (remote_async): Mark and clear the async stop reply queue event-loop token as appropriate.
2015-02-03 16:07:54 +01:00
/* The to_async method of target record-btrace. */
static void
record_btrace_async (struct target_ops *ops,
void (*callback) (enum inferior_event_type event_type,
void *context),
void *context)
{
if (callback != NULL)
mark_async_event_handler (record_btrace_async_inferior_event_handler);
else
clear_async_event_handler (record_btrace_async_inferior_event_handler);
ops->beneath->to_async (ops->beneath, callback, context);
}
record-btrace: add bts buffer size configuration option Allow the size of the branch trace ring buffer to be defined by the user. The specified buffer size will be used when BTS tracing is enabled for new threads. The obtained buffer size may differ from the requested size. The actual buffer size for the current thread is shown in the "info record" command. Bigger buffers mean longer traces, but also longer processing time. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (parse_xml_btrace_conf_bts): Add size. (btrace_conf_bts_attributes): New. (btrace_conf_children): Add attributes. * common/btrace-common.h (btrace_config_bts): New. (btrace_config)<bts>: New. (btrace_config): Update comment. * nat/linux-btrace.c (linux_enable_btrace, linux_enable_bts): Use config. * features/btrace-conf.dtd: Increment version. Add size attribute to bts element. * record-btrace.c (set_record_btrace_bts_cmdlist, show_record_btrace_bts_cmdlist): New. (record_btrace_adjust_size, record_btrace_print_bts_conf, record_btrace_print_conf, cmd_set_record_btrace_bts, cmd_show_record_btrace_bts): New. (record_btrace_info): Call record_btrace_print_conf. (_initialize_record_btrace): Add commands. * remote.c: Add PACKET_Qbtrace_conf_bts_size enum. (remote_protocol_features): Add Qbtrace-conf:bts:size packet. (btrace_sync_conf): Synchronize bts size. (_initialize_remote): Add Qbtrace-conf:bts:size packet. * NEWS: Announce new commands and new packets. doc/ * gdb.texinfo (Branch Trace Configuration Format): Add size. (Process Record and Replay): Describe new set|show commands. (General Query Packets): Describe Qbtrace-conf:bts:size packet. testsuite/ * gdb.btrace/buffer-size: New. gdbserver/ * linux-low.c (linux_low_btrace_conf): Print size. * server.c (handle_btrace_conf_general_set): New. (hanle_general_set): Call handle_btrace_conf_general_set. (handle_query): Report Qbtrace-conf:bts:size as supported.
2013-11-28 16:39:12 +01:00
/* Adjusts the size and returns a human readable size suffix. */
static const char *
record_btrace_adjust_size (unsigned int *size)
{
unsigned int sz;
sz = *size;
if ((sz & ((1u << 30) - 1)) == 0)
{
*size = sz >> 30;
return "GB";
}
else if ((sz & ((1u << 20) - 1)) == 0)
{
*size = sz >> 20;
return "MB";
}
else if ((sz & ((1u << 10) - 1)) == 0)
{
*size = sz >> 10;
return "kB";
}
else
return "";
}
/* Print a BTS configuration. */
static void
record_btrace_print_bts_conf (const struct btrace_config_bts *conf)
{
const char *suffix;
unsigned int size;
size = conf->size;
if (size > 0)
{
suffix = record_btrace_adjust_size (&size);
printf_unfiltered (_("Buffer size: %u%s.\n"), size, suffix);
}
}
/* Print a branch tracing configuration. */
static void
record_btrace_print_conf (const struct btrace_config *conf)
{
printf_unfiltered (_("Recording format: %s.\n"),
btrace_format_string (conf->format));
switch (conf->format)
{
case BTRACE_FORMAT_NONE:
return;
case BTRACE_FORMAT_BTS:
record_btrace_print_bts_conf (&conf->bts);
return;
}
internal_error (__FILE__, __LINE__, _("Unkown branch trace format."));
}
/* The to_info_record method of target record-btrace. */
static void
record_btrace_info (struct target_ops *self)
{
struct btrace_thread_info *btinfo;
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
const struct btrace_config *conf;
struct thread_info *tp;
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
unsigned int insns, calls, gaps;
DEBUG ("info");
tp = find_thread_ptid (inferior_ptid);
if (tp == NULL)
error (_("No thread."));
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
btinfo = &tp->btrace;
conf = btrace_conf (btinfo);
if (conf != NULL)
record-btrace: add bts buffer size configuration option Allow the size of the branch trace ring buffer to be defined by the user. The specified buffer size will be used when BTS tracing is enabled for new threads. The obtained buffer size may differ from the requested size. The actual buffer size for the current thread is shown in the "info record" command. Bigger buffers mean longer traces, but also longer processing time. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (parse_xml_btrace_conf_bts): Add size. (btrace_conf_bts_attributes): New. (btrace_conf_children): Add attributes. * common/btrace-common.h (btrace_config_bts): New. (btrace_config)<bts>: New. (btrace_config): Update comment. * nat/linux-btrace.c (linux_enable_btrace, linux_enable_bts): Use config. * features/btrace-conf.dtd: Increment version. Add size attribute to bts element. * record-btrace.c (set_record_btrace_bts_cmdlist, show_record_btrace_bts_cmdlist): New. (record_btrace_adjust_size, record_btrace_print_bts_conf, record_btrace_print_conf, cmd_set_record_btrace_bts, cmd_show_record_btrace_bts): New. (record_btrace_info): Call record_btrace_print_conf. (_initialize_record_btrace): Add commands. * remote.c: Add PACKET_Qbtrace_conf_bts_size enum. (remote_protocol_features): Add Qbtrace-conf:bts:size packet. (btrace_sync_conf): Synchronize bts size. (_initialize_remote): Add Qbtrace-conf:bts:size packet. * NEWS: Announce new commands and new packets. doc/ * gdb.texinfo (Branch Trace Configuration Format): Add size. (Process Record and Replay): Describe new set|show commands. (General Query Packets): Describe Qbtrace-conf:bts:size packet. testsuite/ * gdb.btrace/buffer-size: New. gdbserver/ * linux-low.c (linux_low_btrace_conf): Print size. * server.c (handle_btrace_conf_general_set): New. (hanle_general_set): Call handle_btrace_conf_general_set. (handle_query): Report Qbtrace-conf:bts:size as supported.
2013-11-28 16:39:12 +01:00
record_btrace_print_conf (conf);
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
btrace_fetch (tp);
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
insns = 0;
calls = 0;
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
gaps = 0;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
if (!btrace_is_empty (tp))
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
{
struct btrace_call_iterator call;
struct btrace_insn_iterator insn;
btrace_call_end (&call, btinfo);
btrace_call_prev (&call, 1);
calls = btrace_call_number (&call);
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btrace_insn_end (&insn, btinfo);
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
insns = btrace_insn_number (&insn);
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
if (insns != 0)
{
/* The last instruction does not really belong to the trace. */
insns -= 1;
}
else
{
unsigned int steps;
/* Skip gaps at the end. */
do
{
steps = btrace_insn_prev (&insn, 1);
if (steps == 0)
break;
insns = btrace_insn_number (&insn);
}
while (insns == 0);
}
gaps = btinfo->ngaps;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
}
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
printf_unfiltered (_("Recorded %u instructions in %u functions (%u gaps) "
"for thread %d (%s).\n"), insns, calls, gaps,
tp->num, target_pid_to_str (tp->ptid));
if (btrace_is_replaying (tp))
printf_unfiltered (_("Replay in progress. At instruction %u.\n"),
btrace_insn_number (btinfo->replay));
}
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
/* Print a decode error. */
static void
btrace_ui_out_decode_error (struct ui_out *uiout, int errcode,
enum btrace_format format)
{
const char *errstr;
int is_error;
errstr = _("unknown");
is_error = 1;
switch (format)
{
default:
break;
case BTRACE_FORMAT_BTS:
switch (errcode)
{
default:
break;
case BDE_BTS_OVERFLOW:
errstr = _("instruction overflow");
break;
case BDE_BTS_INSN_SIZE:
errstr = _("unknown instruction");
break;
}
break;
}
ui_out_text (uiout, _("["));
if (is_error)
{
ui_out_text (uiout, _("decode error ("));
ui_out_field_int (uiout, "errcode", errcode);
ui_out_text (uiout, _("): "));
}
ui_out_text (uiout, errstr);
ui_out_text (uiout, _("]\n"));
}
/* Print an unsigned int. */
static void
ui_out_field_uint (struct ui_out *uiout, const char *fld, unsigned int val)
{
ui_out_field_fmt (uiout, fld, "%u", val);
}
/* Disassemble a section of the recorded instruction trace. */
static void
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btrace_insn_history (struct ui_out *uiout,
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
const struct btrace_thread_info *btinfo,
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
const struct btrace_insn_iterator *begin,
const struct btrace_insn_iterator *end, int flags)
{
struct gdbarch *gdbarch;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
struct btrace_insn_iterator it;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
DEBUG ("itrace (0x%x): [%u; %u)", flags, btrace_insn_number (begin),
btrace_insn_number (end));
gdbarch = target_gdbarch ();
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
for (it = *begin; btrace_insn_cmp (&it, end) != 0; btrace_insn_next (&it, 1))
{
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
const struct btrace_insn *insn;
insn = btrace_insn_get (&it);
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
/* A NULL instruction indicates a gap in the trace. */
if (insn == NULL)
{
const struct btrace_config *conf;
conf = btrace_conf (btinfo);
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
/* We have trace so we must have a configuration. */
gdb_assert (conf != NULL);
btrace_ui_out_decode_error (uiout, it.function->errcode,
conf->format);
}
else
{
/* Print the instruction index. */
ui_out_field_uint (uiout, "index", btrace_insn_number (&it));
ui_out_text (uiout, "\t");
/* Disassembly with '/m' flag may not produce the expected result.
See PR gdb/11833. */
gdb_disassembly (gdbarch, uiout, NULL, flags, 1, insn->pc,
insn->pc + 1);
}
}
}
/* The to_insn_history method of target record-btrace. */
static void
record_btrace_insn_history (struct target_ops *self, int size, int flags)
{
struct btrace_thread_info *btinfo;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
struct btrace_insn_history *history;
struct btrace_insn_iterator begin, end;
struct cleanup *uiout_cleanup;
struct ui_out *uiout;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
unsigned int context, covered;
uiout = current_uiout;
uiout_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout,
"insn history");
context = abs (size);
if (context == 0)
error (_("Bad record instruction-history-size."));
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btinfo = require_btrace ();
history = btinfo->insn_history;
if (history == NULL)
{
struct btrace_insn_iterator *replay;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
DEBUG ("insn-history (0x%x): %d", flags, size);
/* If we're replaying, we start at the replay position. Otherwise, we
start at the tail of the trace. */
replay = btinfo->replay;
if (replay != NULL)
begin = *replay;
else
btrace_insn_end (&begin, btinfo);
/* We start from here and expand in the requested direction. Then we
expand in the other direction, as well, to fill up any remaining
context. */
end = begin;
if (size < 0)
{
/* We want the current position covered, as well. */
covered = btrace_insn_next (&end, 1);
covered += btrace_insn_prev (&begin, context - covered);
covered += btrace_insn_next (&end, context - covered);
}
else
{
covered = btrace_insn_next (&end, context);
covered += btrace_insn_prev (&begin, context - covered);
}
}
else
{
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
begin = history->begin;
end = history->end;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
DEBUG ("insn-history (0x%x): %d, prev: [%u; %u)", flags, size,
btrace_insn_number (&begin), btrace_insn_number (&end));
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
if (size < 0)
{
end = begin;
covered = btrace_insn_prev (&begin, context);
}
else
{
begin = end;
covered = btrace_insn_next (&end, context);
}
}
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
if (covered > 0)
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
btrace_insn_history (uiout, btinfo, &begin, &end, flags);
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
else
{
if (size < 0)
printf_unfiltered (_("At the start of the branch trace record.\n"));
else
printf_unfiltered (_("At the end of the branch trace record.\n"));
}
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btrace_set_insn_history (btinfo, &begin, &end);
do_cleanups (uiout_cleanup);
}
/* The to_insn_history_range method of target record-btrace. */
static void
record_btrace_insn_history_range (struct target_ops *self,
ULONGEST from, ULONGEST to, int flags)
{
struct btrace_thread_info *btinfo;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
struct btrace_insn_history *history;
struct btrace_insn_iterator begin, end;
struct cleanup *uiout_cleanup;
struct ui_out *uiout;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
unsigned int low, high;
int found;
uiout = current_uiout;
uiout_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout,
"insn history");
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
low = from;
high = to;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
DEBUG ("insn-history (0x%x): [%u; %u)", flags, low, high);
/* Check for wrap-arounds. */
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
if (low != from || high != to)
error (_("Bad range."));
if (high < low)
error (_("Bad range."));
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btinfo = require_btrace ();
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
found = btrace_find_insn_by_number (&begin, btinfo, low);
if (found == 0)
error (_("Range out of bounds."));
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
found = btrace_find_insn_by_number (&end, btinfo, high);
if (found == 0)
{
/* Silently truncate the range. */
btrace_insn_end (&end, btinfo);
}
else
{
/* We want both begin and end to be inclusive. */
btrace_insn_next (&end, 1);
}
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
btrace_insn_history (uiout, btinfo, &begin, &end, flags);
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btrace_set_insn_history (btinfo, &begin, &end);
do_cleanups (uiout_cleanup);
}
/* The to_insn_history_from method of target record-btrace. */
static void
record_btrace_insn_history_from (struct target_ops *self,
ULONGEST from, int size, int flags)
{
ULONGEST begin, end, context;
context = abs (size);
if (context == 0)
error (_("Bad record instruction-history-size."));
if (size < 0)
{
end = from;
if (from < context)
begin = 0;
else
begin = from - context + 1;
}
else
{
begin = from;
end = from + context - 1;
/* Check for wrap-around. */
if (end < begin)
end = ULONGEST_MAX;
}
record_btrace_insn_history_range (self, begin, end, flags);
}
/* Print the instruction number range for a function call history line. */
static void
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btrace_call_history_insn_range (struct ui_out *uiout,
const struct btrace_function *bfun)
{
unsigned int begin, end, size;
size = VEC_length (btrace_insn_s, bfun->insn);
gdb_assert (size > 0);
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
begin = bfun->insn_offset;
end = begin + size - 1;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
ui_out_field_uint (uiout, "insn begin", begin);
record-btrace: optionally indent function call history Add a new modifier /c to the "record function-call-history" command to indent the function name based on its depth in the call stack. Also reorder the optional fields to have the indentation at the very beginning. Prefix the insn range (/i modifier) with "inst ". Prefix the source line (/l modifier) with "at ". Change the range syntax from "begin-end" to "begin,end" to allow copy&paste to the "record instruction-history" and "list" commands. Adjust the respective tests and add new tests for the /c modifier. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * record.h (enum record_print_flag) <record_print_indent_calls>: New. * record.c (get_call_history_modifiers): Recognize /c modifier. (_initialize_record): Document /c modifier. * record-btrace.c (btrace_call_history): Add btinfo parameter. Reorder fields. Optionally indent the function name. Update all users. * NEWS: Announce changes. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected field order for "record function-call-history". Add new tests for "record function-call-history /c". * gdb.btrace/exception.cc: New. * gdb.btrace/exception.exp: New. * gdb.btrace/tailcall.exp: New. * gdb.btrace/x86-tailcall.S: New. * gdb.btrace/x86-tailcall.c: New. * gdb.btrace/unknown_functions.c: New. * gdb.btrace/unknown_functions.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo (Process Record and Replay): Document new /c modifier accepted by "record function-call-history". Add /i modifier to "record function-call-history" example.
2013-04-18 10:58:05 +02:00
ui_out_text (uiout, ",");
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
ui_out_field_uint (uiout, "insn end", end);
}
/* Print the source line information for a function call history line. */
static void
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btrace_call_history_src_line (struct ui_out *uiout,
const struct btrace_function *bfun)
{
struct symbol *sym;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
int begin, end;
sym = bfun->sym;
if (sym == NULL)
return;
ui_out_field_string (uiout, "file",
symtab_to_filename_for_display (symbol_symtab (sym)));
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
begin = bfun->lbegin;
end = bfun->lend;
if (end < begin)
return;
ui_out_text (uiout, ":");
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
ui_out_field_int (uiout, "min line", begin);
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
if (end == begin)
return;
record-btrace: optionally indent function call history Add a new modifier /c to the "record function-call-history" command to indent the function name based on its depth in the call stack. Also reorder the optional fields to have the indentation at the very beginning. Prefix the insn range (/i modifier) with "inst ". Prefix the source line (/l modifier) with "at ". Change the range syntax from "begin-end" to "begin,end" to allow copy&paste to the "record instruction-history" and "list" commands. Adjust the respective tests and add new tests for the /c modifier. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * record.h (enum record_print_flag) <record_print_indent_calls>: New. * record.c (get_call_history_modifiers): Recognize /c modifier. (_initialize_record): Document /c modifier. * record-btrace.c (btrace_call_history): Add btinfo parameter. Reorder fields. Optionally indent the function name. Update all users. * NEWS: Announce changes. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected field order for "record function-call-history". Add new tests for "record function-call-history /c". * gdb.btrace/exception.cc: New. * gdb.btrace/exception.exp: New. * gdb.btrace/tailcall.exp: New. * gdb.btrace/x86-tailcall.S: New. * gdb.btrace/x86-tailcall.c: New. * gdb.btrace/unknown_functions.c: New. * gdb.btrace/unknown_functions.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo (Process Record and Replay): Document new /c modifier accepted by "record function-call-history". Add /i modifier to "record function-call-history" example.
2013-04-18 10:58:05 +02:00
ui_out_text (uiout, ",");
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
ui_out_field_int (uiout, "max line", end);
}
/* Get the name of a branch trace function. */
static const char *
btrace_get_bfun_name (const struct btrace_function *bfun)
{
struct minimal_symbol *msym;
struct symbol *sym;
if (bfun == NULL)
return "??";
msym = bfun->msym;
sym = bfun->sym;
if (sym != NULL)
return SYMBOL_PRINT_NAME (sym);
else if (msym != NULL)
change minsym representation 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.
2013-08-15 16:43:43 +02:00
return MSYMBOL_PRINT_NAME (msym);
else
return "??";
}
/* Disassemble a section of the recorded function trace. */
static void
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btrace_call_history (struct ui_out *uiout,
record-btrace: optionally indent function call history Add a new modifier /c to the "record function-call-history" command to indent the function name based on its depth in the call stack. Also reorder the optional fields to have the indentation at the very beginning. Prefix the insn range (/i modifier) with "inst ". Prefix the source line (/l modifier) with "at ". Change the range syntax from "begin-end" to "begin,end" to allow copy&paste to the "record instruction-history" and "list" commands. Adjust the respective tests and add new tests for the /c modifier. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * record.h (enum record_print_flag) <record_print_indent_calls>: New. * record.c (get_call_history_modifiers): Recognize /c modifier. (_initialize_record): Document /c modifier. * record-btrace.c (btrace_call_history): Add btinfo parameter. Reorder fields. Optionally indent the function name. Update all users. * NEWS: Announce changes. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected field order for "record function-call-history". Add new tests for "record function-call-history /c". * gdb.btrace/exception.cc: New. * gdb.btrace/exception.exp: New. * gdb.btrace/tailcall.exp: New. * gdb.btrace/x86-tailcall.S: New. * gdb.btrace/x86-tailcall.c: New. * gdb.btrace/unknown_functions.c: New. * gdb.btrace/unknown_functions.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo (Process Record and Replay): Document new /c modifier accepted by "record function-call-history". Add /i modifier to "record function-call-history" example.
2013-04-18 10:58:05 +02:00
const struct btrace_thread_info *btinfo,
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
const struct btrace_call_iterator *begin,
const struct btrace_call_iterator *end,
enum record_print_flag flags)
{
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
struct btrace_call_iterator it;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
DEBUG ("ftrace (0x%x): [%u; %u)", flags, btrace_call_number (begin),
btrace_call_number (end));
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
for (it = *begin; btrace_call_cmp (&it, end) < 0; btrace_call_next (&it, 1))
{
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
const struct btrace_function *bfun;
struct minimal_symbol *msym;
struct symbol *sym;
bfun = btrace_call_get (&it);
sym = bfun->sym;
msym = bfun->msym;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
/* Print the function index. */
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
ui_out_field_uint (uiout, "index", bfun->number);
ui_out_text (uiout, "\t");
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
/* Indicate gaps in the trace. */
if (bfun->errcode != 0)
{
const struct btrace_config *conf;
conf = btrace_conf (btinfo);
/* We have trace so we must have a configuration. */
gdb_assert (conf != NULL);
btrace_ui_out_decode_error (uiout, bfun->errcode, conf->format);
continue;
}
record-btrace: optionally indent function call history Add a new modifier /c to the "record function-call-history" command to indent the function name based on its depth in the call stack. Also reorder the optional fields to have the indentation at the very beginning. Prefix the insn range (/i modifier) with "inst ". Prefix the source line (/l modifier) with "at ". Change the range syntax from "begin-end" to "begin,end" to allow copy&paste to the "record instruction-history" and "list" commands. Adjust the respective tests and add new tests for the /c modifier. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * record.h (enum record_print_flag) <record_print_indent_calls>: New. * record.c (get_call_history_modifiers): Recognize /c modifier. (_initialize_record): Document /c modifier. * record-btrace.c (btrace_call_history): Add btinfo parameter. Reorder fields. Optionally indent the function name. Update all users. * NEWS: Announce changes. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected field order for "record function-call-history". Add new tests for "record function-call-history /c". * gdb.btrace/exception.cc: New. * gdb.btrace/exception.exp: New. * gdb.btrace/tailcall.exp: New. * gdb.btrace/x86-tailcall.S: New. * gdb.btrace/x86-tailcall.c: New. * gdb.btrace/unknown_functions.c: New. * gdb.btrace/unknown_functions.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo (Process Record and Replay): Document new /c modifier accepted by "record function-call-history". Add /i modifier to "record function-call-history" example.
2013-04-18 10:58:05 +02:00
if ((flags & RECORD_PRINT_INDENT_CALLS) != 0)
{
int level = bfun->level + btinfo->level, i;
for (i = 0; i < level; ++i)
ui_out_text (uiout, " ");
}
if (sym != NULL)
ui_out_field_string (uiout, "function", SYMBOL_PRINT_NAME (sym));
else if (msym != NULL)
change minsym representation 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.
2013-08-15 16:43:43 +02:00
ui_out_field_string (uiout, "function", MSYMBOL_PRINT_NAME (msym));
record-btrace: optionally indent function call history Add a new modifier /c to the "record function-call-history" command to indent the function name based on its depth in the call stack. Also reorder the optional fields to have the indentation at the very beginning. Prefix the insn range (/i modifier) with "inst ". Prefix the source line (/l modifier) with "at ". Change the range syntax from "begin-end" to "begin,end" to allow copy&paste to the "record instruction-history" and "list" commands. Adjust the respective tests and add new tests for the /c modifier. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * record.h (enum record_print_flag) <record_print_indent_calls>: New. * record.c (get_call_history_modifiers): Recognize /c modifier. (_initialize_record): Document /c modifier. * record-btrace.c (btrace_call_history): Add btinfo parameter. Reorder fields. Optionally indent the function name. Update all users. * NEWS: Announce changes. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected field order for "record function-call-history". Add new tests for "record function-call-history /c". * gdb.btrace/exception.cc: New. * gdb.btrace/exception.exp: New. * gdb.btrace/tailcall.exp: New. * gdb.btrace/x86-tailcall.S: New. * gdb.btrace/x86-tailcall.c: New. * gdb.btrace/unknown_functions.c: New. * gdb.btrace/unknown_functions.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo (Process Record and Replay): Document new /c modifier accepted by "record function-call-history". Add /i modifier to "record function-call-history" example.
2013-04-18 10:58:05 +02:00
else if (!ui_out_is_mi_like_p (uiout))
ui_out_field_string (uiout, "function", "??");
if ((flags & RECORD_PRINT_INSN_RANGE) != 0)
{
record-btrace: optionally indent function call history Add a new modifier /c to the "record function-call-history" command to indent the function name based on its depth in the call stack. Also reorder the optional fields to have the indentation at the very beginning. Prefix the insn range (/i modifier) with "inst ". Prefix the source line (/l modifier) with "at ". Change the range syntax from "begin-end" to "begin,end" to allow copy&paste to the "record instruction-history" and "list" commands. Adjust the respective tests and add new tests for the /c modifier. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * record.h (enum record_print_flag) <record_print_indent_calls>: New. * record.c (get_call_history_modifiers): Recognize /c modifier. (_initialize_record): Document /c modifier. * record-btrace.c (btrace_call_history): Add btinfo parameter. Reorder fields. Optionally indent the function name. Update all users. * NEWS: Announce changes. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected field order for "record function-call-history". Add new tests for "record function-call-history /c". * gdb.btrace/exception.cc: New. * gdb.btrace/exception.exp: New. * gdb.btrace/tailcall.exp: New. * gdb.btrace/x86-tailcall.S: New. * gdb.btrace/x86-tailcall.c: New. * gdb.btrace/unknown_functions.c: New. * gdb.btrace/unknown_functions.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo (Process Record and Replay): Document new /c modifier accepted by "record function-call-history". Add /i modifier to "record function-call-history" example.
2013-04-18 10:58:05 +02:00
ui_out_text (uiout, _("\tinst "));
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btrace_call_history_insn_range (uiout, bfun);
}
if ((flags & RECORD_PRINT_SRC_LINE) != 0)
{
record-btrace: optionally indent function call history Add a new modifier /c to the "record function-call-history" command to indent the function name based on its depth in the call stack. Also reorder the optional fields to have the indentation at the very beginning. Prefix the insn range (/i modifier) with "inst ". Prefix the source line (/l modifier) with "at ". Change the range syntax from "begin-end" to "begin,end" to allow copy&paste to the "record instruction-history" and "list" commands. Adjust the respective tests and add new tests for the /c modifier. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * record.h (enum record_print_flag) <record_print_indent_calls>: New. * record.c (get_call_history_modifiers): Recognize /c modifier. (_initialize_record): Document /c modifier. * record-btrace.c (btrace_call_history): Add btinfo parameter. Reorder fields. Optionally indent the function name. Update all users. * NEWS: Announce changes. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected field order for "record function-call-history". Add new tests for "record function-call-history /c". * gdb.btrace/exception.cc: New. * gdb.btrace/exception.exp: New. * gdb.btrace/tailcall.exp: New. * gdb.btrace/x86-tailcall.S: New. * gdb.btrace/x86-tailcall.c: New. * gdb.btrace/unknown_functions.c: New. * gdb.btrace/unknown_functions.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo (Process Record and Replay): Document new /c modifier accepted by "record function-call-history". Add /i modifier to "record function-call-history" example.
2013-04-18 10:58:05 +02:00
ui_out_text (uiout, _("\tat "));
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btrace_call_history_src_line (uiout, bfun);
}
ui_out_text (uiout, "\n");
}
}
/* The to_call_history method of target record-btrace. */
static void
record_btrace_call_history (struct target_ops *self, int size, int flags)
{
struct btrace_thread_info *btinfo;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
struct btrace_call_history *history;
struct btrace_call_iterator begin, end;
struct cleanup *uiout_cleanup;
struct ui_out *uiout;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
unsigned int context, covered;
uiout = current_uiout;
uiout_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout,
"insn history");
context = abs (size);
if (context == 0)
error (_("Bad record function-call-history-size."));
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btinfo = require_btrace ();
history = btinfo->call_history;
if (history == NULL)
{
struct btrace_insn_iterator *replay;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
DEBUG ("call-history (0x%x): %d", flags, size);
/* If we're replaying, we start at the replay position. Otherwise, we
start at the tail of the trace. */
replay = btinfo->replay;
if (replay != NULL)
{
begin.function = replay->function;
begin.btinfo = btinfo;
}
else
btrace_call_end (&begin, btinfo);
/* We start from here and expand in the requested direction. Then we
expand in the other direction, as well, to fill up any remaining
context. */
end = begin;
if (size < 0)
{
/* We want the current position covered, as well. */
covered = btrace_call_next (&end, 1);
covered += btrace_call_prev (&begin, context - covered);
covered += btrace_call_next (&end, context - covered);
}
else
{
covered = btrace_call_next (&end, context);
covered += btrace_call_prev (&begin, context- covered);
}
}
else
{
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
begin = history->begin;
end = history->end;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
DEBUG ("call-history (0x%x): %d, prev: [%u; %u)", flags, size,
btrace_call_number (&begin), btrace_call_number (&end));
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
if (size < 0)
{
end = begin;
covered = btrace_call_prev (&begin, context);
}
else
{
begin = end;
covered = btrace_call_next (&end, context);
}
}
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
if (covered > 0)
record-btrace: optionally indent function call history Add a new modifier /c to the "record function-call-history" command to indent the function name based on its depth in the call stack. Also reorder the optional fields to have the indentation at the very beginning. Prefix the insn range (/i modifier) with "inst ". Prefix the source line (/l modifier) with "at ". Change the range syntax from "begin-end" to "begin,end" to allow copy&paste to the "record instruction-history" and "list" commands. Adjust the respective tests and add new tests for the /c modifier. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * record.h (enum record_print_flag) <record_print_indent_calls>: New. * record.c (get_call_history_modifiers): Recognize /c modifier. (_initialize_record): Document /c modifier. * record-btrace.c (btrace_call_history): Add btinfo parameter. Reorder fields. Optionally indent the function name. Update all users. * NEWS: Announce changes. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected field order for "record function-call-history". Add new tests for "record function-call-history /c". * gdb.btrace/exception.cc: New. * gdb.btrace/exception.exp: New. * gdb.btrace/tailcall.exp: New. * gdb.btrace/x86-tailcall.S: New. * gdb.btrace/x86-tailcall.c: New. * gdb.btrace/unknown_functions.c: New. * gdb.btrace/unknown_functions.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo (Process Record and Replay): Document new /c modifier accepted by "record function-call-history". Add /i modifier to "record function-call-history" example.
2013-04-18 10:58:05 +02:00
btrace_call_history (uiout, btinfo, &begin, &end, flags);
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
else
{
if (size < 0)
printf_unfiltered (_("At the start of the branch trace record.\n"));
else
printf_unfiltered (_("At the end of the branch trace record.\n"));
}
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btrace_set_call_history (btinfo, &begin, &end);
do_cleanups (uiout_cleanup);
}
/* The to_call_history_range method of target record-btrace. */
static void
record_btrace_call_history_range (struct target_ops *self,
ULONGEST from, ULONGEST to, int flags)
{
struct btrace_thread_info *btinfo;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
struct btrace_call_history *history;
struct btrace_call_iterator begin, end;
struct cleanup *uiout_cleanup;
struct ui_out *uiout;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
unsigned int low, high;
int found;
uiout = current_uiout;
uiout_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout,
"func history");
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
low = from;
high = to;
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
DEBUG ("call-history (0x%x): [%u; %u)", flags, low, high);
/* Check for wrap-arounds. */
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
if (low != from || high != to)
error (_("Bad range."));
if (high < low)
error (_("Bad range."));
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btinfo = require_btrace ();
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
found = btrace_find_call_by_number (&begin, btinfo, low);
if (found == 0)
error (_("Range out of bounds."));
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
found = btrace_find_call_by_number (&end, btinfo, high);
if (found == 0)
{
/* Silently truncate the range. */
btrace_call_end (&end, btinfo);
}
else
{
/* We want both begin and end to be inclusive. */
btrace_call_next (&end, 1);
}
record-btrace: optionally indent function call history Add a new modifier /c to the "record function-call-history" command to indent the function name based on its depth in the call stack. Also reorder the optional fields to have the indentation at the very beginning. Prefix the insn range (/i modifier) with "inst ". Prefix the source line (/l modifier) with "at ". Change the range syntax from "begin-end" to "begin,end" to allow copy&paste to the "record instruction-history" and "list" commands. Adjust the respective tests and add new tests for the /c modifier. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * record.h (enum record_print_flag) <record_print_indent_calls>: New. * record.c (get_call_history_modifiers): Recognize /c modifier. (_initialize_record): Document /c modifier. * record-btrace.c (btrace_call_history): Add btinfo parameter. Reorder fields. Optionally indent the function name. Update all users. * NEWS: Announce changes. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected field order for "record function-call-history". Add new tests for "record function-call-history /c". * gdb.btrace/exception.cc: New. * gdb.btrace/exception.exp: New. * gdb.btrace/tailcall.exp: New. * gdb.btrace/x86-tailcall.S: New. * gdb.btrace/x86-tailcall.c: New. * gdb.btrace/unknown_functions.c: New. * gdb.btrace/unknown_functions.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo (Process Record and Replay): Document new /c modifier accepted by "record function-call-history". Add /i modifier to "record function-call-history" example.
2013-04-18 10:58:05 +02:00
btrace_call_history (uiout, btinfo, &begin, &end, flags);
btrace: change branch trace data structure The branch trace is represented as 3 vectors: - a block vector - a instruction vector - a function vector Each vector (except for the first) is computed from the one above. Change this into a graph where a node represents a sequence of instructions belonging to the same function and where we have three types of edges to connect the function segments: - control flow - same function (instance) - call stack This allows us to navigate in the branch trace. We will need this for "record goto" and reverse execution. This patch introduces the data structure and computes the control flow edges. It also introduces iterator structs to simplify iterating over the branch trace in control-flow order. It also fixes PR gdb/15240 since now recursive calls are handled correctly. Fix the test that got the number of expected fib instances and also the function numbers wrong. The current instruction had been part of the branch trace. This will look odd once we start support for reverse execution. Remove it. We still keep it in the trace itself to allow extending the branch trace more easily in the future. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (struct btrace_func_link): New. (enum btrace_function_flag): New. (struct btrace_inst): Rename to ... (struct btrace_insn): ...this. Update all users. (struct btrace_func) <ibegin, iend>: Remove. (struct btrace_func_link): New. (struct btrace_func): Rename to ... (struct btrace_function): ...this. Update all users. (struct btrace_function) <segment, flow, up, insn, insn_offset) (number, level, flags>: New. (struct btrace_insn_iterator): Rename to ... (struct btrace_insn_history): ...this. Update all users. (struct btrace_insn_iterator, btrace_call_iterator): New. (struct btrace_target_info) <btrace, itrace, ftrace>: Remove. (struct btrace_target_info) <begin, end, level> <insn_history, call_history>: New. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * btrace.c (btrace_init_insn_iterator) (btrace_init_func_iterator, compute_itrace): Remove. (ftrace_print_function_name, ftrace_print_filename) (ftrace_skip_file): Change parameter to const. (ftrace_init_func): Remove. (ftrace_debug): Use new btrace_function fields. (ftrace_function_switched): Also consider gaining and losing symbol information). (ftrace_print_insn_addr, ftrace_new_call, ftrace_new_return) (ftrace_new_switch, ftrace_find_caller, ftrace_new_function) (ftrace_update_caller, ftrace_fixup_caller, ftrace_new_tailcall): New. (ftrace_new_function): Move. Remove debug print. (ftrace_update_lines, ftrace_update_insns): New. (ftrace_update_function): Check for call, ret, and jump. (compute_ftrace): Renamed to ... (btrace_compute_ftrace): ...this. Rewritten to compute call stack. (btrace_fetch, btrace_clear): Updated. (btrace_insn_get, btrace_insn_number, btrace_insn_begin) (btrace_insn_end, btrace_insn_prev, btrace_insn_next) (btrace_insn_cmp, btrace_find_insn_by_number, btrace_call_get) (btrace_call_number, btrace_call_begin, btrace_call_end) (btrace_call_prev, btrace_call_next, btrace_call_cmp) (btrace_find_function_by_number, btrace_set_insn_history) (btrace_set_call_history): New. * record-btrace.c (require_btrace): Use new btrace thread info fields. (record_btrace_info, btrace_insn_history) (record_btrace_insn_history, record_btrace_insn_history_range): Use new btrace thread info fields and new iterator. (btrace_func_history_src_line): Rename to ... (btrace_call_history_src_line): ...this. Use new btrace thread info fields. (btrace_func_history): Rename to ... (btrace_call_history): ...this. Use new btrace thread info fields and new iterator. (record_btrace_call_history, record_btrace_call_history_range): Use new btrace thread info fields and new iterator. testsuite/ * gdb.btrace/function_call_history.exp: Fix expected function trace. * gdb.btrace/instruction_history.exp: Initialize traced. Remove traced_functions.
2013-03-22 14:32:47 +01:00
btrace_set_call_history (btinfo, &begin, &end);
do_cleanups (uiout_cleanup);
}
/* The to_call_history_from method of target record-btrace. */
static void
record_btrace_call_history_from (struct target_ops *self,
ULONGEST from, int size, int flags)
{
ULONGEST begin, end, context;
context = abs (size);
if (context == 0)
error (_("Bad record function-call-history-size."));
if (size < 0)
{
end = from;
if (from < context)
begin = 0;
else
begin = from - context + 1;
}
else
{
begin = from;
end = from + context - 1;
/* Check for wrap-around. */
if (end < begin)
end = ULONGEST_MAX;
}
record_btrace_call_history_range (self, begin, end, flags);
}
/* The to_record_is_replaying method of target record-btrace. */
static int
record_btrace_is_replaying (struct target_ops *self)
{
struct thread_info *tp;
Fix next over threaded execl with "set scheduler-locking step". Running gdb.threads/thread-execl.exp with scheduler-locking set to "step" reveals a problem: (gdb) next^M [Thread 0x7ffff7fda700 (LWP 27168) exited]^M [New LWP 27168]^M [Thread 0x7ffff74ee700 (LWP 27174) exited]^M process 27168 is executing new program: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/thread-execl^M [Thread debugging using libthread_db enabled]^M Using host libthread_db library "/lib64/libthread_db.so.1".^M infrun.c:5225: internal-error: switch_back_to_stepped_thread: Assertion `!schedlock_applies (1)' failed.^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M Quit this debugging session? (y or n) FAIL: gdb.threads/thread-execl.exp: schedlock step: get to main in new image (GDB internal error) The assertion is correct. The issue is that GDB is mistakenly trying to switch back to an exited thread, that was previously stepping when it exited. This is exactly the sort of thing the test wants to make sure doesn't happen: # Now set a breakpoint at `main', and step over the execl call. The # breakpoint at main should be reached. GDB should not try to revert # back to the old thread from the old image and resume stepping it We don't see this bug with schedlock off only because a different sequence of events makes GDB manage to delete the thread instead of marking it exited. This particular internal error can be fixed by making the loop over all threads in switch_back_to_stepped_thread skip exited threads. But, looking over other ALL_THREADS users, all either can or should be skipping exited threads too. So for simplicity, this patch replaces ALL_THREADS with a new macro that skips exited threads itself, and updates everything to use it. Tested on x86_64 Fedora 20. gdb/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_THREADS): Delete. (ALL_NON_EXITED_THREADS): New macro. * btrace.c (btrace_free_objfile): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * infrun.c (find_thread_needs_step_over) (switch_back_to_stepped_thread): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * record-btrace.c (record_btrace_open) (record_btrace_stop_recording, record_btrace_close) (record_btrace_is_replaying, record_btrace_resume) (record_btrace_find_thread_to_move, record_btrace_wait): Likewise. * remote.c (append_pending_thread_resumptions): Likewise. * thread.c (thread_apply_all_command): Likewise. gdb/testsuite/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdb.threads/thread-execl.exp (do_test): New procedure, factored out from ... (top level): ... here. Iterate running tests under different scheduler-locking settings.
2014-06-19 12:59:03 +02:00
ALL_NON_EXITED_THREADS (tp)
if (btrace_is_replaying (tp))
return 1;
return 0;
}
/* The to_xfer_partial method of target record-btrace. */
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
static enum target_xfer_status
record_btrace_xfer_partial (struct target_ops *ops, enum target_object object,
const char *annex, gdb_byte *readbuf,
const gdb_byte *writebuf, ULONGEST offset,
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
ULONGEST len, ULONGEST *xfered_len)
{
struct target_ops *t;
/* Filter out requests that don't make sense during replay. */
if (replay_memory_access == replay_memory_access_read_only
&& !record_btrace_generating_corefile
&& record_btrace_is_replaying (ops))
{
switch (object)
{
case TARGET_OBJECT_MEMORY:
{
struct target_section *section;
/* We do not allow writing memory in general. */
if (writebuf != NULL)
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
{
*xfered_len = len;
return TARGET_XFER_UNAVAILABLE;
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
}
/* We allow reading readonly memory. */
section = target_section_by_addr (ops, offset);
if (section != NULL)
{
/* Check if the section we found is readonly. */
if ((bfd_get_section_flags (section->the_bfd_section->owner,
section->the_bfd_section)
& SEC_READONLY) != 0)
{
/* Truncate the request to fit into this section. */
len = min (len, section->endaddr - offset);
break;
}
}
Return target_xfer_status in to_xfer_partial This patch does the conversion of to_xfer_partial from LONGEST (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len); to enum target_xfer_status (*to_xfer_partial) (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len); It changes to_xfer_partial return the transfer status and the transfered length by *XFERED_LEN. Generally, the return status has three stats, - TARGET_XFER_OK, - TARGET_XFER_EOF, - TARGET_XFER_E_XXXX, See the comments to them in 'enum target_xfer_status'. Note that Pedro suggested not name TARGET_XFER_DONE, as it is confusing, compared with "TARGET_XFER_OK". We finally name it TARGET_XFER_EOF. With this change, GDB core can handle unavailable data in a convenient way. The rationale behind this change was mentioned here https://sourceware.org/ml/gdb-patches/2013-10/msg00761.html Consider an object/value like this: 0 100 150 200 512 DDDDDDDDDDDxxxxxxxxxDDDDDD...DDIIIIIIIIIIII..III where D is valid data, and xxx is unavailable data, and I is beyond the end of the object (Invalid). Currently, if we start the xfer at 0, requesting, say 512 bytes, we'll first get back 100 bytes. The xfer machinery then retries fetching [100,512), and gets back TARGET_XFER_E_UNAVAILABLE. That's sufficient when you're either interested in either having the whole of the 512 bytes available, or erroring out. But, in this scenario, we're interested in the data at [150,512). The problem is that the last TARGET_XFER_E_UNAVAILABLE gives us no indication where to start the read next. We'd need something like: get me [0,512) >>> <<< here's [0,100), *xfered_len is 100, returns TARGET_XFER_OK get me [100,512) >>> (**1) <<< [100,150) is unavailable, *xfered_len is 50, return TARGET_XFER_E_UNAVAILABLE. get me [150,512) >>> <<< here's [150,200), *xfered_len is 50, return TARGET_XFER_OK. get me [200,512) >>> <<< no more data, return TARGET_XFER_EOF. This naturally implies pushing down the decision of whether to return TARGET_XFER_E_UNAVAILABLE or something else down to the target. (Which kinds of leads back to tfile itself reading from RO memory from file (though we could export a function in exec.c for that that tfile delegates to, instead of re-adding the old code). Beside this change, we also add a macro TARGET_XFER_STATUS_ERROR_P to check whether a status is an error or not, to stop using "status < 0". This patch also eliminates the comparison between status and 0. No target implementations to to_xfer_partial adapts this new interface. The interface still behaves as before. gdb: 2014-02-11 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_error): Rename to ... (enum target_xfer_status): ... it. New. All users updated. (enum target_xfer_status) <TARGET_XFER_OK>, <TARGET_XFER_EOF>: New. (TARGET_XFER_STATUS_ERROR_P): New macro. (target_xfer_error_to_string): Remove declaration. (target_xfer_status_to_string): Declare. (target_xfer_partial_ftype): Adjust it. (struct target_ops) <to_xfer_partial>: Return target_xfer_status. Add argument xfered_len. Update comments. * target.c (target_xfer_error_to_string): Rename to ... (target_xfer_status_to_string): ... it. New. All callers updated. (target_read_live_memory): Likewise. Call target_xfer_partial instead of target_read. (memory_xfer_live_readonly_partial): Return target_xfer_status. Add argument xfered_len. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1): Likewise. (memory_xfer_partial): Likewise. (target_xfer_partial): Likewise. Check *XFERED_LEN is set properly. Update debug message. (default_xfer_partial, current_xfer_partial): Likewise. (target_write_partial): Likewise. (target_read_partial): Likewise. All callers updated. (read_whatever_is_readable): Likewise. (target_write_with_progress): Likewise. (target_read_alloc_1): Likewise. * aix-thread.c (aix_thread_xfer_partial): Likewise. * auxv.c (procfs_xfer_auxv): Likewise. (ld_so_xfer_auxv, memory_xfer_auxv): Likewise. * bfd-target.c (target_bfd_xfer_partial): Likewise. * bsd-kvm.c (bsd_kvm_xfer_partial): Likewise. * bsd-uthread.c (bsd_uthread_xfer_partia): Likewise. * corefile.c (read_memory): Adjust. * corelow.c (core_xfer_partial): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * darwin-nat.c (darwin_read_dyld_info): Likewise. All callers updated. (darwin_xfer_partial): Likewise. * exec.c (section_table_xfer_memory_partial): Likewise. All callers updated. (exec_xfer_partial): Likewise. * exec.h (section_table_xfer_memory_partial): Update declaration. * gnu-nat.c (gnu_xfer_memory): Likewise. Assert 'res' is not negative. (gnu_xfer_partial): Likewise. * ia64-hpux-nat.c (ia64_hpux_xfer_memory_no_bs): Likewise. (ia64_hpux_xfer_memory, ia64_hpux_xfer_uregs): Likewise. (ia64_hpux_xfer_solib_got): Likewise. * inf-ptrace.c (inf_ptrace_xfer_partial): Likewise. Change type of 'partial_len' to ULONGEST. * inf-ttrace.c (inf_ttrace_xfer_partial): Likewise. * linux-nat.c (linux_xfer_siginfo ): Likewise. (linux_nat_xfer_partial): Likewise. (linux_proc_xfer_partial, linux_xfer_partial): Likewise. (linux_proc_xfer_spu, linux_nat_xfer_osdata): Likewise. * monitor.c (monitor_xfer_memory): Likewise. (monitor_xfer_partial): Likewise. * procfs.c (procfs_xfer_partial): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * record-full.c (record_full_xfer_partial): Likewise. (record_full_core_xfer_partial): Likewise. * remote-sim.c (gdbsim_xfer_memory): Likewise. (gdbsim_xfer_partial): Likewise. * remote.c (remote_write_bytes_aux): Likewise. All callers updated. (remote_write_bytes, remote_read_bytes): Likewise. All callers updated. (remote_flash_erase): Likewise. All callers updated. (remote_write_qxfer): Likewise. All callers updated. (remote_read_qxfer): Likewise. All callers updated. (remote_xfer_partial): Likewise. * rs6000-nat.c (rs6000_xfer_partial): Likewise. (rs6000_xfer_shared_libraries): Likewise. * sol-thread.c (sol_thread_xfer_partial): Likewise. (sol_thread_xfer_partial): Likewise. * sparc-nat.c (sparc_xfer_wcookie): Likewise. (sparc_xfer_partial): Likewise. * spu-linux-nat.c (spu_proc_xfer_spu): Likewise. All callers updated. (spu_xfer_partial): Likewise. * spu-multiarch.c (spu_xfer_partial): Likewise. * tracepoint.c (tfile_xfer_partial): Likewise. * windows-nat.c (windows_xfer_memory): Likewise. (windows_xfer_shared_libraries): Likewise. (windows_xfer_partial): Likewise. * valprint.c: Replace 'target_xfer_error' with 'target_xfer_status' in comments.
2014-01-27 13:35:33 +01:00
*xfered_len = len;
return TARGET_XFER_UNAVAILABLE;
}
}
}
/* Forward the request. */
ops = ops->beneath;
return ops->to_xfer_partial (ops, object, annex, readbuf, writebuf,
offset, len, xfered_len);
}
/* The to_insert_breakpoint method of target record-btrace. */
static int
record_btrace_insert_breakpoint (struct target_ops *ops,
struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
volatile struct gdb_exception except;
const char *old;
int ret;
/* Inserting breakpoints requires accessing memory. Allow it for the
duration of this function. */
old = replay_memory_access;
replay_memory_access = replay_memory_access_read_write;
ret = 0;
TRY_CATCH (except, RETURN_MASK_ALL)
add target method delegation This patch replaces some code in the record targets with target method delegation. record-full.c stores pointers to many target methods when the record target is pushed. Then it later delegates some calls via these. This is wrong because it violates the target stack contract. In particular it is ok to unpush a target at any stratum, but record-full does not keep track of this, so it could potentially call into an unpushed target. This patch fixes the problem by using the newly-introduced generic approach to target delegation for the methods in question. 2014-02-19 Tom Tromey <tromey@redhat.com> * record-full.c (record_full_beneath_to_resume_ops) (record_full_beneath_to_resume, record_full_beneath_to_wait_ops) (record_full_beneath_to_wait) (record_full_beneath_to_store_registers_ops) (record_full_beneath_to_store_registers) (record_full_beneath_to_xfer_partial_ops) (record_full_beneath_to_xfer_partial) (record_full_beneath_to_insert_breakpoint_ops) (record_full_beneath_to_insert_breakpoint) (record_full_beneath_to_remove_breakpoint_ops) (record_full_beneath_to_remove_breakpoint) (record_full_beneath_to_stopped_by_watchpoint) (record_full_beneath_to_stopped_data_address) (record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume) (tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops) (tmp_to_store_registers, tmp_to_xfer_partial_ops) (tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops) (tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops) (tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint) (tmp_to_stopped_data_address, tmp_to_async): Remove. (record_full_open_1, record_full_open): Update. Use RECORD_IS_USED. (record_full_resume, record_full_wait_1) (record_full_stopped_by_watchpoint, record_full_stopped_data_address) (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint) (record_full_async, record_full_core_xfer_partial): Use target delegation. * target-delegates.c: Rebuild. * target.c (current_xfer_partial): Remove. (update_current_target): Do not INHERIT or de_fault to_insert_breakpoint, to_remove_breakpoint, to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p, to_is_async_p, to_async. Do not set to_xfer_partial field. (default_xfer_partial): Simplify. (current_xfer_partial): Remove. (target_wait, target_resume): Simplify. (find_default_can_async_p, find_default_is_async_p): Update. (init_dummy_target): Don't set to_can_async_p, to_is_async_p, to_xfer_partial, to_stopped_by_watchpoint, to_stopped_data_address. (target_store_registers): Simplify. (forward_target_remove_breakpoint) (forward_target_insert_breakpoint): Remove. (target_remove_breakpoint, target_insert_breakpoint) (debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update. * target.h (struct target_ops) <to_resume, to_wait, to_store_registers, to_insert_breakpoint, to_remove_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p, to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT markup. (forward_target_remove_breakpoint) (forward_target_insert_breakpoint): Remove. * record-btrace.c (record_btrace_remove_breakpoint): Delegate directly. (record_btrace_insert_breakpoint): Delegate directly.
2013-07-12 21:00:34 +02:00
ret = ops->beneath->to_insert_breakpoint (ops->beneath, gdbarch, bp_tgt);
replay_memory_access = old;
if (except.reason < 0)
throw_exception (except);
return ret;
}
/* The to_remove_breakpoint method of target record-btrace. */
static int
record_btrace_remove_breakpoint (struct target_ops *ops,
struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
volatile struct gdb_exception except;
const char *old;
int ret;
/* Removing breakpoints requires accessing memory. Allow it for the
duration of this function. */
old = replay_memory_access;
replay_memory_access = replay_memory_access_read_write;
ret = 0;
TRY_CATCH (except, RETURN_MASK_ALL)
add target method delegation This patch replaces some code in the record targets with target method delegation. record-full.c stores pointers to many target methods when the record target is pushed. Then it later delegates some calls via these. This is wrong because it violates the target stack contract. In particular it is ok to unpush a target at any stratum, but record-full does not keep track of this, so it could potentially call into an unpushed target. This patch fixes the problem by using the newly-introduced generic approach to target delegation for the methods in question. 2014-02-19 Tom Tromey <tromey@redhat.com> * record-full.c (record_full_beneath_to_resume_ops) (record_full_beneath_to_resume, record_full_beneath_to_wait_ops) (record_full_beneath_to_wait) (record_full_beneath_to_store_registers_ops) (record_full_beneath_to_store_registers) (record_full_beneath_to_xfer_partial_ops) (record_full_beneath_to_xfer_partial) (record_full_beneath_to_insert_breakpoint_ops) (record_full_beneath_to_insert_breakpoint) (record_full_beneath_to_remove_breakpoint_ops) (record_full_beneath_to_remove_breakpoint) (record_full_beneath_to_stopped_by_watchpoint) (record_full_beneath_to_stopped_data_address) (record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume) (tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops) (tmp_to_store_registers, tmp_to_xfer_partial_ops) (tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops) (tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops) (tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint) (tmp_to_stopped_data_address, tmp_to_async): Remove. (record_full_open_1, record_full_open): Update. Use RECORD_IS_USED. (record_full_resume, record_full_wait_1) (record_full_stopped_by_watchpoint, record_full_stopped_data_address) (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint) (record_full_async, record_full_core_xfer_partial): Use target delegation. * target-delegates.c: Rebuild. * target.c (current_xfer_partial): Remove. (update_current_target): Do not INHERIT or de_fault to_insert_breakpoint, to_remove_breakpoint, to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p, to_is_async_p, to_async. Do not set to_xfer_partial field. (default_xfer_partial): Simplify. (current_xfer_partial): Remove. (target_wait, target_resume): Simplify. (find_default_can_async_p, find_default_is_async_p): Update. (init_dummy_target): Don't set to_can_async_p, to_is_async_p, to_xfer_partial, to_stopped_by_watchpoint, to_stopped_data_address. (target_store_registers): Simplify. (forward_target_remove_breakpoint) (forward_target_insert_breakpoint): Remove. (target_remove_breakpoint, target_insert_breakpoint) (debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update. * target.h (struct target_ops) <to_resume, to_wait, to_store_registers, to_insert_breakpoint, to_remove_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p, to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT markup. (forward_target_remove_breakpoint) (forward_target_insert_breakpoint): Remove. * record-btrace.c (record_btrace_remove_breakpoint): Delegate directly. (record_btrace_insert_breakpoint): Delegate directly.
2013-07-12 21:00:34 +02:00
ret = ops->beneath->to_remove_breakpoint (ops->beneath, gdbarch, bp_tgt);
replay_memory_access = old;
if (except.reason < 0)
throw_exception (except);
return ret;
}
/* The to_fetch_registers method of target record-btrace. */
static void
record_btrace_fetch_registers (struct target_ops *ops,
struct regcache *regcache, int regno)
{
struct btrace_insn_iterator *replay;
struct thread_info *tp;
tp = find_thread_ptid (inferior_ptid);
gdb_assert (tp != NULL);
replay = tp->btrace.replay;
if (replay != NULL && !record_btrace_generating_corefile)
{
const struct btrace_insn *insn;
struct gdbarch *gdbarch;
int pcreg;
gdbarch = get_regcache_arch (regcache);
pcreg = gdbarch_pc_regnum (gdbarch);
if (pcreg < 0)
return;
/* We can only provide the PC register. */
if (regno >= 0 && regno != pcreg)
return;
insn = btrace_insn_get (replay);
gdb_assert (insn != NULL);
regcache_raw_supply (regcache, regno, &insn->pc);
}
else
{
struct target_ops *t = ops->beneath;
t->to_fetch_registers (t, regcache, regno);
}
}
/* The to_store_registers method of target record-btrace. */
static void
record_btrace_store_registers (struct target_ops *ops,
struct regcache *regcache, int regno)
{
struct target_ops *t;
if (!record_btrace_generating_corefile && record_btrace_is_replaying (ops))
error (_("This record target does not allow writing registers."));
gdb_assert (may_write_registers != 0);
t = ops->beneath;
t->to_store_registers (t, regcache, regno);
}
/* The to_prepare_to_store method of target record-btrace. */
static void
record_btrace_prepare_to_store (struct target_ops *ops,
struct regcache *regcache)
{
struct target_ops *t;
if (!record_btrace_generating_corefile && record_btrace_is_replaying (ops))
return;
t = ops->beneath;
t->to_prepare_to_store (t, regcache);
}
/* The branch trace frame cache. */
struct btrace_frame_cache
{
/* The thread. */
struct thread_info *tp;
/* The frame info. */
struct frame_info *frame;
/* The branch trace function segment. */
const struct btrace_function *bfun;
};
/* A struct btrace_frame_cache hash table indexed by NEXT. */
static htab_t bfcache;
/* hash_f for htab_create_alloc of bfcache. */
static hashval_t
bfcache_hash (const void *arg)
{
const struct btrace_frame_cache *cache = arg;
return htab_hash_pointer (cache->frame);
}
/* eq_f for htab_create_alloc of bfcache. */
static int
bfcache_eq (const void *arg1, const void *arg2)
{
const struct btrace_frame_cache *cache1 = arg1;
const struct btrace_frame_cache *cache2 = arg2;
return cache1->frame == cache2->frame;
}
/* Create a new btrace frame cache. */
static struct btrace_frame_cache *
bfcache_new (struct frame_info *frame)
{
struct btrace_frame_cache *cache;
void **slot;
cache = FRAME_OBSTACK_ZALLOC (struct btrace_frame_cache);
cache->frame = frame;
slot = htab_find_slot (bfcache, cache, INSERT);
gdb_assert (*slot == NULL);
*slot = cache;
return cache;
}
/* Extract the branch trace function from a branch trace frame. */
static const struct btrace_function *
btrace_get_frame_function (struct frame_info *frame)
{
const struct btrace_frame_cache *cache;
const struct btrace_function *bfun;
struct btrace_frame_cache pattern;
void **slot;
pattern.frame = frame;
slot = htab_find_slot (bfcache, &pattern, NO_INSERT);
if (slot == NULL)
return NULL;
cache = *slot;
return cache->bfun;
}
/* Implement stop_reason method for record_btrace_frame_unwind. */
static enum unwind_stop_reason
record_btrace_frame_unwind_stop_reason (struct frame_info *this_frame,
void **this_cache)
{
const struct btrace_frame_cache *cache;
const struct btrace_function *bfun;
cache = *this_cache;
bfun = cache->bfun;
gdb_assert (bfun != NULL);
if (bfun->up == NULL)
return UNWIND_UNAVAILABLE;
return UNWIND_NO_REASON;
}
/* Implement this_id method for record_btrace_frame_unwind. */
static void
record_btrace_frame_this_id (struct frame_info *this_frame, void **this_cache,
struct frame_id *this_id)
{
const struct btrace_frame_cache *cache;
const struct btrace_function *bfun;
CORE_ADDR code, special;
cache = *this_cache;
bfun = cache->bfun;
gdb_assert (bfun != NULL);
while (bfun->segment.prev != NULL)
bfun = bfun->segment.prev;
code = get_frame_func (this_frame);
special = bfun->number;
*this_id = frame_id_build_unavailable_stack_special (code, special);
DEBUG ("[frame] %s id: (!stack, pc=%s, special=%s)",
btrace_get_bfun_name (cache->bfun),
core_addr_to_string_nz (this_id->code_addr),
core_addr_to_string_nz (this_id->special_addr));
}
/* Implement prev_register method for record_btrace_frame_unwind. */
static struct value *
record_btrace_frame_prev_register (struct frame_info *this_frame,
void **this_cache,
int regnum)
{
const struct btrace_frame_cache *cache;
const struct btrace_function *bfun, *caller;
const struct btrace_insn *insn;
struct gdbarch *gdbarch;
CORE_ADDR pc;
int pcreg;
gdbarch = get_frame_arch (this_frame);
pcreg = gdbarch_pc_regnum (gdbarch);
if (pcreg < 0 || regnum != pcreg)
throw_error (NOT_AVAILABLE_ERROR,
_("Registers are not available in btrace record history"));
cache = *this_cache;
bfun = cache->bfun;
gdb_assert (bfun != NULL);
caller = bfun->up;
if (caller == NULL)
throw_error (NOT_AVAILABLE_ERROR,
_("No caller in btrace record history"));
if ((bfun->flags & BFUN_UP_LINKS_TO_RET) != 0)
{
insn = VEC_index (btrace_insn_s, caller->insn, 0);
pc = insn->pc;
}
else
{
insn = VEC_last (btrace_insn_s, caller->insn);
pc = insn->pc;
pc += gdb_insn_length (gdbarch, pc);
}
DEBUG ("[frame] unwound PC in %s on level %d: %s",
btrace_get_bfun_name (bfun), bfun->level,
core_addr_to_string_nz (pc));
return frame_unwind_got_address (this_frame, regnum, pc);
}
/* Implement sniffer method for record_btrace_frame_unwind. */
static int
record_btrace_frame_sniffer (const struct frame_unwind *self,
struct frame_info *this_frame,
void **this_cache)
{
const struct btrace_function *bfun;
struct btrace_frame_cache *cache;
struct thread_info *tp;
struct frame_info *next;
/* THIS_FRAME does not contain a reference to its thread. */
tp = find_thread_ptid (inferior_ptid);
gdb_assert (tp != NULL);
bfun = NULL;
next = get_next_frame (this_frame);
if (next == NULL)
{
const struct btrace_insn_iterator *replay;
replay = tp->btrace.replay;
if (replay != NULL)
bfun = replay->function;
}
else
{
const struct btrace_function *callee;
callee = btrace_get_frame_function (next);
if (callee != NULL && (callee->flags & BFUN_UP_LINKS_TO_TAILCALL) == 0)
bfun = callee->up;
}
if (bfun == NULL)
return 0;
DEBUG ("[frame] sniffed frame for %s on level %d",
btrace_get_bfun_name (bfun), bfun->level);
/* This is our frame. Initialize the frame cache. */
cache = bfcache_new (this_frame);
cache->tp = tp;
cache->bfun = bfun;
*this_cache = cache;
return 1;
}
/* Implement sniffer method for record_btrace_tailcall_frame_unwind. */
static int
record_btrace_tailcall_frame_sniffer (const struct frame_unwind *self,
struct frame_info *this_frame,
void **this_cache)
{
const struct btrace_function *bfun, *callee;
struct btrace_frame_cache *cache;
struct frame_info *next;
next = get_next_frame (this_frame);
if (next == NULL)
return 0;
callee = btrace_get_frame_function (next);
if (callee == NULL)
return 0;
if ((callee->flags & BFUN_UP_LINKS_TO_TAILCALL) == 0)
return 0;
bfun = callee->up;
if (bfun == NULL)
return 0;
DEBUG ("[frame] sniffed tailcall frame for %s on level %d",
btrace_get_bfun_name (bfun), bfun->level);
/* This is our frame. Initialize the frame cache. */
cache = bfcache_new (this_frame);
cache->tp = find_thread_ptid (inferior_ptid);
cache->bfun = bfun;
*this_cache = cache;
return 1;
}
static void
record_btrace_frame_dealloc_cache (struct frame_info *self, void *this_cache)
{
struct btrace_frame_cache *cache;
void **slot;
cache = this_cache;
slot = htab_find_slot (bfcache, cache, NO_INSERT);
gdb_assert (slot != NULL);
htab_remove_elt (bfcache, cache);
}
/* btrace recording does not store previous memory content, neither the stack
frames content. Any unwinding would return errorneous results as the stack
contents no longer matches the changed PC value restored from history.
Therefore this unwinder reports any possibly unwound registers as
<unavailable>. */
const struct frame_unwind record_btrace_frame_unwind =
{
NORMAL_FRAME,
record_btrace_frame_unwind_stop_reason,
record_btrace_frame_this_id,
record_btrace_frame_prev_register,
NULL,
record_btrace_frame_sniffer,
record_btrace_frame_dealloc_cache
};
const struct frame_unwind record_btrace_tailcall_frame_unwind =
{
TAILCALL_FRAME,
record_btrace_frame_unwind_stop_reason,
record_btrace_frame_this_id,
record_btrace_frame_prev_register,
NULL,
record_btrace_tailcall_frame_sniffer,
record_btrace_frame_dealloc_cache
};
/* Implement the to_get_unwinder method. */
static const struct frame_unwind *
record_btrace_to_get_unwinder (struct target_ops *self)
{
return &record_btrace_frame_unwind;
}
/* Implement the to_get_tailcall_unwinder method. */
static const struct frame_unwind *
record_btrace_to_get_tailcall_unwinder (struct target_ops *self)
{
return &record_btrace_tailcall_frame_unwind;
}
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
/* Indicate that TP should be resumed according to FLAG. */
static void
record_btrace_resume_thread (struct thread_info *tp,
enum btrace_thread_flag flag)
{
struct btrace_thread_info *btinfo;
DEBUG ("resuming %d (%s): %u", tp->num, target_pid_to_str (tp->ptid), flag);
btinfo = &tp->btrace;
if ((btinfo->flags & BTHR_MOVE) != 0)
error (_("Thread already moving."));
/* Fetch the latest branch trace. */
btrace_fetch (tp);
btinfo->flags |= flag;
}
/* Find the thread to resume given a PTID. */
static struct thread_info *
record_btrace_find_resume_thread (ptid_t ptid)
{
struct thread_info *tp;
/* When asked to resume everything, we pick the current thread. */
if (ptid_equal (minus_one_ptid, ptid) || ptid_is_pid (ptid))
ptid = inferior_ptid;
return find_thread_ptid (ptid);
}
/* Start replaying a thread. */
static struct btrace_insn_iterator *
record_btrace_start_replaying (struct thread_info *tp)
{
volatile struct gdb_exception except;
struct btrace_insn_iterator *replay;
struct btrace_thread_info *btinfo;
int executing;
btinfo = &tp->btrace;
replay = NULL;
/* We can't start replaying without trace. */
if (btinfo->begin == NULL)
return NULL;
/* Clear the executing flag to allow changes to the current frame.
We are not actually running, yet. We just started a reverse execution
command or a record goto command.
For the latter, EXECUTING is false and this has no effect.
For the former, EXECUTING is true and we're in to_wait, about to
move the thread. Since we need to recompute the stack, we temporarily
set EXECUTING to flase. */
executing = is_executing (tp->ptid);
set_executing (tp->ptid, 0);
/* GDB stores the current frame_id when stepping in order to detects steps
into subroutines.
Since frames are computed differently when we're replaying, we need to
recompute those stored frames and fix them up so we can still detect
subroutines after we started replaying. */
TRY_CATCH (except, RETURN_MASK_ALL)
{
struct frame_info *frame;
struct frame_id frame_id;
int upd_step_frame_id, upd_step_stack_frame_id;
/* The current frame without replaying - computed via normal unwind. */
frame = get_current_frame ();
frame_id = get_frame_id (frame);
/* Check if we need to update any stepping-related frame id's. */
upd_step_frame_id = frame_id_eq (frame_id,
tp->control.step_frame_id);
upd_step_stack_frame_id = frame_id_eq (frame_id,
tp->control.step_stack_frame_id);
/* We start replaying at the end of the branch trace. This corresponds
to the current instruction. */
replay = xmalloc (sizeof (*replay));
btrace_insn_end (replay, btinfo);
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
/* Skip gaps at the end of the trace. */
while (btrace_insn_get (replay) == NULL)
{
unsigned int steps;
steps = btrace_insn_prev (replay, 1);
if (steps == 0)
error (_("No trace."));
}
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
/* We're not replaying, yet. */
gdb_assert (btinfo->replay == NULL);
btinfo->replay = replay;
/* Make sure we're not using any stale registers. */
registers_changed_ptid (tp->ptid);
/* The current frame with replaying - computed via btrace unwind. */
frame = get_current_frame ();
frame_id = get_frame_id (frame);
/* Replace stepping related frames where necessary. */
if (upd_step_frame_id)
tp->control.step_frame_id = frame_id;
if (upd_step_stack_frame_id)
tp->control.step_stack_frame_id = frame_id;
}
/* Restore the previous execution state. */
set_executing (tp->ptid, executing);
if (except.reason < 0)
{
xfree (btinfo->replay);
btinfo->replay = NULL;
registers_changed_ptid (tp->ptid);
throw_exception (except);
}
return replay;
}
/* Stop replaying a thread. */
static void
record_btrace_stop_replaying (struct thread_info *tp)
{
struct btrace_thread_info *btinfo;
btinfo = &tp->btrace;
xfree (btinfo->replay);
btinfo->replay = NULL;
/* Make sure we're not leaving any stale registers. */
registers_changed_ptid (tp->ptid);
}
/* The to_resume method of target record-btrace. */
static void
record_btrace_resume (struct target_ops *ops, ptid_t ptid, int step,
enum gdb_signal signal)
{
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
struct thread_info *tp, *other;
enum btrace_thread_flag flag;
DEBUG ("resume %s: %s", target_pid_to_str (ptid), step ? "step" : "cont");
/* Store the execution direction of the last resume. */
record_btrace_resume_exec_dir = execution_direction;
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
tp = record_btrace_find_resume_thread (ptid);
if (tp == NULL)
error (_("Cannot find thread to resume."));
/* Stop replaying other threads if the thread to resume is not replaying. */
if (!btrace_is_replaying (tp) && execution_direction != EXEC_REVERSE)
Fix next over threaded execl with "set scheduler-locking step". Running gdb.threads/thread-execl.exp with scheduler-locking set to "step" reveals a problem: (gdb) next^M [Thread 0x7ffff7fda700 (LWP 27168) exited]^M [New LWP 27168]^M [Thread 0x7ffff74ee700 (LWP 27174) exited]^M process 27168 is executing new program: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/thread-execl^M [Thread debugging using libthread_db enabled]^M Using host libthread_db library "/lib64/libthread_db.so.1".^M infrun.c:5225: internal-error: switch_back_to_stepped_thread: Assertion `!schedlock_applies (1)' failed.^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M Quit this debugging session? (y or n) FAIL: gdb.threads/thread-execl.exp: schedlock step: get to main in new image (GDB internal error) The assertion is correct. The issue is that GDB is mistakenly trying to switch back to an exited thread, that was previously stepping when it exited. This is exactly the sort of thing the test wants to make sure doesn't happen: # Now set a breakpoint at `main', and step over the execl call. The # breakpoint at main should be reached. GDB should not try to revert # back to the old thread from the old image and resume stepping it We don't see this bug with schedlock off only because a different sequence of events makes GDB manage to delete the thread instead of marking it exited. This particular internal error can be fixed by making the loop over all threads in switch_back_to_stepped_thread skip exited threads. But, looking over other ALL_THREADS users, all either can or should be skipping exited threads too. So for simplicity, this patch replaces ALL_THREADS with a new macro that skips exited threads itself, and updates everything to use it. Tested on x86_64 Fedora 20. gdb/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_THREADS): Delete. (ALL_NON_EXITED_THREADS): New macro. * btrace.c (btrace_free_objfile): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * infrun.c (find_thread_needs_step_over) (switch_back_to_stepped_thread): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * record-btrace.c (record_btrace_open) (record_btrace_stop_recording, record_btrace_close) (record_btrace_is_replaying, record_btrace_resume) (record_btrace_find_thread_to_move, record_btrace_wait): Likewise. * remote.c (append_pending_thread_resumptions): Likewise. * thread.c (thread_apply_all_command): Likewise. gdb/testsuite/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdb.threads/thread-execl.exp (do_test): New procedure, factored out from ... (top level): ... here. Iterate running tests under different scheduler-locking settings.
2014-06-19 12:59:03 +02:00
ALL_NON_EXITED_THREADS (other)
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
record_btrace_stop_replaying (other);
/* As long as we're not replaying, just forward the request. */
if (!record_btrace_is_replaying (ops) && execution_direction != EXEC_REVERSE)
{
ops = ops->beneath;
return ops->to_resume (ops, ptid, step, signal);
}
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
/* Compute the btrace thread flag for the requested move. */
if (step == 0)
flag = execution_direction == EXEC_REVERSE ? BTHR_RCONT : BTHR_CONT;
else
flag = execution_direction == EXEC_REVERSE ? BTHR_RSTEP : BTHR_STEP;
/* At the moment, we only move a single thread. We could also move
all threads in parallel by single-stepping each resumed thread
until the first runs into an event.
When we do that, we would want to continue all other threads.
For now, just resume one thread to not confuse to_wait. */
record_btrace_resume_thread (tp, flag);
/* We just indicate the resume intent here. The actual stepping happens in
record_btrace_wait below. */
/* Async support. */
if (target_can_async_p ())
{
target_async (inferior_event_handler, 0);
mark_async_event_handler (record_btrace_async_inferior_event_handler);
}
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
}
/* Find a thread to move. */
static struct thread_info *
record_btrace_find_thread_to_move (ptid_t ptid)
{
struct thread_info *tp;
/* First check the parameter thread. */
tp = find_thread_ptid (ptid);
if (tp != NULL && (tp->btrace.flags & BTHR_MOVE) != 0)
return tp;
/* Otherwise, find one other thread that has been resumed. */
Fix next over threaded execl with "set scheduler-locking step". Running gdb.threads/thread-execl.exp with scheduler-locking set to "step" reveals a problem: (gdb) next^M [Thread 0x7ffff7fda700 (LWP 27168) exited]^M [New LWP 27168]^M [Thread 0x7ffff74ee700 (LWP 27174) exited]^M process 27168 is executing new program: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/thread-execl^M [Thread debugging using libthread_db enabled]^M Using host libthread_db library "/lib64/libthread_db.so.1".^M infrun.c:5225: internal-error: switch_back_to_stepped_thread: Assertion `!schedlock_applies (1)' failed.^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M Quit this debugging session? (y or n) FAIL: gdb.threads/thread-execl.exp: schedlock step: get to main in new image (GDB internal error) The assertion is correct. The issue is that GDB is mistakenly trying to switch back to an exited thread, that was previously stepping when it exited. This is exactly the sort of thing the test wants to make sure doesn't happen: # Now set a breakpoint at `main', and step over the execl call. The # breakpoint at main should be reached. GDB should not try to revert # back to the old thread from the old image and resume stepping it We don't see this bug with schedlock off only because a different sequence of events makes GDB manage to delete the thread instead of marking it exited. This particular internal error can be fixed by making the loop over all threads in switch_back_to_stepped_thread skip exited threads. But, looking over other ALL_THREADS users, all either can or should be skipping exited threads too. So for simplicity, this patch replaces ALL_THREADS with a new macro that skips exited threads itself, and updates everything to use it. Tested on x86_64 Fedora 20. gdb/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_THREADS): Delete. (ALL_NON_EXITED_THREADS): New macro. * btrace.c (btrace_free_objfile): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * infrun.c (find_thread_needs_step_over) (switch_back_to_stepped_thread): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * record-btrace.c (record_btrace_open) (record_btrace_stop_recording, record_btrace_close) (record_btrace_is_replaying, record_btrace_resume) (record_btrace_find_thread_to_move, record_btrace_wait): Likewise. * remote.c (append_pending_thread_resumptions): Likewise. * thread.c (thread_apply_all_command): Likewise. gdb/testsuite/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdb.threads/thread-execl.exp (do_test): New procedure, factored out from ... (top level): ... here. Iterate running tests under different scheduler-locking settings.
2014-06-19 12:59:03 +02:00
ALL_NON_EXITED_THREADS (tp)
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
if ((tp->btrace.flags & BTHR_MOVE) != 0)
return tp;
return NULL;
}
/* Return a target_waitstatus indicating that we ran out of history. */
static struct target_waitstatus
btrace_step_no_history (void)
{
struct target_waitstatus status;
status.kind = TARGET_WAITKIND_NO_HISTORY;
return status;
}
/* Return a target_waitstatus indicating that a step finished. */
static struct target_waitstatus
btrace_step_stopped (void)
{
struct target_waitstatus status;
status.kind = TARGET_WAITKIND_STOPPED;
status.value.sig = GDB_SIGNAL_TRAP;
return status;
}
/* Clear the record histories. */
static void
record_btrace_clear_histories (struct btrace_thread_info *btinfo)
{
xfree (btinfo->insn_history);
xfree (btinfo->call_history);
btinfo->insn_history = NULL;
btinfo->call_history = NULL;
}
/* Step a single thread. */
static struct target_waitstatus
record_btrace_step_thread (struct thread_info *tp)
{
struct btrace_insn_iterator *replay, end;
struct btrace_thread_info *btinfo;
struct address_space *aspace;
struct inferior *inf;
enum btrace_thread_flag flags;
unsigned int steps;
/* We can't step without an execution history. */
if (btrace_is_empty (tp))
return btrace_step_no_history ();
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
btinfo = &tp->btrace;
replay = btinfo->replay;
flags = btinfo->flags & BTHR_MOVE;
btinfo->flags &= ~BTHR_MOVE;
DEBUG ("stepping %d (%s): %u", tp->num, target_pid_to_str (tp->ptid), flags);
switch (flags)
{
default:
internal_error (__FILE__, __LINE__, _("invalid stepping type."));
case BTHR_STEP:
/* We're done if we're not replaying. */
if (replay == NULL)
return btrace_step_no_history ();
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
/* Skip gaps during replay. */
do
{
steps = btrace_insn_next (replay, 1);
if (steps == 0)
{
record_btrace_stop_replaying (tp);
return btrace_step_no_history ();
}
}
while (btrace_insn_get (replay) == NULL);
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
/* Determine the end of the instruction trace. */
btrace_insn_end (&end, btinfo);
/* We stop replaying if we reached the end of the trace. */
if (btrace_insn_cmp (replay, &end) == 0)
record_btrace_stop_replaying (tp);
return btrace_step_stopped ();
case BTHR_RSTEP:
/* Start replaying if we're not already doing so. */
if (replay == NULL)
replay = record_btrace_start_replaying (tp);
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
/* If we can't step any further, we reached the end of the history.
Skip gaps during replay. */
do
{
steps = btrace_insn_prev (replay, 1);
if (steps == 0)
return btrace_step_no_history ();
}
while (btrace_insn_get (replay) == NULL);
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
return btrace_step_stopped ();
case BTHR_CONT:
/* We're done if we're not replaying. */
if (replay == NULL)
return btrace_step_no_history ();
inf = find_inferior_ptid (tp->ptid);
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
aspace = inf->aspace;
/* Determine the end of the instruction trace. */
btrace_insn_end (&end, btinfo);
for (;;)
{
const struct btrace_insn *insn;
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
/* Skip gaps during replay. */
do
{
steps = btrace_insn_next (replay, 1);
if (steps == 0)
{
record_btrace_stop_replaying (tp);
return btrace_step_no_history ();
}
insn = btrace_insn_get (replay);
}
while (insn == NULL);
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
/* We stop replaying if we reached the end of the trace. */
if (btrace_insn_cmp (replay, &end) == 0)
{
record_btrace_stop_replaying (tp);
return btrace_step_no_history ();
}
DEBUG ("stepping %d (%s) ... %s", tp->num,
target_pid_to_str (tp->ptid),
core_addr_to_string_nz (insn->pc));
if (breakpoint_here_p (aspace, insn->pc))
return btrace_step_stopped ();
}
case BTHR_RCONT:
/* Start replaying if we're not already doing so. */
if (replay == NULL)
replay = record_btrace_start_replaying (tp);
inf = find_inferior_ptid (tp->ptid);
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
aspace = inf->aspace;
for (;;)
{
const struct btrace_insn *insn;
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
/* If we can't step any further, we reached the end of the history.
Skip gaps during replay. */
do
{
steps = btrace_insn_prev (replay, 1);
if (steps == 0)
return btrace_step_no_history ();
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
record-btrace: indicate gaps Indicate gaps in the trace due to decode errors. Internally, a gap is represented as a btrace function segment without instructions and with a non-zero format-specific error code. Show the gap when traversing the instruction or function call history. Also indicate gaps in "info record". It looks like this: (gdb) info record Active record target: record-btrace Recording format: Branch Trace Store. Buffer size: 64KB. Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182). (gdb) record function-call-history /cli 1 fib inst 1,9 at src/fib.c:9,14 2 fib inst 10,20 at src/fib.c:6,14 3 [decode error (1): instruction overflow] 4 fib inst 21,28 at src/fib.c:11,14 5 fib inst 29,33 at src/fib.c:6,9 (gdb) record instruction-history 20,22 20 0x000000000040062f <fib+47>: sub $0x1,%rax [decode error (1): instruction overflow] 21 0x0000000000400613 <fib+19>: add $0x1,%rax 22 0x0000000000400617 <fib+23>: mov %rax,0x200a3a(%rip) (gdb) Gaps are ignored during reverse execution and replay. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (ftrace_find_call): Skip gaps. (ftrace_new_function): Initialize level. (ftrace_new_call, ftrace_new_tailcall, ftrace_new_return) (ftrace_new_switch): Update level computation. (ftrace_new_gap): New. (ftrace_update_function): Create new function after gap. (btrace_compute_ftrace_bts): Create gap on error. (btrace_stitch_bts): Update parameters. Clear trace if it becomes empty. (btrace_stitch_trace): Update parameters. Update callers. (btrace_clear): Reset the number of gaps. (btrace_insn_get): Return NULL if the iterator points to a gap. (btrace_insn_number): Return zero if the iterator points to a gap. (btrace_insn_end): Allow gaps at the end. (btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps. (btrace_find_insn_by_number): Assert that the found iterator does not point to a gap. (btrace_call_next, btrace_call_prev): Assert that the last function is not a gap. * btrace.h (btrace_bts_error): New. (btrace_function): Update comment. (btrace_function) <insn, insn_offset, number>: Update comment. (btrace_function) <errcode>: New. (btrace_thread_info) <ngaps>: New. (btrace_thread_info) <replay>: Update comment. (btrace_insn_get): Update comment. * record-btrace.c (btrace_ui_out_decode_error): New. (record_btrace_info): Print number of gaps. (btrace_insn_history, btrace_call_history): Call btrace_ui_out_decode_error for gaps. (record_btrace_step_thread, record_btrace_start_replaying): Skip gaps. testsuite/ * gdb.btrace/buffer-size.exp: Update "info record" output. * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2014-01-30 09:51:10 +01:00
insn = btrace_insn_get (replay);
}
while (insn == NULL);
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
DEBUG ("reverse-stepping %d (%s) ... %s", tp->num,
target_pid_to_str (tp->ptid),
core_addr_to_string_nz (insn->pc));
if (breakpoint_here_p (aspace, insn->pc))
return btrace_step_stopped ();
}
}
}
/* The to_wait method of target record-btrace. */
static ptid_t
record_btrace_wait (struct target_ops *ops, ptid_t ptid,
struct target_waitstatus *status, int options)
{
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
struct thread_info *tp, *other;
DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid), options);
/* As long as we're not replaying, just forward the request. */
if (!record_btrace_is_replaying (ops) && execution_direction != EXEC_REVERSE)
{
ops = ops->beneath;
return ops->to_wait (ops, ptid, status, options);
}
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
/* Let's find a thread to move. */
tp = record_btrace_find_thread_to_move (ptid);
if (tp == NULL)
{
DEBUG ("wait %s: no thread", target_pid_to_str (ptid));
status->kind = TARGET_WAITKIND_IGNORE;
return minus_one_ptid;
}
/* We only move a single thread. We're not able to correlate threads. */
*status = record_btrace_step_thread (tp);
/* Stop all other threads. */
if (!non_stop)
Fix next over threaded execl with "set scheduler-locking step". Running gdb.threads/thread-execl.exp with scheduler-locking set to "step" reveals a problem: (gdb) next^M [Thread 0x7ffff7fda700 (LWP 27168) exited]^M [New LWP 27168]^M [Thread 0x7ffff74ee700 (LWP 27174) exited]^M process 27168 is executing new program: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/thread-execl^M [Thread debugging using libthread_db enabled]^M Using host libthread_db library "/lib64/libthread_db.so.1".^M infrun.c:5225: internal-error: switch_back_to_stepped_thread: Assertion `!schedlock_applies (1)' failed.^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M Quit this debugging session? (y or n) FAIL: gdb.threads/thread-execl.exp: schedlock step: get to main in new image (GDB internal error) The assertion is correct. The issue is that GDB is mistakenly trying to switch back to an exited thread, that was previously stepping when it exited. This is exactly the sort of thing the test wants to make sure doesn't happen: # Now set a breakpoint at `main', and step over the execl call. The # breakpoint at main should be reached. GDB should not try to revert # back to the old thread from the old image and resume stepping it We don't see this bug with schedlock off only because a different sequence of events makes GDB manage to delete the thread instead of marking it exited. This particular internal error can be fixed by making the loop over all threads in switch_back_to_stepped_thread skip exited threads. But, looking over other ALL_THREADS users, all either can or should be skipping exited threads too. So for simplicity, this patch replaces ALL_THREADS with a new macro that skips exited threads itself, and updates everything to use it. Tested on x86_64 Fedora 20. gdb/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdbthread.h (ALL_THREADS): Delete. (ALL_NON_EXITED_THREADS): New macro. * btrace.c (btrace_free_objfile): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * infrun.c (find_thread_needs_step_over) (switch_back_to_stepped_thread): Use ALL_NON_EXITED_THREADS instead of ALL_THREADS. * record-btrace.c (record_btrace_open) (record_btrace_stop_recording, record_btrace_close) (record_btrace_is_replaying, record_btrace_resume) (record_btrace_find_thread_to_move, record_btrace_wait): Likewise. * remote.c (append_pending_thread_resumptions): Likewise. * thread.c (thread_apply_all_command): Likewise. gdb/testsuite/ 2014-06-19 Pedro Alves <palves@redhat.com> * gdb.threads/thread-execl.exp (do_test): New procedure, factored out from ... (top level): ... here. Iterate running tests under different scheduler-locking settings.
2014-06-19 12:59:03 +02:00
ALL_NON_EXITED_THREADS (other)
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
other->btrace.flags &= ~BTHR_MOVE;
/* Start record histories anew from the current position. */
record_btrace_clear_histories (&tp->btrace);
/* We moved the replay position but did not update registers. */
registers_changed_ptid (tp->ptid);
return tp->ptid;
}
/* The to_can_execute_reverse method of target record-btrace. */
static int
record_btrace_can_execute_reverse (struct target_ops *self)
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
{
return 1;
}
/* The to_decr_pc_after_break method of target record-btrace. */
static CORE_ADDR
record_btrace_decr_pc_after_break (struct target_ops *ops,
struct gdbarch *gdbarch)
{
/* When replaying, we do not actually execute the breakpoint instruction
so there is no need to adjust the PC after hitting a breakpoint. */
if (record_btrace_is_replaying (ops))
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
return 0;
return ops->beneath->to_decr_pc_after_break (ops->beneath, gdbarch);
}
Push pruning old threads down to the target When GDB wants to sync the thread list with the target's (e.g., due to "info threads"), it calls update_thread_list: update_thread_list (void) { prune_threads (); target_find_new_threads (); update_threads_executing (); } And then prune_threads does: prune_threads (void) { struct thread_info *tp, *next; for (tp = thread_list; tp; tp = next) { next = tp->next; if (!thread_alive (tp)) delete_thread (tp->ptid); } } Calling thread_live on each thread one by one is expensive. E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not a big deal, but still a bunch of syscalls... With the remote target, it's cumbersome. That thread_alive call ends up generating one T packet per thread: Sending packet: $Tp2141.2150#82...Packet received: OK Sending packet: $Tp2141.214f#b7...Packet received: OK Sending packet: $Tp2141.2141#82...Packet received: OK Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n That seems a bit silly when target_find_new_threads method implementations will always fetch the whole current set of target threads, and then add those that are not in GDB's thread list, to GDB's thread list. This patch thus pushes down the responsibility of pruning dead threads to the target_find_new_threads method instead, so a target may implement pruning dead threads however it wants. Once we do that, target_find_new_threads becomes a misnomer, so the patch renames it to target_update_thread_list. The patch doesn't attempt to do any optimization to any target yet. It simply exports prune_threads, and makes all implementations of target_update_thread_list call that. It's meant to be a no-op. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * ada-tasks.c (print_ada_task_info, task_command_1): Adjust. * bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ... (bsd_uthread_update_thread_list): ... this. Call prune_threads. (bsd_uthread_target): Adjust. * corelow.c (core_open): Adjust. * dec-thread.c (dec_thread_find_new_threads): Update comment. (dec_thread_update_thread_list): New function. (init_dec_thread_ops): Adjust. * gdbthread.h (prune_threads): New declaration. * linux-thread-db.c (thread_db_find_new_threads): Rename to ... (thread_db_update_thread_list): ... this. Call prune_threads. (init_thread_db_ops): Adjust. * nto-procfs.c (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. (procfs_attach, procfs_create_inferior, init_procfs_targets): Adjust. * obsd-nat.c (obsd_find_new_threads): Rename to ... (obsd_update_thread_list): ... this. Call prune_threads. (obsd_add_target): Adjust. * procfs.c (procfs_target): Adjust. (procfs_notice_thread): Update comment. (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. * ravenscar-thread.c (ravenscar_update_inferior_ptid): Update comment. (ravenscar_wait): Adjust. (ravenscar_find_new_threads): Rename to ... (ravenscar_update_thread_list): ... this. Call prune_threads. (init_ravenscar_thread_ops): Adjust. * record-btrace.c (record_btrace_find_new_threads): Rename to ... (record_btrace_update_thread_list): ... this. Adjust comment. (init_record_btrace_ops): Adjust. * remote.c (remote_threads_info): Rename to ... (remote_update_thread_list): ... this. Call prune_threads. (remote_start_remote, extended_remote_attach_1, init_remote_ops): Adjust. * sol-thread.c (check_for_thread_db): Adjust. (sol_find_new_threads_callback): Rename to ... (sol_update_thread_list_callback): ... this. (sol_find_new_threads): Rename to ... (sol_update_thread_list): ... this. Call prune_threads. Adjust. (sol_get_ada_task_ptid, init_sol_thread_ops): Adjust. * target-delegates.c: Regenerate. * target.c (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * target.h (struct target_ops): Rename to_find_new_threads field to to_update_thread_list. (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * thread.c (prune_threads): Make extern. (update_thread_list): Adjust.
2014-10-15 23:44:00 +02:00
/* The to_update_thread_list method of target record-btrace. */
static void
Push pruning old threads down to the target When GDB wants to sync the thread list with the target's (e.g., due to "info threads"), it calls update_thread_list: update_thread_list (void) { prune_threads (); target_find_new_threads (); update_threads_executing (); } And then prune_threads does: prune_threads (void) { struct thread_info *tp, *next; for (tp = thread_list; tp; tp = next) { next = tp->next; if (!thread_alive (tp)) delete_thread (tp->ptid); } } Calling thread_live on each thread one by one is expensive. E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not a big deal, but still a bunch of syscalls... With the remote target, it's cumbersome. That thread_alive call ends up generating one T packet per thread: Sending packet: $Tp2141.2150#82...Packet received: OK Sending packet: $Tp2141.214f#b7...Packet received: OK Sending packet: $Tp2141.2141#82...Packet received: OK Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n That seems a bit silly when target_find_new_threads method implementations will always fetch the whole current set of target threads, and then add those that are not in GDB's thread list, to GDB's thread list. This patch thus pushes down the responsibility of pruning dead threads to the target_find_new_threads method instead, so a target may implement pruning dead threads however it wants. Once we do that, target_find_new_threads becomes a misnomer, so the patch renames it to target_update_thread_list. The patch doesn't attempt to do any optimization to any target yet. It simply exports prune_threads, and makes all implementations of target_update_thread_list call that. It's meant to be a no-op. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * ada-tasks.c (print_ada_task_info, task_command_1): Adjust. * bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ... (bsd_uthread_update_thread_list): ... this. Call prune_threads. (bsd_uthread_target): Adjust. * corelow.c (core_open): Adjust. * dec-thread.c (dec_thread_find_new_threads): Update comment. (dec_thread_update_thread_list): New function. (init_dec_thread_ops): Adjust. * gdbthread.h (prune_threads): New declaration. * linux-thread-db.c (thread_db_find_new_threads): Rename to ... (thread_db_update_thread_list): ... this. Call prune_threads. (init_thread_db_ops): Adjust. * nto-procfs.c (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. (procfs_attach, procfs_create_inferior, init_procfs_targets): Adjust. * obsd-nat.c (obsd_find_new_threads): Rename to ... (obsd_update_thread_list): ... this. Call prune_threads. (obsd_add_target): Adjust. * procfs.c (procfs_target): Adjust. (procfs_notice_thread): Update comment. (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. * ravenscar-thread.c (ravenscar_update_inferior_ptid): Update comment. (ravenscar_wait): Adjust. (ravenscar_find_new_threads): Rename to ... (ravenscar_update_thread_list): ... this. Call prune_threads. (init_ravenscar_thread_ops): Adjust. * record-btrace.c (record_btrace_find_new_threads): Rename to ... (record_btrace_update_thread_list): ... this. Adjust comment. (init_record_btrace_ops): Adjust. * remote.c (remote_threads_info): Rename to ... (remote_update_thread_list): ... this. Call prune_threads. (remote_start_remote, extended_remote_attach_1, init_remote_ops): Adjust. * sol-thread.c (check_for_thread_db): Adjust. (sol_find_new_threads_callback): Rename to ... (sol_update_thread_list_callback): ... this. (sol_find_new_threads): Rename to ... (sol_update_thread_list): ... this. Call prune_threads. Adjust. (sol_get_ada_task_ptid, init_sol_thread_ops): Adjust. * target-delegates.c: Regenerate. * target.c (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * target.h (struct target_ops): Rename to_find_new_threads field to to_update_thread_list. (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * thread.c (prune_threads): Make extern. (update_thread_list): Adjust.
2014-10-15 23:44:00 +02:00
record_btrace_update_thread_list (struct target_ops *ops)
{
Push pruning old threads down to the target When GDB wants to sync the thread list with the target's (e.g., due to "info threads"), it calls update_thread_list: update_thread_list (void) { prune_threads (); target_find_new_threads (); update_threads_executing (); } And then prune_threads does: prune_threads (void) { struct thread_info *tp, *next; for (tp = thread_list; tp; tp = next) { next = tp->next; if (!thread_alive (tp)) delete_thread (tp->ptid); } } Calling thread_live on each thread one by one is expensive. E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not a big deal, but still a bunch of syscalls... With the remote target, it's cumbersome. That thread_alive call ends up generating one T packet per thread: Sending packet: $Tp2141.2150#82...Packet received: OK Sending packet: $Tp2141.214f#b7...Packet received: OK Sending packet: $Tp2141.2141#82...Packet received: OK Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n That seems a bit silly when target_find_new_threads method implementations will always fetch the whole current set of target threads, and then add those that are not in GDB's thread list, to GDB's thread list. This patch thus pushes down the responsibility of pruning dead threads to the target_find_new_threads method instead, so a target may implement pruning dead threads however it wants. Once we do that, target_find_new_threads becomes a misnomer, so the patch renames it to target_update_thread_list. The patch doesn't attempt to do any optimization to any target yet. It simply exports prune_threads, and makes all implementations of target_update_thread_list call that. It's meant to be a no-op. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * ada-tasks.c (print_ada_task_info, task_command_1): Adjust. * bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ... (bsd_uthread_update_thread_list): ... this. Call prune_threads. (bsd_uthread_target): Adjust. * corelow.c (core_open): Adjust. * dec-thread.c (dec_thread_find_new_threads): Update comment. (dec_thread_update_thread_list): New function. (init_dec_thread_ops): Adjust. * gdbthread.h (prune_threads): New declaration. * linux-thread-db.c (thread_db_find_new_threads): Rename to ... (thread_db_update_thread_list): ... this. Call prune_threads. (init_thread_db_ops): Adjust. * nto-procfs.c (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. (procfs_attach, procfs_create_inferior, init_procfs_targets): Adjust. * obsd-nat.c (obsd_find_new_threads): Rename to ... (obsd_update_thread_list): ... this. Call prune_threads. (obsd_add_target): Adjust. * procfs.c (procfs_target): Adjust. (procfs_notice_thread): Update comment. (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. * ravenscar-thread.c (ravenscar_update_inferior_ptid): Update comment. (ravenscar_wait): Adjust. (ravenscar_find_new_threads): Rename to ... (ravenscar_update_thread_list): ... this. Call prune_threads. (init_ravenscar_thread_ops): Adjust. * record-btrace.c (record_btrace_find_new_threads): Rename to ... (record_btrace_update_thread_list): ... this. Adjust comment. (init_record_btrace_ops): Adjust. * remote.c (remote_threads_info): Rename to ... (remote_update_thread_list): ... this. Call prune_threads. (remote_start_remote, extended_remote_attach_1, init_remote_ops): Adjust. * sol-thread.c (check_for_thread_db): Adjust. (sol_find_new_threads_callback): Rename to ... (sol_update_thread_list_callback): ... this. (sol_find_new_threads): Rename to ... (sol_update_thread_list): ... this. Call prune_threads. Adjust. (sol_get_ada_task_ptid, init_sol_thread_ops): Adjust. * target-delegates.c: Regenerate. * target.c (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * target.h (struct target_ops): Rename to_find_new_threads field to to_update_thread_list. (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * thread.c (prune_threads): Make extern. (update_thread_list): Adjust.
2014-10-15 23:44:00 +02:00
/* We don't add or remove threads during replay. */
if (record_btrace_is_replaying (ops))
return;
/* Forward the request. */
ops = ops->beneath;
Push pruning old threads down to the target When GDB wants to sync the thread list with the target's (e.g., due to "info threads"), it calls update_thread_list: update_thread_list (void) { prune_threads (); target_find_new_threads (); update_threads_executing (); } And then prune_threads does: prune_threads (void) { struct thread_info *tp, *next; for (tp = thread_list; tp; tp = next) { next = tp->next; if (!thread_alive (tp)) delete_thread (tp->ptid); } } Calling thread_live on each thread one by one is expensive. E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not a big deal, but still a bunch of syscalls... With the remote target, it's cumbersome. That thread_alive call ends up generating one T packet per thread: Sending packet: $Tp2141.2150#82...Packet received: OK Sending packet: $Tp2141.214f#b7...Packet received: OK Sending packet: $Tp2141.2141#82...Packet received: OK Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n That seems a bit silly when target_find_new_threads method implementations will always fetch the whole current set of target threads, and then add those that are not in GDB's thread list, to GDB's thread list. This patch thus pushes down the responsibility of pruning dead threads to the target_find_new_threads method instead, so a target may implement pruning dead threads however it wants. Once we do that, target_find_new_threads becomes a misnomer, so the patch renames it to target_update_thread_list. The patch doesn't attempt to do any optimization to any target yet. It simply exports prune_threads, and makes all implementations of target_update_thread_list call that. It's meant to be a no-op. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * ada-tasks.c (print_ada_task_info, task_command_1): Adjust. * bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ... (bsd_uthread_update_thread_list): ... this. Call prune_threads. (bsd_uthread_target): Adjust. * corelow.c (core_open): Adjust. * dec-thread.c (dec_thread_find_new_threads): Update comment. (dec_thread_update_thread_list): New function. (init_dec_thread_ops): Adjust. * gdbthread.h (prune_threads): New declaration. * linux-thread-db.c (thread_db_find_new_threads): Rename to ... (thread_db_update_thread_list): ... this. Call prune_threads. (init_thread_db_ops): Adjust. * nto-procfs.c (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. (procfs_attach, procfs_create_inferior, init_procfs_targets): Adjust. * obsd-nat.c (obsd_find_new_threads): Rename to ... (obsd_update_thread_list): ... this. Call prune_threads. (obsd_add_target): Adjust. * procfs.c (procfs_target): Adjust. (procfs_notice_thread): Update comment. (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. * ravenscar-thread.c (ravenscar_update_inferior_ptid): Update comment. (ravenscar_wait): Adjust. (ravenscar_find_new_threads): Rename to ... (ravenscar_update_thread_list): ... this. Call prune_threads. (init_ravenscar_thread_ops): Adjust. * record-btrace.c (record_btrace_find_new_threads): Rename to ... (record_btrace_update_thread_list): ... this. Adjust comment. (init_record_btrace_ops): Adjust. * remote.c (remote_threads_info): Rename to ... (remote_update_thread_list): ... this. Call prune_threads. (remote_start_remote, extended_remote_attach_1, init_remote_ops): Adjust. * sol-thread.c (check_for_thread_db): Adjust. (sol_find_new_threads_callback): Rename to ... (sol_update_thread_list_callback): ... this. (sol_find_new_threads): Rename to ... (sol_update_thread_list): ... this. Call prune_threads. Adjust. (sol_get_ada_task_ptid, init_sol_thread_ops): Adjust. * target-delegates.c: Regenerate. * target.c (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * target.h (struct target_ops): Rename to_find_new_threads field to to_update_thread_list. (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * thread.c (prune_threads): Make extern. (update_thread_list): Adjust.
2014-10-15 23:44:00 +02:00
ops->to_update_thread_list (ops);
}
/* The to_thread_alive method of target record-btrace. */
static int
record_btrace_thread_alive (struct target_ops *ops, ptid_t ptid)
{
/* We don't add or remove threads during replay. */
if (record_btrace_is_replaying (ops))
return find_thread_ptid (ptid) != NULL;
/* Forward the request. */
ops = ops->beneath;
return ops->to_thread_alive (ops, ptid);
}
/* Set the replay branch trace instruction iterator. If IT is NULL, replay
is stopped. */
static void
record_btrace_set_replay (struct thread_info *tp,
const struct btrace_insn_iterator *it)
{
struct btrace_thread_info *btinfo;
btinfo = &tp->btrace;
if (it == NULL || it->function == NULL)
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
record_btrace_stop_replaying (tp);
else
{
if (btinfo->replay == NULL)
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
record_btrace_start_replaying (tp);
else if (btrace_insn_cmp (btinfo->replay, it) == 0)
return;
*btinfo->replay = *it;
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
registers_changed_ptid (tp->ptid);
}
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
/* Start anew from the new replay position. */
record_btrace_clear_histories (btinfo);
}
/* The to_goto_record_begin method of target record-btrace. */
static void
record_btrace_goto_begin (struct target_ops *self)
{
struct thread_info *tp;
struct btrace_insn_iterator begin;
tp = require_btrace_thread ();
btrace_insn_begin (&begin, &tp->btrace);
record_btrace_set_replay (tp, &begin);
print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
/* The to_goto_record_end method of target record-btrace. */
static void
record_btrace_goto_end (struct target_ops *ops)
{
struct thread_info *tp;
tp = require_btrace_thread ();
record_btrace_set_replay (tp, NULL);
print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
/* The to_goto_record method of target record-btrace. */
static void
record_btrace_goto (struct target_ops *self, ULONGEST insn)
{
struct thread_info *tp;
struct btrace_insn_iterator it;
unsigned int number;
int found;
number = insn;
/* Check for wrap-arounds. */
if (number != insn)
error (_("Instruction number out of range."));
tp = require_btrace_thread ();
found = btrace_find_insn_by_number (&it, &tp->btrace, number);
if (found == 0)
error (_("No such instruction."));
record_btrace_set_replay (tp, &it);
print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
/* The to_execution_direction target method. */
static enum exec_direction_kind
record_btrace_execution_direction (struct target_ops *self)
{
return record_btrace_resume_exec_dir;
}
/* The to_prepare_to_generate_core target method. */
static void
record_btrace_prepare_to_generate_core (struct target_ops *self)
{
record_btrace_generating_corefile = 1;
}
/* The to_done_generating_core target method. */
static void
record_btrace_done_generating_core (struct target_ops *self)
{
record_btrace_generating_corefile = 0;
}
/* Initialize the record-btrace target ops. */
static void
init_record_btrace_ops (void)
{
struct target_ops *ops;
ops = &record_btrace_ops;
ops->to_shortname = "record-btrace";
ops->to_longname = "Branch tracing target";
ops->to_doc = "Collect control-flow trace and provide the execution history.";
ops->to_open = record_btrace_open;
ops->to_close = record_btrace_close;
When disabling target async, remove all target event sources from the event loop The sigall-reverse.exp test occasionally fails with something like this: (gdb) PASS: gdb.reverse/sigall-reverse.exp: send signal TERM continue Continuing. The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?([y] or n) FAIL: gdb.reverse/sigall-reverse.exp: continue to signal exit (timeout) FAIL: gdb.reverse/sigall-reverse.exp: reverse to handler of TERM (timeout) FAIL: gdb.reverse/sigall-reverse.exp: reverse to gen_TERM (timeout) This is another event-loop/async related problem exposed by the patch that made 'query' use gdb_readline_wrapper (588dcc3edbde19f9). The problem is that even though gdb_readline_wrapper disables target-async while the secondary prompt is in progress, the record target's async event source is left marked. So when gdb_readline_wrapper nests an event loop to process input, it may happen that that event loop ends up processing a target event while GDB is not really ready for it. Here's the relevant part of the backtrace showing the root issue in action: ... #14 0x000000000061cb48 in fetch_inferior_event (client_data=0x0) at src/gdb/infrun.c:4158 #15 0x0000000000642917 in inferior_event_handler (event_type=INF_REG_EVENT, client_data=0x0) at src/gdb/inf-loop.c:57 #16 0x000000000077ca5c in record_full_async_inferior_event_handler (data=0x0) at src/gdb/record-full.c:791 #17 0x0000000000640fdf in invoke_async_event_handler (data=...) at src/gdb/event-loop.c:1067 #18 0x000000000063fb01 in process_event () at src/gdb/event-loop.c:339 #19 0x000000000063fb2a in gdb_do_one_event () at src/gdb/event-loop.c:360 #20 0x000000000074d607 in gdb_readline_wrapper (prompt=0x3588f40 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?([y] or n) ") at src/gdb/top.c:842 #21 0x0000000000750bd9 in defaulted_query (ctlstr=0x8c6588 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?", defchar=121 'y', args=0x7fff70524410) at src/gdb/utils.c:1279 #22 0x0000000000750e4c in yquery (ctlstr=0x8c6588 "The next instruction is syscall exit_group. It will make the program exit. Do you want to stop the program?") at src/gdb/utils.c:1358 #23 0x00000000004b020e in record_linux_system_call (syscall=gdb_sys_exit_group, regcache=0x3529450, tdep=0xd6c840 <amd64_linux_record_tdep>) at src/gdb/linux-record.c:1933 With my all-stop-on-top-of-non-stop series, I'm also seeing gdb.server/ext-attach.exp fail occasionally due to the same issue. The first part of the fix is for target_async implementations to make sure to remove/unmark all target-related event sources from the event loop. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ 2015-02-03 Pedro Alves <palves@redhat.com> * event-loop.c (clear_async_event_handler): New function. * event-loop.h (clear_async_event_handler): New declaration. * record-btrace.c (record_btrace_async): New function. (init_record_btrace_ops): Install record_btrace_async. * record-full.c (record_full_async): New function. (record_full_resume): Don't mark the async event source here. (init_record_full_ops): Install record_full_async. (record_full_core_resume): Don't mark the async event source here. (init_record_full_core_ops): Install record_full_async. * remote.c (remote_async): Mark and clear the async stop reply queue event-loop token as appropriate.
2015-02-03 16:07:54 +01:00
ops->to_async = record_btrace_async;
ops->to_detach = record_detach;
ops->to_disconnect = record_disconnect;
ops->to_mourn_inferior = record_mourn_inferior;
ops->to_kill = record_kill;
ops->to_stop_recording = record_btrace_stop_recording;
ops->to_info_record = record_btrace_info;
ops->to_insn_history = record_btrace_insn_history;
ops->to_insn_history_from = record_btrace_insn_history_from;
ops->to_insn_history_range = record_btrace_insn_history_range;
ops->to_call_history = record_btrace_call_history;
ops->to_call_history_from = record_btrace_call_history_from;
ops->to_call_history_range = record_btrace_call_history_range;
ops->to_record_is_replaying = record_btrace_is_replaying;
ops->to_xfer_partial = record_btrace_xfer_partial;
ops->to_remove_breakpoint = record_btrace_remove_breakpoint;
ops->to_insert_breakpoint = record_btrace_insert_breakpoint;
ops->to_fetch_registers = record_btrace_fetch_registers;
ops->to_store_registers = record_btrace_store_registers;
ops->to_prepare_to_store = record_btrace_prepare_to_store;
ops->to_get_unwinder = &record_btrace_to_get_unwinder;
ops->to_get_tailcall_unwinder = &record_btrace_to_get_tailcall_unwinder;
ops->to_resume = record_btrace_resume;
ops->to_wait = record_btrace_wait;
Push pruning old threads down to the target When GDB wants to sync the thread list with the target's (e.g., due to "info threads"), it calls update_thread_list: update_thread_list (void) { prune_threads (); target_find_new_threads (); update_threads_executing (); } And then prune_threads does: prune_threads (void) { struct thread_info *tp, *next; for (tp = thread_list; tp; tp = next) { next = tp->next; if (!thread_alive (tp)) delete_thread (tp->ptid); } } Calling thread_live on each thread one by one is expensive. E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not a big deal, but still a bunch of syscalls... With the remote target, it's cumbersome. That thread_alive call ends up generating one T packet per thread: Sending packet: $Tp2141.2150#82...Packet received: OK Sending packet: $Tp2141.214f#b7...Packet received: OK Sending packet: $Tp2141.2141#82...Packet received: OK Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n That seems a bit silly when target_find_new_threads method implementations will always fetch the whole current set of target threads, and then add those that are not in GDB's thread list, to GDB's thread list. This patch thus pushes down the responsibility of pruning dead threads to the target_find_new_threads method instead, so a target may implement pruning dead threads however it wants. Once we do that, target_find_new_threads becomes a misnomer, so the patch renames it to target_update_thread_list. The patch doesn't attempt to do any optimization to any target yet. It simply exports prune_threads, and makes all implementations of target_update_thread_list call that. It's meant to be a no-op. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * ada-tasks.c (print_ada_task_info, task_command_1): Adjust. * bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ... (bsd_uthread_update_thread_list): ... this. Call prune_threads. (bsd_uthread_target): Adjust. * corelow.c (core_open): Adjust. * dec-thread.c (dec_thread_find_new_threads): Update comment. (dec_thread_update_thread_list): New function. (init_dec_thread_ops): Adjust. * gdbthread.h (prune_threads): New declaration. * linux-thread-db.c (thread_db_find_new_threads): Rename to ... (thread_db_update_thread_list): ... this. Call prune_threads. (init_thread_db_ops): Adjust. * nto-procfs.c (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. (procfs_attach, procfs_create_inferior, init_procfs_targets): Adjust. * obsd-nat.c (obsd_find_new_threads): Rename to ... (obsd_update_thread_list): ... this. Call prune_threads. (obsd_add_target): Adjust. * procfs.c (procfs_target): Adjust. (procfs_notice_thread): Update comment. (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. * ravenscar-thread.c (ravenscar_update_inferior_ptid): Update comment. (ravenscar_wait): Adjust. (ravenscar_find_new_threads): Rename to ... (ravenscar_update_thread_list): ... this. Call prune_threads. (init_ravenscar_thread_ops): Adjust. * record-btrace.c (record_btrace_find_new_threads): Rename to ... (record_btrace_update_thread_list): ... this. Adjust comment. (init_record_btrace_ops): Adjust. * remote.c (remote_threads_info): Rename to ... (remote_update_thread_list): ... this. Call prune_threads. (remote_start_remote, extended_remote_attach_1, init_remote_ops): Adjust. * sol-thread.c (check_for_thread_db): Adjust. (sol_find_new_threads_callback): Rename to ... (sol_update_thread_list_callback): ... this. (sol_find_new_threads): Rename to ... (sol_update_thread_list): ... this. Call prune_threads. Adjust. (sol_get_ada_task_ptid, init_sol_thread_ops): Adjust. * target-delegates.c: Regenerate. * target.c (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * target.h (struct target_ops): Rename to_find_new_threads field to to_update_thread_list. (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * thread.c (prune_threads): Make extern. (update_thread_list): Adjust.
2014-10-15 23:44:00 +02:00
ops->to_update_thread_list = record_btrace_update_thread_list;
ops->to_thread_alive = record_btrace_thread_alive;
ops->to_goto_record_begin = record_btrace_goto_begin;
ops->to_goto_record_end = record_btrace_goto_end;
ops->to_goto_record = record_btrace_goto;
record-btrace: add (reverse-)stepping support Provide to_resume and to_wait target methods for the btrace record target to allow reverse stepping and replay support. Replay is limited in the sense that only stepping and source correlation are supported. We do not record data and thus can not show variables. Non-stop mode is not working. Do not allow record-btrace in non-stop mode. 2014-01-16 Markus Metzger <markus.t.metzger@intel.com> * btrace.h (btrace_thread_flag): New. (struct btrace_thread_info) <flags>: New. * record-btrace.c (record_btrace_resume_thread) (record_btrace_find_thread_to_move, btrace_step_no_history) (btrace_step_stopped, record_btrace_start_replaying) (record_btrace_step_thread, record_btrace_decr_pc_after_break) (record_btrace_find_resume_thread): New. (record_btrace_resume, record_btrace_wait): Extend. (record_btrace_can_execute_reverse): New. (record_btrace_open): Fail in non-stop mode. (record_btrace_set_replay): Split into this, ... (record_btrace_stop_replaying): ... this, ... (record_btrace_clear_histories): ... and this. (init_record_btrace_ops): Init to_can_execute_reverse. * NEWS: Announce it. testsuite/ * gdb.btrace/delta.exp: Check reverse stepi. * gdb.btrace/tailcall.exp: Update. Add stepping tests. * gdb.btrace/finish.exp: New. * gdb.btrace/next.exp: New. * gdb.btrace/nexti.exp: New. * gdb.btrace/record_goto.c: Add comments. * gdb.btrace/step.exp: New. * gdb.btrace/stepi.exp: New. * gdb.btrace/multi-thread-step.c: New. * gdb.btrace/multi-thread-step.exp: New. * gdb.btrace/rn-dl-bind.c: New. * gdb.btrace/rn-dl-bind.exp: New. * gdb.btrace/data.c: New. * gdb.btrace/data.exp: New. * gdb.btrace/Makefile.in (EXECUTABLES): Add new. doc/ * gdb.texinfo: Document limited reverse/replay support for target record-btrace.
2013-05-06 16:04:46 +02:00
ops->to_can_execute_reverse = record_btrace_can_execute_reverse;
ops->to_decr_pc_after_break = record_btrace_decr_pc_after_break;
ops->to_execution_direction = record_btrace_execution_direction;
ops->to_prepare_to_generate_core = record_btrace_prepare_to_generate_core;
ops->to_done_generating_core = record_btrace_done_generating_core;
ops->to_stratum = record_stratum;
ops->to_magic = OPS_MAGIC;
}
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
/* Start recording in BTS format. */
static void
cmd_record_btrace_bts_start (char *args, int from_tty)
{
volatile struct gdb_exception exception;
if (args != NULL && *args != 0)
error (_("Invalid argument."));
record_btrace_conf.format = BTRACE_FORMAT_BTS;
TRY_CATCH (exception, RETURN_MASK_ALL)
execute_command ("target record-btrace", from_tty);
if (exception.error != 0)
{
record_btrace_conf.format = BTRACE_FORMAT_NONE;
throw_exception (exception);
}
}
/* Alias for "target record". */
static void
cmd_record_btrace_start (char *args, int from_tty)
{
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
volatile struct gdb_exception exception;
if (args != NULL && *args != 0)
error (_("Invalid argument."));
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
record_btrace_conf.format = BTRACE_FORMAT_BTS;
TRY_CATCH (exception, RETURN_MASK_ALL)
execute_command ("target record-btrace", from_tty);
if (exception.error == 0)
return;
record_btrace_conf.format = BTRACE_FORMAT_NONE;
throw_exception (exception);
}
/* The "set record btrace" command. */
static void
cmd_set_record_btrace (char *args, int from_tty)
{
cmd_show_list (set_record_btrace_cmdlist, from_tty, "");
}
/* The "show record btrace" command. */
static void
cmd_show_record_btrace (char *args, int from_tty)
{
cmd_show_list (show_record_btrace_cmdlist, from_tty, "");
}
/* The "show record btrace replay-memory-access" command. */
static void
cmd_show_replay_memory_access (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
fprintf_filtered (gdb_stdout, _("Replay memory access is %s.\n"),
replay_memory_access);
}
record-btrace: add bts buffer size configuration option Allow the size of the branch trace ring buffer to be defined by the user. The specified buffer size will be used when BTS tracing is enabled for new threads. The obtained buffer size may differ from the requested size. The actual buffer size for the current thread is shown in the "info record" command. Bigger buffers mean longer traces, but also longer processing time. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (parse_xml_btrace_conf_bts): Add size. (btrace_conf_bts_attributes): New. (btrace_conf_children): Add attributes. * common/btrace-common.h (btrace_config_bts): New. (btrace_config)<bts>: New. (btrace_config): Update comment. * nat/linux-btrace.c (linux_enable_btrace, linux_enable_bts): Use config. * features/btrace-conf.dtd: Increment version. Add size attribute to bts element. * record-btrace.c (set_record_btrace_bts_cmdlist, show_record_btrace_bts_cmdlist): New. (record_btrace_adjust_size, record_btrace_print_bts_conf, record_btrace_print_conf, cmd_set_record_btrace_bts, cmd_show_record_btrace_bts): New. (record_btrace_info): Call record_btrace_print_conf. (_initialize_record_btrace): Add commands. * remote.c: Add PACKET_Qbtrace_conf_bts_size enum. (remote_protocol_features): Add Qbtrace-conf:bts:size packet. (btrace_sync_conf): Synchronize bts size. (_initialize_remote): Add Qbtrace-conf:bts:size packet. * NEWS: Announce new commands and new packets. doc/ * gdb.texinfo (Branch Trace Configuration Format): Add size. (Process Record and Replay): Describe new set|show commands. (General Query Packets): Describe Qbtrace-conf:bts:size packet. testsuite/ * gdb.btrace/buffer-size: New. gdbserver/ * linux-low.c (linux_low_btrace_conf): Print size. * server.c (handle_btrace_conf_general_set): New. (hanle_general_set): Call handle_btrace_conf_general_set. (handle_query): Report Qbtrace-conf:bts:size as supported.
2013-11-28 16:39:12 +01:00
/* The "set record btrace bts" command. */
static void
cmd_set_record_btrace_bts (char *args, int from_tty)
{
printf_unfiltered (_("\"set record btrace bts\" must be followed "
"by an apporpriate subcommand.\n"));
help_list (set_record_btrace_bts_cmdlist, "set record btrace bts ",
all_commands, gdb_stdout);
}
/* The "show record btrace bts" command. */
static void
cmd_show_record_btrace_bts (char *args, int from_tty)
{
cmd_show_list (show_record_btrace_bts_cmdlist, from_tty, "");
}
void _initialize_record_btrace (void);
/* Initialize btrace commands. */
void
_initialize_record_btrace (void)
{
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
add_prefix_cmd ("btrace", class_obscure, cmd_record_btrace_start,
_("Start branch trace recording."), &record_btrace_cmdlist,
"record btrace ", 0, &record_cmdlist);
add_alias_cmd ("b", "btrace", class_obscure, 1, &record_cmdlist);
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
add_cmd ("bts", class_obscure, cmd_record_btrace_bts_start,
_("\
Start branch trace recording in Branch Trace Store (BTS) format.\n\n\
The processor stores a from/to record for each branch into a cyclic buffer.\n\
This format may not be available on all processors."),
&record_btrace_cmdlist);
add_alias_cmd ("bts", "btrace bts", class_obscure, 1, &record_cmdlist);
add_prefix_cmd ("btrace", class_support, cmd_set_record_btrace,
_("Set record options"), &set_record_btrace_cmdlist,
"set record btrace ", 0, &set_record_cmdlist);
add_prefix_cmd ("btrace", class_support, cmd_show_record_btrace,
_("Show record options"), &show_record_btrace_cmdlist,
"show record btrace ", 0, &show_record_cmdlist);
add_setshow_enum_cmd ("replay-memory-access", no_class,
replay_memory_access_types, &replay_memory_access, _("\
Set what memory accesses are allowed during replay."), _("\
Show what memory accesses are allowed during replay."),
_("Default is READ-ONLY.\n\n\
The btrace record target does not trace data.\n\
The memory therefore corresponds to the live target and not \
to the current replay position.\n\n\
When READ-ONLY, allow accesses to read-only memory during replay.\n\
When READ-WRITE, allow accesses to read-only and read-write memory during \
replay."),
NULL, cmd_show_replay_memory_access,
&set_record_btrace_cmdlist,
&show_record_btrace_cmdlist);
record-btrace: add bts buffer size configuration option Allow the size of the branch trace ring buffer to be defined by the user. The specified buffer size will be used when BTS tracing is enabled for new threads. The obtained buffer size may differ from the requested size. The actual buffer size for the current thread is shown in the "info record" command. Bigger buffers mean longer traces, but also longer processing time. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (parse_xml_btrace_conf_bts): Add size. (btrace_conf_bts_attributes): New. (btrace_conf_children): Add attributes. * common/btrace-common.h (btrace_config_bts): New. (btrace_config)<bts>: New. (btrace_config): Update comment. * nat/linux-btrace.c (linux_enable_btrace, linux_enable_bts): Use config. * features/btrace-conf.dtd: Increment version. Add size attribute to bts element. * record-btrace.c (set_record_btrace_bts_cmdlist, show_record_btrace_bts_cmdlist): New. (record_btrace_adjust_size, record_btrace_print_bts_conf, record_btrace_print_conf, cmd_set_record_btrace_bts, cmd_show_record_btrace_bts): New. (record_btrace_info): Call record_btrace_print_conf. (_initialize_record_btrace): Add commands. * remote.c: Add PACKET_Qbtrace_conf_bts_size enum. (remote_protocol_features): Add Qbtrace-conf:bts:size packet. (btrace_sync_conf): Synchronize bts size. (_initialize_remote): Add Qbtrace-conf:bts:size packet. * NEWS: Announce new commands and new packets. doc/ * gdb.texinfo (Branch Trace Configuration Format): Add size. (Process Record and Replay): Describe new set|show commands. (General Query Packets): Describe Qbtrace-conf:bts:size packet. testsuite/ * gdb.btrace/buffer-size: New. gdbserver/ * linux-low.c (linux_low_btrace_conf): Print size. * server.c (handle_btrace_conf_general_set): New. (hanle_general_set): Call handle_btrace_conf_general_set. (handle_query): Report Qbtrace-conf:bts:size as supported.
2013-11-28 16:39:12 +01:00
add_prefix_cmd ("bts", class_support, cmd_set_record_btrace_bts,
_("Set record btrace bts options"),
&set_record_btrace_bts_cmdlist,
"set record btrace bts ", 0, &set_record_btrace_cmdlist);
add_prefix_cmd ("bts", class_support, cmd_show_record_btrace_bts,
_("Show record btrace bts options"),
&show_record_btrace_bts_cmdlist,
"show record btrace bts ", 0, &show_record_btrace_cmdlist);
add_setshow_uinteger_cmd ("buffer-size", no_class,
&record_btrace_conf.bts.size,
_("Set the record/replay bts buffer size."),
_("Show the record/replay bts buffer size."), _("\
When starting recording request a trace buffer of this size. \
The actual buffer size may differ from the requested size. \
Use \"info record\" to see the actual buffer size.\n\n\
Bigger buffers allow longer recording but also take more time to process \
the recorded execution trace.\n\n\
The trace buffer size may not be changed while recording."), NULL, NULL,
&set_record_btrace_bts_cmdlist,
&show_record_btrace_bts_cmdlist);
init_record_btrace_ops ();
add_target (&record_btrace_ops);
bfcache = htab_create_alloc (50, bfcache_hash, bfcache_eq, NULL,
xcalloc, xfree);
record-btrace: add bts buffer size configuration option Allow the size of the branch trace ring buffer to be defined by the user. The specified buffer size will be used when BTS tracing is enabled for new threads. The obtained buffer size may differ from the requested size. The actual buffer size for the current thread is shown in the "info record" command. Bigger buffers mean longer traces, but also longer processing time. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * btrace.c (parse_xml_btrace_conf_bts): Add size. (btrace_conf_bts_attributes): New. (btrace_conf_children): Add attributes. * common/btrace-common.h (btrace_config_bts): New. (btrace_config)<bts>: New. (btrace_config): Update comment. * nat/linux-btrace.c (linux_enable_btrace, linux_enable_bts): Use config. * features/btrace-conf.dtd: Increment version. Add size attribute to bts element. * record-btrace.c (set_record_btrace_bts_cmdlist, show_record_btrace_bts_cmdlist): New. (record_btrace_adjust_size, record_btrace_print_bts_conf, record_btrace_print_conf, cmd_set_record_btrace_bts, cmd_show_record_btrace_bts): New. (record_btrace_info): Call record_btrace_print_conf. (_initialize_record_btrace): Add commands. * remote.c: Add PACKET_Qbtrace_conf_bts_size enum. (remote_protocol_features): Add Qbtrace-conf:bts:size packet. (btrace_sync_conf): Synchronize bts size. (_initialize_remote): Add Qbtrace-conf:bts:size packet. * NEWS: Announce new commands and new packets. doc/ * gdb.texinfo (Branch Trace Configuration Format): Add size. (Process Record and Replay): Describe new set|show commands. (General Query Packets): Describe Qbtrace-conf:bts:size packet. testsuite/ * gdb.btrace/buffer-size: New. gdbserver/ * linux-low.c (linux_low_btrace_conf): Print size. * server.c (handle_btrace_conf_general_set): New. (hanle_general_set): Call handle_btrace_conf_general_set. (handle_query): Report Qbtrace-conf:bts:size as supported.
2013-11-28 16:39:12 +01:00
record_btrace_conf.bts.size = 64 * 1024;
}