Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: gdb/remote-sim.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/remote-mips.c ('k') | gdb/reverse.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Generic remote debugging interface for simulators. 1 /* Generic remote debugging interface for simulators.
2 2
3 Copyright (C) 1993-2002, 2004-2012 Free Software Foundation, Inc. 3 Copyright (C) 1993-2002, 2004-2012 Free Software Foundation, Inc.
4 4
5 Contributed by Cygnus Support. 5 Contributed by Cygnus Support.
6 Steve Chamberlain (sac@cygnus.com). 6 Steve Chamberlain (sac@cygnus.com).
7 7
8 This file is part of GDB. 8 This file is part of GDB.
9 9
10 This program is free software; you can redistribute it and/or modify 10 This program is free software; you can redistribute it and/or modify
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 SIM_DESC gdbsim_desc; 111 SIM_DESC gdbsim_desc;
112 112
113 /* This is the ptid we use for this particular simulator instance. Its 113 /* This is the ptid we use for this particular simulator instance. Its
114 value is somewhat arbitrary, as the simulator target don't have a 114 value is somewhat arbitrary, as the simulator target don't have a
115 notion of tasks or threads, but we need something non-null to place 115 notion of tasks or threads, but we need something non-null to place
116 in inferior_ptid. For simulators which permit multiple instances, 116 in inferior_ptid. For simulators which permit multiple instances,
117 we also need a unique identifier to use for each inferior. */ 117 we also need a unique identifier to use for each inferior. */
118 ptid_t remote_sim_ptid; 118 ptid_t remote_sim_ptid;
119 119
120 /* Signal with which to resume. */ 120 /* Signal with which to resume. */
121 enum target_signal resume_siggnal; 121 enum gdb_signal resume_siggnal;
122 122
123 /* Flag which indicates whether resume should step or not. */ 123 /* Flag which indicates whether resume should step or not. */
124 int resume_step; 124 int resume_step;
125 }; 125 };
126 126
127 /* Flag indicating the "open" status of this module. It's set to 1 127 /* Flag indicating the "open" status of this module. It's set to 1
128 in gdbsim_open() and 0 in gdbsim_close(). */ 128 in gdbsim_open() and 0 in gdbsim_close(). */
129 static int gdbsim_is_open = 0; 129 static int gdbsim_is_open = 0;
130 130
131 /* Value of the next pid to allocate for an inferior. As indicated 131 /* Value of the next pid to allocate for an inferior. As indicated
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 sim_data = XZALLOC(struct sim_inferior_data); 210 sim_data = XZALLOC(struct sim_inferior_data);
211 set_inferior_data (inf, sim_inferior_data_key, sim_data); 211 set_inferior_data (inf, sim_inferior_data_key, sim_data);
212 212
213 /* Allocate a ptid for this inferior. */ 213 /* Allocate a ptid for this inferior. */
214 sim_data->remote_sim_ptid = ptid_build (next_pid, 0, next_pid); 214 sim_data->remote_sim_ptid = ptid_build (next_pid, 0, next_pid);
215 next_pid++; 215 next_pid++;
216 216
217 /* Initialize the other instance variables. */ 217 /* Initialize the other instance variables. */
218 sim_data->program_loaded = 0; 218 sim_data->program_loaded = 0;
219 sim_data->gdbsim_desc = sim_desc; 219 sim_data->gdbsim_desc = sim_desc;
220 sim_data->resume_siggnal = TARGET_SIGNAL_0; 220 sim_data->resume_siggnal = GDB_SIGNAL_0;
221 sim_data->resume_step = 0; 221 sim_data->resume_step = 0;
222 } 222 }
223 else if (sim_desc) 223 else if (sim_desc)
224 { 224 {
225 /* This handles the case where sim_data was allocated prior to 225 /* This handles the case where sim_data was allocated prior to
226 needing a sim instance. */ 226 needing a sim instance. */
227 sim_data->gdbsim_desc = sim_desc; 227 sim_data->gdbsim_desc = sim_desc;
228 } 228 }
229 229
230 230
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 arg_buf = (char *) alloca (len); 634 arg_buf = (char *) alloca (len);
635 arg_buf[0] = '\0'; 635 arg_buf[0] = '\0';
636 strcat (arg_buf, exec_file); 636 strcat (arg_buf, exec_file);
637 strcat (arg_buf, " "); 637 strcat (arg_buf, " ");
638 strcat (arg_buf, args); 638 strcat (arg_buf, args);
639 argv = gdb_buildargv (arg_buf); 639 argv = gdb_buildargv (arg_buf);
640 make_cleanup_freeargv (argv); 640 make_cleanup_freeargv (argv);
641 } 641 }
642 else 642 else
643 argv = NULL; 643 argv = NULL;
644 sim_create_inferior (sim_data->gdbsim_desc, exec_bfd, argv, env); 644
645 if (sim_create_inferior (sim_data->gdbsim_desc, exec_bfd, argv, env)
646 != SIM_RC_OK)
647 error (_("Unable to create sim inferior."));
645 648
646 inferior_ptid = sim_data->remote_sim_ptid; 649 inferior_ptid = sim_data->remote_sim_ptid;
647 inferior_appeared (current_inferior (), ptid_get_pid (inferior_ptid)); 650 inferior_appeared (current_inferior (), ptid_get_pid (inferior_ptid));
648 add_thread_silent (inferior_ptid); 651 add_thread_silent (inferior_ptid);
649 652
650 insert_breakpoints (); /* Needed to get correct instruction 653 insert_breakpoints (); /* Needed to get correct instruction
651 in cache. */ 654 in cache. */
652 655
653 clear_proceed_status (); 656 clear_proceed_status ();
654 } 657 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 if (from_tty) 831 if (from_tty)
829 printf_filtered ("Ending simulator %s debugging\n", target_shortname); 832 printf_filtered ("Ending simulator %s debugging\n", target_shortname);
830 } 833 }
831 834
832 /* Resume execution of the target process. STEP says whether to single-step 835 /* Resume execution of the target process. STEP says whether to single-step
833 or to run free; SIGGNAL is the signal value (e.g. SIGINT) to be given 836 or to run free; SIGGNAL is the signal value (e.g. SIGINT) to be given
834 to the target, or zero for no signal. */ 837 to the target, or zero for no signal. */
835 838
836 struct resume_data 839 struct resume_data
837 { 840 {
838 enum target_signal siggnal; 841 enum gdb_signal siggnal;
839 int step; 842 int step;
840 }; 843 };
841 844
842 static int 845 static int
843 gdbsim_resume_inferior (struct inferior *inf, void *arg) 846 gdbsim_resume_inferior (struct inferior *inf, void *arg)
844 { 847 {
845 struct sim_inferior_data *sim_data 848 struct sim_inferior_data *sim_data
846 = get_sim_inferior_data (inf, SIM_INSTANCE_NOT_NEEDED); 849 = get_sim_inferior_data (inf, SIM_INSTANCE_NOT_NEEDED);
847 struct resume_data *rd = arg; 850 struct resume_data *rd = arg;
848 851
849 if (sim_data) 852 if (sim_data)
850 { 853 {
851 sim_data->resume_siggnal = rd->siggnal; 854 sim_data->resume_siggnal = rd->siggnal;
852 sim_data->resume_step = rd->step; 855 sim_data->resume_step = rd->step;
853 856
854 if (remote_debug) 857 if (remote_debug)
855 printf_filtered (_("gdbsim_resume: pid %d, step %d, signal %d\n"), 858 printf_filtered (_("gdbsim_resume: pid %d, step %d, signal %d\n"),
856 inf->pid, rd->step, rd->siggnal); 859 inf->pid, rd->step, rd->siggnal);
857 } 860 }
858 861
859 /* When called from iterate_over_inferiors, a zero return causes the 862 /* When called from iterate_over_inferiors, a zero return causes the
860 iteration process to proceed until there are no more inferiors to 863 iteration process to proceed until there are no more inferiors to
861 consider. */ 864 consider. */
862 return 0; 865 return 0;
863 } 866 }
864 867
865 static void 868 static void
866 gdbsim_resume (struct target_ops *ops, 869 gdbsim_resume (struct target_ops *ops,
867 » ptid_t ptid, int step, enum target_signal siggnal) 870 » ptid_t ptid, int step, enum gdb_signal siggnal)
868 { 871 {
869 struct resume_data rd; 872 struct resume_data rd;
870 struct sim_inferior_data *sim_data 873 struct sim_inferior_data *sim_data
871 = get_sim_inferior_data_by_ptid (ptid, SIM_INSTANCE_NOT_NEEDED); 874 = get_sim_inferior_data_by_ptid (ptid, SIM_INSTANCE_NOT_NEEDED);
872 875
873 rd.siggnal = siggnal; 876 rd.siggnal = siggnal;
874 rd.step = step; 877 rd.step = step;
875 878
876 /* We don't access any sim_data members within this function. 879 /* We don't access any sim_data members within this function.
877 What's of interest is whether or not the call to 880 What's of interest is whether or not the call to
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 1021
1019 switch (reason) 1022 switch (reason)
1020 { 1023 {
1021 case sim_exited: 1024 case sim_exited:
1022 status->kind = TARGET_WAITKIND_EXITED; 1025 status->kind = TARGET_WAITKIND_EXITED;
1023 status->value.integer = sigrc; 1026 status->value.integer = sigrc;
1024 break; 1027 break;
1025 case sim_stopped: 1028 case sim_stopped:
1026 switch (sigrc) 1029 switch (sigrc)
1027 { 1030 {
1028 » case TARGET_SIGNAL_ABRT: 1031 » case GDB_SIGNAL_ABRT:
1029 quit (); 1032 quit ();
1030 break; 1033 break;
1031 » case TARGET_SIGNAL_INT: 1034 » case GDB_SIGNAL_INT:
1032 » case TARGET_SIGNAL_TRAP: 1035 » case GDB_SIGNAL_TRAP:
1033 default: 1036 default:
1034 status->kind = TARGET_WAITKIND_STOPPED; 1037 status->kind = TARGET_WAITKIND_STOPPED;
1035 status->value.sig = sigrc; 1038 status->value.sig = sigrc;
1036 break; 1039 break;
1037 } 1040 }
1038 break; 1041 break;
1039 case sim_signalled: 1042 case sim_signalled:
1040 status->kind = TARGET_WAITKIND_SIGNALLED; 1043 status->kind = TARGET_WAITKIND_SIGNALLED;
1041 status->value.sig = sigrc; 1044 status->value.sig = sigrc;
1042 break; 1045 break;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 error (_("Not connected to the simulator target")); 1191 error (_("Not connected to the simulator target"));
1189 } 1192 }
1190 1193
1191 sim_do_command (sim_data->gdbsim_desc, args); 1194 sim_do_command (sim_data->gdbsim_desc, args);
1192 1195
1193 /* Invalidate the register cache, in case the simulator command does 1196 /* Invalidate the register cache, in case the simulator command does
1194 something funny. */ 1197 something funny. */
1195 registers_changed (); 1198 registers_changed ();
1196 } 1199 }
1197 1200
1198 static char ** 1201 static VEC (char_ptr) *
1199 sim_command_completer (struct cmd_list_element *ignore, char *text, char *word) 1202 sim_command_completer (struct cmd_list_element *ignore, char *text, char *word)
1200 { 1203 {
1201 struct sim_inferior_data *sim_data; 1204 struct sim_inferior_data *sim_data;
1205 char **tmp;
1206 int i;
1207 VEC (char_ptr) *result = NULL;
1202 1208
1203 sim_data = inferior_data (current_inferior (), sim_inferior_data_key); 1209 sim_data = inferior_data (current_inferior (), sim_inferior_data_key);
1204 if (sim_data == NULL || sim_data->gdbsim_desc == NULL) 1210 if (sim_data == NULL || sim_data->gdbsim_desc == NULL)
1205 return NULL; 1211 return NULL;
1206 1212
1207 return sim_complete_command (sim_data->gdbsim_desc, text, word); 1213 tmp = sim_complete_command (sim_data->gdbsim_desc, text, word);
1214 if (tmp == NULL)
1215 return NULL;
1216
1217 /* Transform the array into a VEC, and then free the array. */
1218 for (i = 0; tmp[i] != NULL; i++)
1219 VEC_safe_push (char_ptr, result, tmp[i]);
1220 xfree (tmp);
1221
1222 return result;
1208 } 1223 }
1209 1224
1210 /* Check to see if a thread is still alive. */ 1225 /* Check to see if a thread is still alive. */
1211 1226
1212 static int 1227 static int
1213 gdbsim_thread_alive (struct target_ops *ops, ptid_t ptid) 1228 gdbsim_thread_alive (struct target_ops *ops, ptid_t ptid)
1214 { 1229 {
1215 struct sim_inferior_data *sim_data 1230 struct sim_inferior_data *sim_data
1216 = get_sim_inferior_data_by_ptid (ptid, SIM_INSTANCE_NOT_NEEDED); 1231 = get_sim_inferior_data_by_ptid (ptid, SIM_INSTANCE_NOT_NEEDED);
1217 1232
(...skipping 11 matching lines...) Expand all
1229 buffer. */ 1244 buffer. */
1230 1245
1231 static char * 1246 static char *
1232 gdbsim_pid_to_str (struct target_ops *ops, ptid_t ptid) 1247 gdbsim_pid_to_str (struct target_ops *ops, ptid_t ptid)
1233 { 1248 {
1234 return normal_pid_to_str (ptid); 1249 return normal_pid_to_str (ptid);
1235 } 1250 }
1236 1251
1237 /* Simulator memory may be accessed after the program has been loaded. */ 1252 /* Simulator memory may be accessed after the program has been loaded. */
1238 1253
1239 int 1254 static int
1240 gdbsim_has_all_memory (struct target_ops *ops) 1255 gdbsim_has_all_memory (struct target_ops *ops)
1241 { 1256 {
1242 struct sim_inferior_data *sim_data 1257 struct sim_inferior_data *sim_data
1243 = get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NOT_NEEDED); 1258 = get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NOT_NEEDED);
1244 1259
1245 if (!sim_data->program_loaded) 1260 if (!sim_data->program_loaded)
1246 return 0; 1261 return 0;
1247 1262
1248 return 1; 1263 return 1;
1249 } 1264 }
1250 1265
1251 int 1266 static int
1252 gdbsim_has_memory (struct target_ops *ops) 1267 gdbsim_has_memory (struct target_ops *ops)
1253 { 1268 {
1254 struct sim_inferior_data *sim_data 1269 struct sim_inferior_data *sim_data
1255 = get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NOT_NEEDED); 1270 = get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NOT_NEEDED);
1256 1271
1257 if (!sim_data->program_loaded) 1272 if (!sim_data->program_loaded)
1258 return 0; 1273 return 0;
1259 1274
1260 return 1; 1275 return 1;
1261 } 1276 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 init_gdbsim_ops (); 1321 init_gdbsim_ops ();
1307 add_target (&gdbsim_ops); 1322 add_target (&gdbsim_ops);
1308 1323
1309 c = add_com ("sim", class_obscure, simulator_command, 1324 c = add_com ("sim", class_obscure, simulator_command,
1310 _("Send a command to the simulator.")); 1325 _("Send a command to the simulator."));
1311 set_cmd_completer (c, sim_command_completer); 1326 set_cmd_completer (c, sim_command_completer);
1312 1327
1313 sim_inferior_data_key 1328 sim_inferior_data_key
1314 = register_inferior_data_with_cleanup (sim_inferior_data_cleanup); 1329 = register_inferior_data_with_cleanup (sim_inferior_data_cleanup);
1315 } 1330 }
OLDNEW
« no previous file with comments | « gdb/remote-mips.c ('k') | gdb/reverse.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698