From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22855 invoked by alias); 16 Jul 2013 20:31:01 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 22836 invoked by uid 306); 16 Jul 2013 20:31:01 -0000 Date: Tue, 16 Jul 2013 20:31:00 -0000 Message-ID: <20130716203101.22775.qmail@sourceware.org> From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] tromey/multi-target: undo note X-Git-Refname: refs/heads/tromey/multi-target X-Git-Reftype: branch X-Git-Oldrev: 63b62e8381b01bbaf9ea4e7577047971beacf5e9 X-Git-Newrev: ba32ac0f6fe938d87ea695a47f622eca129bc5f3 X-SW-Source: 2013-q3/txt/msg00006.txt.bz2 List-Id: The branch, tromey/multi-target has been updated via ba32ac0f6fe938d87ea695a47f622eca129bc5f3 (commit) via c4a816ba2bb097f02124f6b7fa03ac7acde20f4a (commit) via 1537dc6fe96baa31dca8f38b894f24f5493432fb (commit) via de4c5b59388014c29c0b5291d74b773e5308ca96 (commit) via ece3c8ffcccdf4fe4adc782f3204bc8297d6a6d9 (commit) via 8a62b3a5fd17b6cb68e3f4219336920e2c93b532 (commit) via c58f7a54962cb1d371163ab1b198a64b12c60c08 (commit) via f0cf991ec3cd9a0914af633f58ac09cea43058fb (commit) via 91f4eda7ca434d30edfbd4e1c5cbe395d751c24c (commit) via 053cbbe91e43a5015e6a80dab50ac925c95cd9f9 (commit) via cb4e363c5e3e02935c4cb31f594678d5c60936a0 (commit) via 7b13bcaa0071953798b5fc2eeed189fd7a13ba91 (commit) via 5965ceec7aab6ad0c8262343a43d88ab50427fdf (commit) via 05a1b05032c04275d263a82662fa4579aa208ed8 (commit) via 97e22a7ea4d0c9509d6afcd673db1ca5e6be4cf7 (commit) via 6dc383ca929454752eb751778c8143fd3b0c7e96 (commit) via 5dca2a23fb5b72707803939fd10bbdbfe261ce59 (commit) via dc598ace37fbb3477cebed38d896e9386bca3915 (commit) via 5941ca50151da61982d9b3fbbee9397b74af75a9 (commit) via 5c28a694e217e7798dcf0d78d47a9c5e4b414818 (commit) via fbdcfa2511967ce2a991f8dc24aabcda833e8ad2 (commit) via 82693740405965fa0c8086b5745e78c2db553eb3 (commit) via ae85609972d177b14dd0146ff9a1d43f0d699e2b (commit) via 5c09901732c4cb2273b878c59e20d54f947ef5ba (commit) via 822a00aafb658589dcdc7edaab36e32a008f01d5 (commit) via cc2ae6276e0131943ed4575c34470902f3d5a581 (commit) via c51b9eb3bc5e92f1805c4a7ee7f7b6eb03c19b49 (commit) via 29df2c0dbbedb6544054eabd523813275e66cfb1 (commit) via 70b4877085d97ae5fc0307c313facbfc14d1b90e (commit) from 63b62e8381b01bbaf9ea4e7577047971beacf5e9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit ba32ac0f6fe938d87ea695a47f622eca129bc5f3 Author: Tom Tromey Date: Sat Jul 13 16:44:05 2013 -0600 undo note commit c4a816ba2bb097f02124f6b7fa03ac7acde20f4a Author: Tom Tromey Date: Sat Jul 13 16:41:09 2013 -0600 notes update commit 1537dc6fe96baa31dca8f38b894f24f5493432fb Author: Tom Tromey Date: Sat Jul 13 15:03:58 2013 -0600 note update commit de4c5b59388014c29c0b5291d74b773e5308ca96 Author: Tom Tromey Date: Sat Jul 13 15:01:56 2013 -0600 make "info inferior" show the target in multi-target mode not totally complete -> should show core file name -> maybe others? commit ece3c8ffcccdf4fe4adc782f3204bc8297d6a6d9 Author: Tom Tromey Date: Sat Jul 13 15:01:07 2013 -0600 even more notes updates commit 8a62b3a5fd17b6cb68e3f4219336920e2c93b532 Author: Tom Tromey Date: Sat Jul 13 13:27:16 2013 -0600 more notes commit c58f7a54962cb1d371163ab1b198a64b12c60c08 Author: Tom Tromey Date: Sat Jul 13 13:27:05 2013 -0600 make "maint print target-stack" show all target stacks commit f0cf991ec3cd9a0914af633f58ac09cea43058fb Author: Tom Tromey Date: Sat Jul 13 13:13:15 2013 -0600 update notes commit 91f4eda7ca434d30edfbd4e1c5cbe395d751c24c Author: Tom Tromey Date: Sat Jul 13 13:03:20 2013 -0600 fix exec_close change exec_close so it doesn't close inferiors from other targets commit 053cbbe91e43a5015e6a80dab50ac925c95cd9f9 Author: Tom Tromey Date: Sat Jul 13 12:27:14 2013 -0600 add checking to multi-target mode when creating new target stacks we must ensure that the existing targets are multi-target-compatible; and when pushing a target in multi-target mode we must do likewise for the new target being pushed commit cb4e363c5e3e02935c4cb31f594678d5c60936a0 Author: Tom Tromey Date: Sat Jul 13 12:23:35 2013 -0600 fix potential memory leak in push_target commit 7b13bcaa0071953798b5fc2eeed189fd7a13ba91 Author: Tom Tromey Date: Sat Jul 13 12:00:57 2013 -0600 fix comment in record-full.c; part of xclose change commit 5965ceec7aab6ad0c8262343a43d88ab50427fdf Author: Tom Tromey Date: Sat Jul 13 11:28:32 2013 -0600 make record-btrace.c use to_xclose commit 05a1b05032c04275d263a82662fa4579aa208ed8 Author: Tom Tromey Date: Sat Jul 13 11:26:20 2013 -0600 make linux-thread-db.c use to_xclose commit 97e22a7ea4d0c9509d6afcd673db1ca5e6be4cf7 Author: Tom Tromey Date: Sat Jul 13 11:24:22 2013 -0600 give target exec a to_xclose method to_xclose is going to be the sentinel for multi-target commit 6dc383ca929454752eb751778c8143fd3b0c7e96 Author: Tom Tromey Date: Sat Jul 13 11:23:16 2013 -0600 add another note commit 5dca2a23fb5b72707803939fd10bbdbfe261ce59 Author: Tom Tromey Date: Sat Jul 13 11:19:57 2013 -0600 minor exec.c cleanups commit dc598ace37fbb3477cebed38d896e9386bca3915 Author: Tom Tromey Date: Sat Jul 13 11:19:14 2013 -0600 remove using_exec_ops global commit 5941ca50151da61982d9b3fbbee9397b74af75a9 Author: Tom Tromey Date: Sat Jul 13 11:01:00 2013 -0600 note update commit 5c28a694e217e7798dcf0d78d47a9c5e4b414818 Author: Tom Tromey Date: Sat Jul 13 11:00:55 2013 -0600 make find_record_target use find_target_at commit fbdcfa2511967ce2a991f8dc24aabcda833e8ad2 Author: Tom Tromey Date: Fri Jul 12 15:59:00 2013 -0600 note update commit 82693740405965fa0c8086b5745e78c2db553eb3 Author: Tom Tromey Date: Fri Jul 12 15:58:52 2013 -0600 use RECORD_IS_USED in record_full_open commit ae85609972d177b14dd0146ff9a1d43f0d699e2b Author: Tom Tromey Date: Fri Jul 12 15:56:11 2013 -0600 fix RECORD_IS_USED commit 5c09901732c4cb2273b878c59e20d54f947ef5ba Author: Tom Tromey Date: Fri Jul 12 15:52:13 2013 -0600 change record-full to be a to_xclose target commit 822a00aafb658589dcdc7edaab36e32a008f01d5 Author: Tom Tromey Date: Fri Jul 12 14:59:21 2013 -0600 update note commit cc2ae6276e0131943ed4575c34470902f3d5a581 Author: Tom Tromey Date: Fri Jul 12 13:12:05 2013 -0600 update note commit c51b9eb3bc5e92f1805c4a7ee7f7b6eb03c19b49 Author: Tom Tromey Date: Fri Jul 12 13:04:32 2013 -0600 update note commit 29df2c0dbbedb6544054eabd523813275e66cfb1 Author: Tom Tromey Date: Fri Jul 12 13:00:34 2013 -0600 replace record pointers with target delegation commit 70b4877085d97ae5fc0307c313facbfc14d1b90e Author: Tom Tromey Date: Thu Jul 11 19:27:59 2013 -0600 notes update ----------------------------------------------------------------------- Summary of changes: README.archer | 108 +++++- gdb/exec.c | 63 ++-- gdb/inferior.c | 16 +- gdb/linux-thread-db.c | 10 + gdb/record-btrace.c | 6 +- gdb/record-full.c | 939 +++++++++++++++++++++++------------------------- gdb/record.c | 10 +- gdb/record.h | 2 +- gdb/remote.c | 16 + gdb/target.c | 301 ++++++++++++++-- gdb/target.h | 55 +++ 11 files changed, 942 insertions(+), 584 deletions(-) First 500 lines of diff: diff --git a/README.archer b/README.archer index 62eabbc..d238400 100644 --- a/README.archer +++ b/README.archer @@ -13,12 +13,6 @@ TO DO: we need some kind of to_instantiate so that find_default_run_target can work properly -"set target-async 1" should examine all existing target stacks -this doesn't quite make sense -we should check instead at new-target time that either there is -no current target stack, or that we're async -but really all this mess should go away & we should be always async - fix up target-descriptions.[ch] stuff - must require target-async to connect to multiple @@ -27,9 +21,6 @@ fix up target-descriptions.[ch] stuff this may just prevent sim? -fix up find_record_target to use find_target_at - - targets to fix: ctf @@ -41,14 +32,31 @@ targets to fix: many others available, but not sure which are important also testing is an issue + +seems like to_record_is_replaying could be fixed to be new-style + + +to_xclose stuff is wrong right now +seems like it should not free the object itself +anyway some do not free right now + + +DONE: + ALL_PSPACES -vs- targets + e.g., exec_close + +fix up remove_target_sections ?? +how will this interact with the BFD-sharing code? + +how does breakpoint insertion work? + + If user makes a new target then tries run, make sure gdb chooses the currently-existing native target instead of trying to open a new one. target to_name stuff should be const but needs add_cmd -by default a target should not be reusable -how can we automate this? I guess you're assuming async, right? need to handle same pid in different targets meaning different @@ -73,3 +81,81 @@ how can we automate this? It might seem like we could remove to_xclose, but that takes a gdb_target, where to_close does not. So we'd have to fix all to_close targets + +================================================================ + +notes for tfile change + +- we already have struct trace_status + can we push all the data in there? + + there are some things that did not go in that struct, don't know + why: + + -static char *trace_filename; +-static int trace_fd = -1; +-static off_t trace_frames_offset; +-static off_t cur_offset; +-static int cur_data_size; + +is trace_filename redundant with trace_status? + + +also trace_regblock_size is a huge hack + + +misplaced comment: + ++/* Fill in tfile_ops with its defined operations and properties. */ ++ + static void + init_tfile_ops (void) + { + + +these static variables: + + static void +trace_find_line_command (char *args, int from_tty) +{ + static CORE_ADDR start_pc, end_pc; + + +static void +trace_find_range_command (char *args, int from_tty) +{ + static CORE_ADDR start, stop; + + +should TSV numbers be per-target? + + + +these globals: + +static VEC(tsv_s) *tvariables; + +/* The next integer to assign to a variable. */ + +static int next_tsv_number = 1; + +/* Number of last traceframe collected. */ +static int traceframe_number; + +/* Tracepoint for last traceframe collected. */ +static int tracepoint_number; + +/* Symbol for function for last traceframe collected. */ +static struct symbol *traceframe_fun; + +/* Symtab and line for last traceframe collected. */ +static struct symtab_and_line traceframe_sal; + +/* The traceframe info of the current traceframe. NULL if we haven't + yet attempted to fetch it, or if the target does not support + fetching this object, or if we're not inspecting a traceframe + presently. */ +static struct traceframe_info *traceframe_info; + + + diff --git a/gdb/exec.c b/gdb/exec.c index 5fee3e7..76b77c2 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -62,9 +62,6 @@ void _initialize_exec (void); struct target_ops exec_ops; -/* True if the exec target is pushed on the stack. */ -static int using_exec_ops; - /* Whether to open exec and core files read-only or read-write. */ int write_files = 0; @@ -105,33 +102,36 @@ exec_close (void) } } -/* This is the target_close implementation. Clears all target +/* This is the to_xclose implementation. Clears all target sections and closes all executable bfds from all program spaces. */ static void -exec_close_1 (void) +exec_close_1 (struct gdb_target *target) { - using_exec_ops = 0; + struct program_space *ss; + struct cleanup *old_chain; + struct target_stack *tstack = target_stack_incref (); + old_chain = save_current_program_space (); + make_cleanup (target_stack_decref_cleanup, tstack); + ALL_PSPACES (ss) { - struct program_space *ss; - struct cleanup *old_chain; + /* Skip program spaces that are associated with some other + target. */ + if (ss->target_stack != tstack) + continue; - old_chain = save_current_program_space (); - ALL_PSPACES (ss) - { - set_current_program_space (ss); + set_current_program_space (ss); - /* Delete all target sections. */ - resize_section_table - (current_target_sections, - -resize_section_table (current_target_sections, 0)); + /* Delete all target sections. */ + resize_section_table + (current_target_sections, + -resize_section_table (current_target_sections, 0)); - exec_close (); - } - - do_cleanups (old_chain); + exec_close (); } + + do_cleanups (old_chain); } void @@ -418,11 +418,8 @@ add_target_sections (void *key, /* If these are the first file sections we can provide memory from, push the file_stratum target. */ - if (!using_exec_ops) - { - using_exec_ops = 1; - push_target (&exec_ops); - } + if (!target_is_pushed (&exec_ops)) + push_target (&exec_ops); } } @@ -750,13 +747,17 @@ exec_has_memory (struct gdb_target *ops) /* Find mapped memory. */ -extern void +void exec_set_find_memory_regions (int (*func) (find_memory_region_ftype, void *)) { exec_ops.to_find_memory_regions = func; } -static char *exec_make_note_section (bfd *, int *); +static char * +exec_make_note_section (bfd *obfd, int *note_size) +{ + error (_("Can't create a corefile")); +} /* Fill in the exec file target vector. Very few entries need to be defined. */ @@ -769,7 +770,7 @@ init_exec_ops (void) exec_ops.to_doc = "Use an executable file as a target.\n\ Specify the filename of the executable file."; exec_ops.to_open = exec_open; - exec_ops.to_close = exec_close_1; + exec_ops.to_xclose = exec_close_1; exec_ops.to_attach = find_default_attach; exec_ops.to_xfer_partial = exec_xfer_partial; exec_ops.to_get_section_table = exec_get_section_table; @@ -825,9 +826,3 @@ Show writing into executable and core files."), NULL, add_target_with_completer (&exec_ops, filename_completer); } - -static char * -exec_make_note_section (bfd *obfd, int *note_size) -{ - error (_("Can't create a corefile")); -} diff --git a/gdb/inferior.c b/gdb/inferior.c index b06ea0d..29b09bf 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -608,6 +608,16 @@ print_inferior (struct ui_out *uiout, char *requested_inferiors) ui_out_field_int (uiout, "vfork-child", inf->vfork_child->num); } + if (currently_multi_target ()) + { + char *name = target_full_name (inf->pspace->target_stack); + + ui_out_text (uiout, _("\n\ton target ")); + ui_out_field_string (uiout, "target-name", name); + + xfree (name); + } + ui_out_text (uiout, "\n"); do_cleanups (chain2); } @@ -820,12 +830,6 @@ add_inferior_with_spaces (void) return inf; } -static void -target_stack_decref_cleanup (void *arg) -{ - target_stack_decref (arg); -} - /* add-inferior [-new-target] [-copies N] [-exec FILENAME] */ static void diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 17187f9..4eadbaa 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -2039,12 +2039,22 @@ info_auto_load_libthread_db (char *args, int from_tty) ui_out_message (uiout, 0, _("No auto-loaded libthread-db.\n")); } +/* The to_xclose method for the thread_db target. */ + +static void +thread_db_xclose (struct gdb_target *targ) +{ + /* We don't need to do anything here, but we need the method to + exist as it advertises multi-target capability. */ +} + static void init_thread_db_ops (void) { thread_db_ops.to_shortname = "multi-thread"; thread_db_ops.to_longname = "multi-threaded child process."; thread_db_ops.to_doc = "Threads and pthreads support."; + thread_db_ops.to_xclose = thread_db_xclose; thread_db_ops.to_detach = thread_db_detach; thread_db_ops.to_wait = thread_db_wait; thread_db_ops.to_resume = thread_db_resume; diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 8fb413e..5e3c9aa 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -187,10 +187,10 @@ record_btrace_stop_recording (void) btrace_disable (tp); } -/* The to_close method of target record-btrace. */ +/* The to_xclose method of target record-btrace. */ static void -record_btrace_close (void) +record_btrace_xclose (struct gdb_target *targ) { /* Make sure automatic recording gets disabled even if we did not stop recording before closing the record-btrace target. */ @@ -650,7 +650,7 @@ init_record_btrace_ops (void) 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; + ops->to_xclose = record_btrace_xclose; ops->to_detach = record_detach; ops->to_disconnect = record_disconnect; ops->to_mourn_inferior = record_mourn_inferior; diff --git a/gdb/record-full.c b/gdb/record-full.c index ffd4d81..a4ab0f2 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -60,8 +60,8 @@ #define DEFAULT_RECORD_FULL_INSN_MAX_NUM 200000 -#define RECORD_FULL_IS_REPLAY \ - (record_full_list->next || execution_direction == EXEC_REVERSE) +#define RECORD_FULL_IS_REPLAY(OPS) \ + ((OPS)->record_full_list->next || execution_direction == EXEC_REVERSE) #define RECORD_FULL_FILE_MAGIC netorder32(0x20091016) @@ -165,44 +165,89 @@ struct record_full_core_buf_entry bfd_byte *buf; }; -/* Record buf with core target. */ -static gdb_byte *record_full_core_regbuf = NULL; -static struct target_section *record_full_core_start; -static struct target_section *record_full_core_end; -static struct record_full_core_buf_entry *record_full_core_buf_list = NULL; +/* A subclass of gdb_target that holds state for the record-full + target. */ -/* The following variables are used for managing the linked list that - represents the execution log. +struct record_full_gdb_target +{ + /* The base class. */ - record_full_first is the anchor that holds down the beginning of - the list. + struct gdb_target base; - record_full_list serves two functions: - 1) In record mode, it anchors the end of the list. - 2) In replay mode, it traverses the list and points to - the next instruction that must be emulated. + /* Record buf with core target. */ + gdb_byte *record_full_core_regbuf; + struct target_section *record_full_core_start; + struct target_section *record_full_core_end; + struct record_full_core_buf_entry *record_full_core_buf_list; - record_full_arch_list_head and record_full_arch_list_tail are used - to manage a separate list, which is used to build up the change - elements of the currently executing instruction during record mode. - When this instruction has been completely annotated in the "arch - list", it will be appended to the main execution log. */ + /* The following variables are used for managing the linked list that + represents the execution log. -static struct record_full_entry record_full_first; -static struct record_full_entry *record_full_list = &record_full_first; -static struct record_full_entry *record_full_arch_list_head = NULL; -static struct record_full_entry *record_full_arch_list_tail = NULL; + record_full_first is the anchor that holds down the beginning of + the list. + + record_full_list serves two functions: + 1) In record mode, it anchors the end of the list. + 2) In replay mode, it traverses the list and points to + the next instruction that must be emulated. + + record_full_arch_list_head and record_full_arch_list_tail are used + to manage a separate list, which is used to build up the change + elements of the currently executing instruction during record mode. + When this instruction has been completely annotated in the "arch + list", it will be appended to the main execution log. */ + + struct record_full_entry record_full_first; + struct record_full_entry *record_full_list; + struct record_full_entry *record_full_arch_list_head; + struct record_full_entry *record_full_arch_list_tail; + + /* Actual count of insns presently in execution log. */ + unsigned int record_full_insn_num; + + /* Count of insns logged so far (may be larger + than count of insns presently in execution log). */ + ULONGEST record_full_insn_count; + + /* Asynchronous signal handle registered as event loop source for when + we have pending events ready to be passed to the core. */ + + struct async_event_handler *record_full_async_inferior_event_token; + + int record_full_resume_step; + + /* True if we've been resumed, and so each record_full_wait call should + advance execution. If this is false, record_full_wait will return a + TARGET_WAITKIND_IGNORE. */ + int record_full_resumed; + + /* The execution direction of the last resume we got. This is + necessary for async mode. Vis (order is not strictly accurate): + + 1. user has the global execution direction set to forward + 2. user does a reverse-step command + 3. record_full_resume is called with global execution direction + temporarily switched to reverse + 4. GDB's execution direction is reverted back to forward + 5. target record notifies event loop there's an event to handle + 6. infrun asks the target which direction was it going, and switches + the global execution direction accordingly (to reverse) + 7. infrun polls an event out of the record target, and handles it + 8. GDB goes back to the event loop, and goto #4. + */ + enum exec_direction_kind record_full_execution_dir; + + /* Set to 1 if record_full_store_registers and record_full_xfer_partial + doesn't need record. */ + + int record_full_gdb_operation_disable; +}; /* 1 ask user. 0 auto delete the last struct record_full_entry. */ static int record_full_stop_at_limit = 1; /* Maximum allowed number of insns in execution log. */ static unsigned int record_full_insn_max_num = DEFAULT_RECORD_FULL_INSN_MAX_NUM; -/* Actual count of insns presently in execution log. */ -static unsigned int record_full_insn_num = 0; -/* Count of insns logged so far (may be larger - than count of insns presently in execution log). */ -static ULONGEST record_full_insn_count; /* The target_ops of process record. */ static struct target_ops record_full_ops; @@ -215,41 +260,8 @@ static struct cmd_list_element *show_record_full_cmdlist; /* Command list for "record full". */ static struct cmd_list_element *record_full_cmdlist; -/* The beneath function pointers. */ -static struct gdb_target *record_full_beneath_to_resume_ops; -static void (*record_full_beneath_to_resume) (struct gdb_target *, ptid_t, int, - enum gdb_signal); -static struct gdb_target *record_full_beneath_to_wait_ops; -static ptid_t (*record_full_beneath_to_wait) (struct gdb_target *, ptid_t, - struct target_waitstatus *, - int); -static struct gdb_target *record_full_beneath_to_store_registers_ops; -static void (*record_full_beneath_to_store_registers) (struct gdb_target *, - struct regcache *, - int regno); -static struct gdb_target *record_full_beneath_to_xfer_partial_ops; hooks/post-receive -- Repository for Project Archer.