1 |
1181 |
sfurman |
/* Memory-access and commands for "inferior" process, for GDB.
|
2 |
|
|
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
|
3 |
|
|
1996, 1997, 1998, 1999, 2000, 2001, 2002
|
4 |
|
|
Free Software Foundation, Inc.
|
5 |
|
|
|
6 |
|
|
This file is part of GDB.
|
7 |
|
|
|
8 |
|
|
This program is free software; you can redistribute it and/or modify
|
9 |
|
|
it under the terms of the GNU General Public License as published by
|
10 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
11 |
|
|
(at your option) any later version.
|
12 |
|
|
|
13 |
|
|
This program is distributed in the hope that it will be useful,
|
14 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
|
|
GNU General Public License for more details.
|
17 |
|
|
|
18 |
|
|
You should have received a copy of the GNU General Public License
|
19 |
|
|
along with this program; if not, write to the Free Software
|
20 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
21 |
|
|
Boston, MA 02111-1307, USA. */
|
22 |
|
|
|
23 |
|
|
#include "defs.h"
|
24 |
|
|
#include <signal.h>
|
25 |
|
|
#include "gdb_string.h"
|
26 |
|
|
#include "symtab.h"
|
27 |
|
|
#include "gdbtypes.h"
|
28 |
|
|
#include "frame.h"
|
29 |
|
|
#include "inferior.h"
|
30 |
|
|
#include "environ.h"
|
31 |
|
|
#include "value.h"
|
32 |
|
|
#include "gdbcmd.h"
|
33 |
|
|
#include "symfile.h"
|
34 |
|
|
#include "gdbcore.h"
|
35 |
|
|
#include "target.h"
|
36 |
|
|
#include "language.h"
|
37 |
|
|
#include "symfile.h"
|
38 |
|
|
#include "objfiles.h"
|
39 |
|
|
#include "completer.h"
|
40 |
|
|
#include "ui-out.h"
|
41 |
|
|
#include "event-top.h"
|
42 |
|
|
#include "parser-defs.h"
|
43 |
|
|
#include "regcache.h"
|
44 |
|
|
|
45 |
|
|
/* Functions exported for general use: */
|
46 |
|
|
|
47 |
|
|
void nofp_registers_info (char *, int);
|
48 |
|
|
|
49 |
|
|
void all_registers_info (char *, int);
|
50 |
|
|
|
51 |
|
|
void registers_info (char *, int);
|
52 |
|
|
|
53 |
|
|
/* Local functions: */
|
54 |
|
|
|
55 |
|
|
void continue_command (char *, int);
|
56 |
|
|
|
57 |
|
|
static void print_return_value (int struct_return, struct type *value_type);
|
58 |
|
|
|
59 |
|
|
static void finish_command_continuation (struct continuation_arg *);
|
60 |
|
|
|
61 |
|
|
static void until_next_command (int);
|
62 |
|
|
|
63 |
|
|
static void until_command (char *, int);
|
64 |
|
|
|
65 |
|
|
static void path_info (char *, int);
|
66 |
|
|
|
67 |
|
|
static void path_command (char *, int);
|
68 |
|
|
|
69 |
|
|
static void unset_command (char *, int);
|
70 |
|
|
|
71 |
|
|
static void float_info (char *, int);
|
72 |
|
|
|
73 |
|
|
static void detach_command (char *, int);
|
74 |
|
|
|
75 |
|
|
static void interrupt_target_command (char *args, int from_tty);
|
76 |
|
|
|
77 |
|
|
static void unset_environment_command (char *, int);
|
78 |
|
|
|
79 |
|
|
static void set_environment_command (char *, int);
|
80 |
|
|
|
81 |
|
|
static void environment_info (char *, int);
|
82 |
|
|
|
83 |
|
|
static void program_info (char *, int);
|
84 |
|
|
|
85 |
|
|
static void finish_command (char *, int);
|
86 |
|
|
|
87 |
|
|
static void signal_command (char *, int);
|
88 |
|
|
|
89 |
|
|
static void jump_command (char *, int);
|
90 |
|
|
|
91 |
|
|
static void step_1 (int, int, char *);
|
92 |
|
|
static void step_once (int skip_subroutines, int single_inst, int count);
|
93 |
|
|
static void step_1_continuation (struct continuation_arg *arg);
|
94 |
|
|
|
95 |
|
|
void nexti_command (char *, int);
|
96 |
|
|
|
97 |
|
|
void stepi_command (char *, int);
|
98 |
|
|
|
99 |
|
|
static void next_command (char *, int);
|
100 |
|
|
|
101 |
|
|
static void step_command (char *, int);
|
102 |
|
|
|
103 |
|
|
static void run_command (char *, int);
|
104 |
|
|
|
105 |
|
|
static void run_no_args_command (char *args, int from_tty);
|
106 |
|
|
|
107 |
|
|
static void go_command (char *line_no, int from_tty);
|
108 |
|
|
|
109 |
|
|
static int strip_bg_char (char **);
|
110 |
|
|
|
111 |
|
|
void _initialize_infcmd (void);
|
112 |
|
|
|
113 |
|
|
#define GO_USAGE "Usage: go <location>\n"
|
114 |
|
|
|
115 |
|
|
static void breakpoint_auto_delete_contents (PTR);
|
116 |
|
|
|
117 |
|
|
#define ERROR_NO_INFERIOR \
|
118 |
|
|
if (!target_has_execution) error ("The program is not being run.");
|
119 |
|
|
|
120 |
|
|
/* String containing arguments to give to the program, separated by spaces.
|
121 |
|
|
Empty string (pointer to '\0') means no args. */
|
122 |
|
|
|
123 |
|
|
static char *inferior_args;
|
124 |
|
|
|
125 |
|
|
/* The inferior arguments as a vector. If INFERIOR_ARGC is nonzero,
|
126 |
|
|
then we must compute INFERIOR_ARGS from this (via the target). */
|
127 |
|
|
|
128 |
|
|
static int inferior_argc;
|
129 |
|
|
static char **inferior_argv;
|
130 |
|
|
|
131 |
|
|
/* File name for default use for standard in/out in the inferior. */
|
132 |
|
|
|
133 |
|
|
char *inferior_io_terminal;
|
134 |
|
|
|
135 |
|
|
/* Pid of our debugged inferior, or 0 if no inferior now.
|
136 |
|
|
Since various parts of infrun.c test this to see whether there is a program
|
137 |
|
|
being debugged it should be nonzero (currently 3 is used) for remote
|
138 |
|
|
debugging. */
|
139 |
|
|
|
140 |
|
|
ptid_t inferior_ptid;
|
141 |
|
|
|
142 |
|
|
/* Last signal that the inferior received (why it stopped). */
|
143 |
|
|
|
144 |
|
|
enum target_signal stop_signal;
|
145 |
|
|
|
146 |
|
|
/* Address at which inferior stopped. */
|
147 |
|
|
|
148 |
|
|
CORE_ADDR stop_pc;
|
149 |
|
|
|
150 |
|
|
/* Chain containing status of breakpoint(s) that we have stopped at. */
|
151 |
|
|
|
152 |
|
|
bpstat stop_bpstat;
|
153 |
|
|
|
154 |
|
|
/* Flag indicating that a command has proceeded the inferior past the
|
155 |
|
|
current breakpoint. */
|
156 |
|
|
|
157 |
|
|
int breakpoint_proceeded;
|
158 |
|
|
|
159 |
|
|
/* Nonzero if stopped due to a step command. */
|
160 |
|
|
|
161 |
|
|
int stop_step;
|
162 |
|
|
|
163 |
|
|
/* Nonzero if stopped due to completion of a stack dummy routine. */
|
164 |
|
|
|
165 |
|
|
int stop_stack_dummy;
|
166 |
|
|
|
167 |
|
|
/* Nonzero if stopped due to a random (unexpected) signal in inferior
|
168 |
|
|
process. */
|
169 |
|
|
|
170 |
|
|
int stopped_by_random_signal;
|
171 |
|
|
|
172 |
|
|
/* Range to single step within.
|
173 |
|
|
If this is nonzero, respond to a single-step signal
|
174 |
|
|
by continuing to step if the pc is in this range. */
|
175 |
|
|
|
176 |
|
|
CORE_ADDR step_range_start; /* Inclusive */
|
177 |
|
|
CORE_ADDR step_range_end; /* Exclusive */
|
178 |
|
|
|
179 |
|
|
/* Stack frame address as of when stepping command was issued.
|
180 |
|
|
This is how we know when we step into a subroutine call,
|
181 |
|
|
and how to set the frame for the breakpoint used to step out. */
|
182 |
|
|
|
183 |
|
|
CORE_ADDR step_frame_address;
|
184 |
|
|
|
185 |
|
|
/* Our notion of the current stack pointer. */
|
186 |
|
|
|
187 |
|
|
CORE_ADDR step_sp;
|
188 |
|
|
|
189 |
|
|
enum step_over_calls_kind step_over_calls;
|
190 |
|
|
|
191 |
|
|
/* If stepping, nonzero means step count is > 1
|
192 |
|
|
so don't print frame next time inferior stops
|
193 |
|
|
if it stops due to stepping. */
|
194 |
|
|
|
195 |
|
|
int step_multi;
|
196 |
|
|
|
197 |
|
|
/* Environment to use for running inferior,
|
198 |
|
|
in format described in environ.h. */
|
199 |
|
|
|
200 |
|
|
struct environ *inferior_environ;
|
201 |
|
|
|
202 |
|
|
/* Accessor routines. */
|
203 |
|
|
|
204 |
|
|
char *
|
205 |
|
|
get_inferior_args (void)
|
206 |
|
|
{
|
207 |
|
|
if (inferior_argc != 0)
|
208 |
|
|
{
|
209 |
|
|
char *n, *old;
|
210 |
|
|
|
211 |
|
|
n = gdbarch_construct_inferior_arguments (current_gdbarch,
|
212 |
|
|
inferior_argc, inferior_argv);
|
213 |
|
|
old = set_inferior_args (n);
|
214 |
|
|
xfree (old);
|
215 |
|
|
}
|
216 |
|
|
|
217 |
|
|
if (inferior_args == NULL)
|
218 |
|
|
inferior_args = xstrdup ("");
|
219 |
|
|
|
220 |
|
|
return inferior_args;
|
221 |
|
|
}
|
222 |
|
|
|
223 |
|
|
char *
|
224 |
|
|
set_inferior_args (char *newargs)
|
225 |
|
|
{
|
226 |
|
|
char *saved_args = inferior_args;
|
227 |
|
|
|
228 |
|
|
inferior_args = newargs;
|
229 |
|
|
inferior_argc = 0;
|
230 |
|
|
inferior_argv = 0;
|
231 |
|
|
|
232 |
|
|
return saved_args;
|
233 |
|
|
}
|
234 |
|
|
|
235 |
|
|
void
|
236 |
|
|
set_inferior_args_vector (int argc, char **argv)
|
237 |
|
|
{
|
238 |
|
|
inferior_argc = argc;
|
239 |
|
|
inferior_argv = argv;
|
240 |
|
|
}
|
241 |
|
|
|
242 |
|
|
/* Notice when `set args' is run. */
|
243 |
|
|
static void
|
244 |
|
|
notice_args_set (char *args, int from_tty, struct cmd_list_element *c)
|
245 |
|
|
{
|
246 |
|
|
inferior_argc = 0;
|
247 |
|
|
inferior_argv = 0;
|
248 |
|
|
}
|
249 |
|
|
|
250 |
|
|
/* Notice when `show args' is run. */
|
251 |
|
|
static void
|
252 |
|
|
notice_args_read (char *args, int from_tty, struct cmd_list_element *c)
|
253 |
|
|
{
|
254 |
|
|
/* Might compute the value. */
|
255 |
|
|
get_inferior_args ();
|
256 |
|
|
}
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
/* Compute command-line string given argument vector. This does the
|
260 |
|
|
same shell processing as fork_inferior. */
|
261 |
|
|
/* ARGSUSED */
|
262 |
|
|
char *
|
263 |
|
|
construct_inferior_arguments (struct gdbarch *gdbarch, int argc, char **argv)
|
264 |
|
|
{
|
265 |
|
|
char *result;
|
266 |
|
|
|
267 |
|
|
if (STARTUP_WITH_SHELL)
|
268 |
|
|
{
|
269 |
|
|
/* This holds all the characters considered special to the
|
270 |
|
|
typical Unix shells. We include `^' because the SunOS
|
271 |
|
|
/bin/sh treats it as a synonym for `|'. */
|
272 |
|
|
char *special = "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
|
273 |
|
|
int i;
|
274 |
|
|
int length = 0;
|
275 |
|
|
char *out, *cp;
|
276 |
|
|
|
277 |
|
|
/* We over-compute the size. It shouldn't matter. */
|
278 |
|
|
for (i = 0; i < argc; ++i)
|
279 |
|
|
length += 2 * strlen (argv[i]) + 1;
|
280 |
|
|
|
281 |
|
|
result = (char *) xmalloc (length);
|
282 |
|
|
out = result;
|
283 |
|
|
|
284 |
|
|
for (i = 0; i < argc; ++i)
|
285 |
|
|
{
|
286 |
|
|
if (i > 0)
|
287 |
|
|
*out++ = ' ';
|
288 |
|
|
|
289 |
|
|
for (cp = argv[i]; *cp; ++cp)
|
290 |
|
|
{
|
291 |
|
|
if (strchr (special, *cp) != NULL)
|
292 |
|
|
*out++ = '\\';
|
293 |
|
|
*out++ = *cp;
|
294 |
|
|
}
|
295 |
|
|
}
|
296 |
|
|
*out = '\0';
|
297 |
|
|
}
|
298 |
|
|
else
|
299 |
|
|
{
|
300 |
|
|
/* In this case we can't handle arguments that contain spaces,
|
301 |
|
|
tabs, or newlines -- see breakup_args(). */
|
302 |
|
|
int i;
|
303 |
|
|
int length = 0;
|
304 |
|
|
|
305 |
|
|
for (i = 0; i < argc; ++i)
|
306 |
|
|
{
|
307 |
|
|
char *cp = strchr (argv[i], ' ');
|
308 |
|
|
if (cp == NULL)
|
309 |
|
|
cp = strchr (argv[i], '\t');
|
310 |
|
|
if (cp == NULL)
|
311 |
|
|
cp = strchr (argv[i], '\n');
|
312 |
|
|
if (cp != NULL)
|
313 |
|
|
error ("can't handle command-line argument containing whitespace");
|
314 |
|
|
length += strlen (argv[i]) + 1;
|
315 |
|
|
}
|
316 |
|
|
|
317 |
|
|
result = (char *) xmalloc (length);
|
318 |
|
|
result[0] = '\0';
|
319 |
|
|
for (i = 0; i < argc; ++i)
|
320 |
|
|
{
|
321 |
|
|
if (i > 0)
|
322 |
|
|
strcat (result, " ");
|
323 |
|
|
strcat (result, argv[i]);
|
324 |
|
|
}
|
325 |
|
|
}
|
326 |
|
|
|
327 |
|
|
return result;
|
328 |
|
|
}
|
329 |
|
|
|
330 |
|
|
|
331 |
|
|
/* This function detects whether or not a '&' character (indicating
|
332 |
|
|
background execution) has been added as *the last* of the arguments ARGS
|
333 |
|
|
of a command. If it has, it removes it and returns 1. Otherwise it
|
334 |
|
|
does nothing and returns 0. */
|
335 |
|
|
static int
|
336 |
|
|
strip_bg_char (char **args)
|
337 |
|
|
{
|
338 |
|
|
char *p = NULL;
|
339 |
|
|
|
340 |
|
|
p = strchr (*args, '&');
|
341 |
|
|
|
342 |
|
|
if (p)
|
343 |
|
|
{
|
344 |
|
|
if (p == (*args + strlen (*args) - 1))
|
345 |
|
|
{
|
346 |
|
|
if (strlen (*args) > 1)
|
347 |
|
|
{
|
348 |
|
|
do
|
349 |
|
|
p--;
|
350 |
|
|
while (*p == ' ' || *p == '\t');
|
351 |
|
|
*(p + 1) = '\0';
|
352 |
|
|
}
|
353 |
|
|
else
|
354 |
|
|
*args = 0;
|
355 |
|
|
return 1;
|
356 |
|
|
}
|
357 |
|
|
}
|
358 |
|
|
return 0;
|
359 |
|
|
}
|
360 |
|
|
|
361 |
|
|
/* ARGSUSED */
|
362 |
|
|
void
|
363 |
|
|
tty_command (char *file, int from_tty)
|
364 |
|
|
{
|
365 |
|
|
if (file == 0)
|
366 |
|
|
error_no_arg ("terminal name for running target process");
|
367 |
|
|
|
368 |
|
|
inferior_io_terminal = savestring (file, strlen (file));
|
369 |
|
|
}
|
370 |
|
|
|
371 |
|
|
static void
|
372 |
|
|
run_command (char *args, int from_tty)
|
373 |
|
|
{
|
374 |
|
|
char *exec_file;
|
375 |
|
|
|
376 |
|
|
dont_repeat ();
|
377 |
|
|
|
378 |
|
|
if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
|
379 |
|
|
{
|
380 |
|
|
if (from_tty
|
381 |
|
|
&& !query ("The program being debugged has been started already.\n\
|
382 |
|
|
Start it from the beginning? "))
|
383 |
|
|
error ("Program not restarted.");
|
384 |
|
|
target_kill ();
|
385 |
|
|
#if defined(SOLIB_RESTART)
|
386 |
|
|
SOLIB_RESTART ();
|
387 |
|
|
#endif
|
388 |
|
|
init_wait_for_inferior ();
|
389 |
|
|
}
|
390 |
|
|
|
391 |
|
|
clear_breakpoint_hit_counts ();
|
392 |
|
|
|
393 |
|
|
/* Purge old solib objfiles. */
|
394 |
|
|
objfile_purge_solibs ();
|
395 |
|
|
|
396 |
|
|
do_run_cleanups (NULL);
|
397 |
|
|
|
398 |
|
|
/* The comment here used to read, "The exec file is re-read every
|
399 |
|
|
time we do a generic_mourn_inferior, so we just have to worry
|
400 |
|
|
about the symbol file." The `generic_mourn_inferior' function
|
401 |
|
|
gets called whenever the program exits. However, suppose the
|
402 |
|
|
program exits, and *then* the executable file changes? We need
|
403 |
|
|
to check again here. Since reopen_exec_file doesn't do anything
|
404 |
|
|
if the timestamp hasn't changed, I don't see the harm. */
|
405 |
|
|
reopen_exec_file ();
|
406 |
|
|
reread_symbols ();
|
407 |
|
|
|
408 |
|
|
exec_file = (char *) get_exec_file (0);
|
409 |
|
|
|
410 |
|
|
/* We keep symbols from add-symbol-file, on the grounds that the
|
411 |
|
|
user might want to add some symbols before running the program
|
412 |
|
|
(right?). But sometimes (dynamic loading where the user manually
|
413 |
|
|
introduces the new symbols with add-symbol-file), the code which
|
414 |
|
|
the symbols describe does not persist between runs. Currently
|
415 |
|
|
the user has to manually nuke all symbols between runs if they
|
416 |
|
|
want them to go away (PR 2207). This is probably reasonable. */
|
417 |
|
|
|
418 |
|
|
if (!args)
|
419 |
|
|
{
|
420 |
|
|
if (event_loop_p && target_can_async_p ())
|
421 |
|
|
async_disable_stdin ();
|
422 |
|
|
}
|
423 |
|
|
else
|
424 |
|
|
{
|
425 |
|
|
int async_exec = strip_bg_char (&args);
|
426 |
|
|
|
427 |
|
|
/* If we get a request for running in the bg but the target
|
428 |
|
|
doesn't support it, error out. */
|
429 |
|
|
if (event_loop_p && async_exec && !target_can_async_p ())
|
430 |
|
|
error ("Asynchronous execution not supported on this target.");
|
431 |
|
|
|
432 |
|
|
/* If we don't get a request of running in the bg, then we need
|
433 |
|
|
to simulate synchronous (fg) execution. */
|
434 |
|
|
if (event_loop_p && !async_exec && target_can_async_p ())
|
435 |
|
|
{
|
436 |
|
|
/* Simulate synchronous execution */
|
437 |
|
|
async_disable_stdin ();
|
438 |
|
|
}
|
439 |
|
|
|
440 |
|
|
/* If there were other args, beside '&', process them. */
|
441 |
|
|
if (args)
|
442 |
|
|
{
|
443 |
|
|
char *old_args = set_inferior_args (xstrdup (args));
|
444 |
|
|
xfree (old_args);
|
445 |
|
|
}
|
446 |
|
|
}
|
447 |
|
|
|
448 |
|
|
if (from_tty)
|
449 |
|
|
{
|
450 |
|
|
ui_out_field_string (uiout, NULL, "Starting program");
|
451 |
|
|
ui_out_text (uiout, ": ");
|
452 |
|
|
if (exec_file)
|
453 |
|
|
ui_out_field_string (uiout, "execfile", exec_file);
|
454 |
|
|
ui_out_spaces (uiout, 1);
|
455 |
|
|
/* We call get_inferior_args() because we might need to compute
|
456 |
|
|
the value now. */
|
457 |
|
|
ui_out_field_string (uiout, "infargs", get_inferior_args ());
|
458 |
|
|
ui_out_text (uiout, "\n");
|
459 |
|
|
ui_out_flush (uiout);
|
460 |
|
|
}
|
461 |
|
|
|
462 |
|
|
/* We call get_inferior_args() because we might need to compute
|
463 |
|
|
the value now. */
|
464 |
|
|
target_create_inferior (exec_file, get_inferior_args (),
|
465 |
|
|
environ_vector (inferior_environ));
|
466 |
|
|
}
|
467 |
|
|
|
468 |
|
|
|
469 |
|
|
static void
|
470 |
|
|
run_no_args_command (char *args, int from_tty)
|
471 |
|
|
{
|
472 |
|
|
char *old_args = set_inferior_args (xstrdup (""));
|
473 |
|
|
xfree (old_args);
|
474 |
|
|
}
|
475 |
|
|
|
476 |
|
|
|
477 |
|
|
void
|
478 |
|
|
continue_command (char *proc_count_exp, int from_tty)
|
479 |
|
|
{
|
480 |
|
|
int async_exec = 0;
|
481 |
|
|
ERROR_NO_INFERIOR;
|
482 |
|
|
|
483 |
|
|
/* Find out whether we must run in the background. */
|
484 |
|
|
if (proc_count_exp != NULL)
|
485 |
|
|
async_exec = strip_bg_char (&proc_count_exp);
|
486 |
|
|
|
487 |
|
|
/* If we must run in the background, but the target can't do it,
|
488 |
|
|
error out. */
|
489 |
|
|
if (event_loop_p && async_exec && !target_can_async_p ())
|
490 |
|
|
error ("Asynchronous execution not supported on this target.");
|
491 |
|
|
|
492 |
|
|
/* If we are not asked to run in the bg, then prepare to run in the
|
493 |
|
|
foreground, synchronously. */
|
494 |
|
|
if (event_loop_p && !async_exec && target_can_async_p ())
|
495 |
|
|
{
|
496 |
|
|
/* Simulate synchronous execution */
|
497 |
|
|
async_disable_stdin ();
|
498 |
|
|
}
|
499 |
|
|
|
500 |
|
|
/* If have argument (besides '&'), set proceed count of breakpoint
|
501 |
|
|
we stopped at. */
|
502 |
|
|
if (proc_count_exp != NULL)
|
503 |
|
|
{
|
504 |
|
|
bpstat bs = stop_bpstat;
|
505 |
|
|
int num = bpstat_num (&bs);
|
506 |
|
|
if (num == 0 && from_tty)
|
507 |
|
|
{
|
508 |
|
|
printf_filtered
|
509 |
|
|
("Not stopped at any breakpoint; argument ignored.\n");
|
510 |
|
|
}
|
511 |
|
|
while (num != 0)
|
512 |
|
|
{
|
513 |
|
|
set_ignore_count (num,
|
514 |
|
|
parse_and_eval_long (proc_count_exp) - 1,
|
515 |
|
|
from_tty);
|
516 |
|
|
/* set_ignore_count prints a message ending with a period.
|
517 |
|
|
So print two spaces before "Continuing.". */
|
518 |
|
|
if (from_tty)
|
519 |
|
|
printf_filtered (" ");
|
520 |
|
|
num = bpstat_num (&bs);
|
521 |
|
|
}
|
522 |
|
|
}
|
523 |
|
|
|
524 |
|
|
if (from_tty)
|
525 |
|
|
printf_filtered ("Continuing.\n");
|
526 |
|
|
|
527 |
|
|
clear_proceed_status ();
|
528 |
|
|
|
529 |
|
|
proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
|
530 |
|
|
}
|
531 |
|
|
|
532 |
|
|
/* Step until outside of current statement. */
|
533 |
|
|
|
534 |
|
|
/* ARGSUSED */
|
535 |
|
|
static void
|
536 |
|
|
step_command (char *count_string, int from_tty)
|
537 |
|
|
{
|
538 |
|
|
step_1 (0, 0, count_string);
|
539 |
|
|
}
|
540 |
|
|
|
541 |
|
|
/* Likewise, but skip over subroutine calls as if single instructions. */
|
542 |
|
|
|
543 |
|
|
/* ARGSUSED */
|
544 |
|
|
static void
|
545 |
|
|
next_command (char *count_string, int from_tty)
|
546 |
|
|
{
|
547 |
|
|
step_1 (1, 0, count_string);
|
548 |
|
|
}
|
549 |
|
|
|
550 |
|
|
/* Likewise, but step only one instruction. */
|
551 |
|
|
|
552 |
|
|
/* ARGSUSED */
|
553 |
|
|
void
|
554 |
|
|
stepi_command (char *count_string, int from_tty)
|
555 |
|
|
{
|
556 |
|
|
step_1 (0, 1, count_string);
|
557 |
|
|
}
|
558 |
|
|
|
559 |
|
|
/* ARGSUSED */
|
560 |
|
|
void
|
561 |
|
|
nexti_command (char *count_string, int from_tty)
|
562 |
|
|
{
|
563 |
|
|
step_1 (1, 1, count_string);
|
564 |
|
|
}
|
565 |
|
|
|
566 |
|
|
static void
|
567 |
|
|
disable_longjmp_breakpoint_cleanup (void *ignore)
|
568 |
|
|
{
|
569 |
|
|
disable_longjmp_breakpoint ();
|
570 |
|
|
}
|
571 |
|
|
|
572 |
|
|
static void
|
573 |
|
|
step_1 (int skip_subroutines, int single_inst, char *count_string)
|
574 |
|
|
{
|
575 |
|
|
register int count = 1;
|
576 |
|
|
struct frame_info *frame;
|
577 |
|
|
struct cleanup *cleanups = 0;
|
578 |
|
|
int async_exec = 0;
|
579 |
|
|
|
580 |
|
|
ERROR_NO_INFERIOR;
|
581 |
|
|
|
582 |
|
|
if (count_string)
|
583 |
|
|
async_exec = strip_bg_char (&count_string);
|
584 |
|
|
|
585 |
|
|
/* If we get a request for running in the bg but the target
|
586 |
|
|
doesn't support it, error out. */
|
587 |
|
|
if (event_loop_p && async_exec && !target_can_async_p ())
|
588 |
|
|
error ("Asynchronous execution not supported on this target.");
|
589 |
|
|
|
590 |
|
|
/* If we don't get a request of running in the bg, then we need
|
591 |
|
|
to simulate synchronous (fg) execution. */
|
592 |
|
|
if (event_loop_p && !async_exec && target_can_async_p ())
|
593 |
|
|
{
|
594 |
|
|
/* Simulate synchronous execution */
|
595 |
|
|
async_disable_stdin ();
|
596 |
|
|
}
|
597 |
|
|
|
598 |
|
|
count = count_string ? parse_and_eval_long (count_string) : 1;
|
599 |
|
|
|
600 |
|
|
if (!single_inst || skip_subroutines) /* leave si command alone */
|
601 |
|
|
{
|
602 |
|
|
enable_longjmp_breakpoint ();
|
603 |
|
|
if (!event_loop_p || !target_can_async_p ())
|
604 |
|
|
cleanups = make_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
|
605 |
|
|
else
|
606 |
|
|
make_exec_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
|
607 |
|
|
}
|
608 |
|
|
|
609 |
|
|
/* In synchronous case, all is well, just use the regular for loop. */
|
610 |
|
|
if (!event_loop_p || !target_can_async_p ())
|
611 |
|
|
{
|
612 |
|
|
for (; count > 0; count--)
|
613 |
|
|
{
|
614 |
|
|
clear_proceed_status ();
|
615 |
|
|
|
616 |
|
|
frame = get_current_frame ();
|
617 |
|
|
if (!frame) /* Avoid coredump here. Why tho? */
|
618 |
|
|
error ("No current frame");
|
619 |
|
|
step_frame_address = FRAME_FP (frame);
|
620 |
|
|
step_sp = read_sp ();
|
621 |
|
|
|
622 |
|
|
if (!single_inst)
|
623 |
|
|
{
|
624 |
|
|
find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
|
625 |
|
|
if (step_range_end == 0)
|
626 |
|
|
{
|
627 |
|
|
char *name;
|
628 |
|
|
if (find_pc_partial_function (stop_pc, &name, &step_range_start,
|
629 |
|
|
&step_range_end) == 0)
|
630 |
|
|
error ("Cannot find bounds of current function");
|
631 |
|
|
|
632 |
|
|
target_terminal_ours ();
|
633 |
|
|
printf_filtered ("\
|
634 |
|
|
Single stepping until exit from function %s, \n\
|
635 |
|
|
which has no line number information.\n", name);
|
636 |
|
|
}
|
637 |
|
|
}
|
638 |
|
|
else
|
639 |
|
|
{
|
640 |
|
|
/* Say we are stepping, but stop after one insn whatever it does. */
|
641 |
|
|
step_range_start = step_range_end = 1;
|
642 |
|
|
if (!skip_subroutines)
|
643 |
|
|
/* It is stepi.
|
644 |
|
|
Don't step over function calls, not even to functions lacking
|
645 |
|
|
line numbers. */
|
646 |
|
|
step_over_calls = STEP_OVER_NONE;
|
647 |
|
|
}
|
648 |
|
|
|
649 |
|
|
if (skip_subroutines)
|
650 |
|
|
step_over_calls = STEP_OVER_ALL;
|
651 |
|
|
|
652 |
|
|
step_multi = (count > 1);
|
653 |
|
|
proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
|
654 |
|
|
|
655 |
|
|
if (!stop_step)
|
656 |
|
|
break;
|
657 |
|
|
|
658 |
|
|
/* FIXME: On nexti, this may have already been done (when we hit the
|
659 |
|
|
step resume break, I think). Probably this should be moved to
|
660 |
|
|
wait_for_inferior (near the top). */
|
661 |
|
|
#if defined (SHIFT_INST_REGS)
|
662 |
|
|
SHIFT_INST_REGS ();
|
663 |
|
|
#endif
|
664 |
|
|
}
|
665 |
|
|
|
666 |
|
|
if (!single_inst || skip_subroutines)
|
667 |
|
|
do_cleanups (cleanups);
|
668 |
|
|
return;
|
669 |
|
|
}
|
670 |
|
|
/* In case of asynchronous target things get complicated, do only
|
671 |
|
|
one step for now, before returning control to the event loop. Let
|
672 |
|
|
the continuation figure out how many other steps we need to do,
|
673 |
|
|
and handle them one at the time, through step_once(). */
|
674 |
|
|
else
|
675 |
|
|
{
|
676 |
|
|
if (event_loop_p && target_can_async_p ())
|
677 |
|
|
step_once (skip_subroutines, single_inst, count);
|
678 |
|
|
}
|
679 |
|
|
}
|
680 |
|
|
|
681 |
|
|
/* Called after we are done with one step operation, to check whether
|
682 |
|
|
we need to step again, before we print the prompt and return control
|
683 |
|
|
to the user. If count is > 1, we will need to do one more call to
|
684 |
|
|
proceed(), via step_once(). Basically it is like step_once and
|
685 |
|
|
step_1_continuation are co-recursive. */
|
686 |
|
|
static void
|
687 |
|
|
step_1_continuation (struct continuation_arg *arg)
|
688 |
|
|
{
|
689 |
|
|
int count;
|
690 |
|
|
int skip_subroutines;
|
691 |
|
|
int single_inst;
|
692 |
|
|
|
693 |
|
|
skip_subroutines = arg->data.integer;
|
694 |
|
|
single_inst = arg->next->data.integer;
|
695 |
|
|
count = arg->next->next->data.integer;
|
696 |
|
|
|
697 |
|
|
if (stop_step)
|
698 |
|
|
{
|
699 |
|
|
/* FIXME: On nexti, this may have already been done (when we hit the
|
700 |
|
|
step resume break, I think). Probably this should be moved to
|
701 |
|
|
wait_for_inferior (near the top). */
|
702 |
|
|
#if defined (SHIFT_INST_REGS)
|
703 |
|
|
SHIFT_INST_REGS ();
|
704 |
|
|
#endif
|
705 |
|
|
step_once (skip_subroutines, single_inst, count - 1);
|
706 |
|
|
}
|
707 |
|
|
else
|
708 |
|
|
if (!single_inst || skip_subroutines)
|
709 |
|
|
do_exec_cleanups (ALL_CLEANUPS);
|
710 |
|
|
}
|
711 |
|
|
|
712 |
|
|
/* Do just one step operation. If count >1 we will have to set up a
|
713 |
|
|
continuation to be done after the target stops (after this one
|
714 |
|
|
step). This is useful to implement the 'step n' kind of commands, in
|
715 |
|
|
case of asynchronous targets. We had to split step_1 into two parts,
|
716 |
|
|
one to be done before proceed() and one afterwards. This function is
|
717 |
|
|
called in case of step n with n>1, after the first step operation has
|
718 |
|
|
been completed.*/
|
719 |
|
|
static void
|
720 |
|
|
step_once (int skip_subroutines, int single_inst, int count)
|
721 |
|
|
{
|
722 |
|
|
struct continuation_arg *arg1;
|
723 |
|
|
struct continuation_arg *arg2;
|
724 |
|
|
struct continuation_arg *arg3;
|
725 |
|
|
struct frame_info *frame;
|
726 |
|
|
|
727 |
|
|
if (count > 0)
|
728 |
|
|
{
|
729 |
|
|
clear_proceed_status ();
|
730 |
|
|
|
731 |
|
|
frame = get_current_frame ();
|
732 |
|
|
if (!frame) /* Avoid coredump here. Why tho? */
|
733 |
|
|
error ("No current frame");
|
734 |
|
|
step_frame_address = FRAME_FP (frame);
|
735 |
|
|
step_sp = read_sp ();
|
736 |
|
|
|
737 |
|
|
if (!single_inst)
|
738 |
|
|
{
|
739 |
|
|
find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
|
740 |
|
|
|
741 |
|
|
/* If we have no line info, switch to stepi mode. */
|
742 |
|
|
if (step_range_end == 0 && step_stop_if_no_debug)
|
743 |
|
|
{
|
744 |
|
|
step_range_start = step_range_end = 1;
|
745 |
|
|
}
|
746 |
|
|
else if (step_range_end == 0)
|
747 |
|
|
{
|
748 |
|
|
char *name;
|
749 |
|
|
if (find_pc_partial_function (stop_pc, &name, &step_range_start,
|
750 |
|
|
&step_range_end) == 0)
|
751 |
|
|
error ("Cannot find bounds of current function");
|
752 |
|
|
|
753 |
|
|
target_terminal_ours ();
|
754 |
|
|
printf_filtered ("\
|
755 |
|
|
Single stepping until exit from function %s, \n\
|
756 |
|
|
which has no line number information.\n", name);
|
757 |
|
|
}
|
758 |
|
|
}
|
759 |
|
|
else
|
760 |
|
|
{
|
761 |
|
|
/* Say we are stepping, but stop after one insn whatever it does. */
|
762 |
|
|
step_range_start = step_range_end = 1;
|
763 |
|
|
if (!skip_subroutines)
|
764 |
|
|
/* It is stepi.
|
765 |
|
|
Don't step over function calls, not even to functions lacking
|
766 |
|
|
line numbers. */
|
767 |
|
|
step_over_calls = STEP_OVER_NONE;
|
768 |
|
|
}
|
769 |
|
|
|
770 |
|
|
if (skip_subroutines)
|
771 |
|
|
step_over_calls = STEP_OVER_ALL;
|
772 |
|
|
|
773 |
|
|
step_multi = (count > 1);
|
774 |
|
|
arg1 =
|
775 |
|
|
(struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
|
776 |
|
|
arg2 =
|
777 |
|
|
(struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
|
778 |
|
|
arg3 =
|
779 |
|
|
(struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
|
780 |
|
|
arg1->next = arg2;
|
781 |
|
|
arg1->data.integer = skip_subroutines;
|
782 |
|
|
arg2->next = arg3;
|
783 |
|
|
arg2->data.integer = single_inst;
|
784 |
|
|
arg3->next = NULL;
|
785 |
|
|
arg3->data.integer = count;
|
786 |
|
|
add_intermediate_continuation (step_1_continuation, arg1);
|
787 |
|
|
proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
|
788 |
|
|
}
|
789 |
|
|
}
|
790 |
|
|
|
791 |
|
|
|
792 |
|
|
/* Continue program at specified address. */
|
793 |
|
|
|
794 |
|
|
static void
|
795 |
|
|
jump_command (char *arg, int from_tty)
|
796 |
|
|
{
|
797 |
|
|
register CORE_ADDR addr;
|
798 |
|
|
struct symtabs_and_lines sals;
|
799 |
|
|
struct symtab_and_line sal;
|
800 |
|
|
struct symbol *fn;
|
801 |
|
|
struct symbol *sfn;
|
802 |
|
|
int async_exec = 0;
|
803 |
|
|
|
804 |
|
|
ERROR_NO_INFERIOR;
|
805 |
|
|
|
806 |
|
|
/* Find out whether we must run in the background. */
|
807 |
|
|
if (arg != NULL)
|
808 |
|
|
async_exec = strip_bg_char (&arg);
|
809 |
|
|
|
810 |
|
|
/* If we must run in the background, but the target can't do it,
|
811 |
|
|
error out. */
|
812 |
|
|
if (event_loop_p && async_exec && !target_can_async_p ())
|
813 |
|
|
error ("Asynchronous execution not supported on this target.");
|
814 |
|
|
|
815 |
|
|
/* If we are not asked to run in the bg, then prepare to run in the
|
816 |
|
|
foreground, synchronously. */
|
817 |
|
|
if (event_loop_p && !async_exec && target_can_async_p ())
|
818 |
|
|
{
|
819 |
|
|
/* Simulate synchronous execution */
|
820 |
|
|
async_disable_stdin ();
|
821 |
|
|
}
|
822 |
|
|
|
823 |
|
|
if (!arg)
|
824 |
|
|
error_no_arg ("starting address");
|
825 |
|
|
|
826 |
|
|
sals = decode_line_spec_1 (arg, 1);
|
827 |
|
|
if (sals.nelts != 1)
|
828 |
|
|
{
|
829 |
|
|
error ("Unreasonable jump request");
|
830 |
|
|
}
|
831 |
|
|
|
832 |
|
|
sal = sals.sals[0];
|
833 |
|
|
xfree (sals.sals);
|
834 |
|
|
|
835 |
|
|
if (sal.symtab == 0 && sal.pc == 0)
|
836 |
|
|
error ("No source file has been specified.");
|
837 |
|
|
|
838 |
|
|
resolve_sal_pc (&sal); /* May error out */
|
839 |
|
|
|
840 |
|
|
/* See if we are trying to jump to another function. */
|
841 |
|
|
fn = get_frame_function (get_current_frame ());
|
842 |
|
|
sfn = find_pc_function (sal.pc);
|
843 |
|
|
if (fn != NULL && sfn != fn)
|
844 |
|
|
{
|
845 |
|
|
if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line,
|
846 |
|
|
SYMBOL_SOURCE_NAME (fn)))
|
847 |
|
|
{
|
848 |
|
|
error ("Not confirmed.");
|
849 |
|
|
/* NOTREACHED */
|
850 |
|
|
}
|
851 |
|
|
}
|
852 |
|
|
|
853 |
|
|
if (sfn != NULL)
|
854 |
|
|
{
|
855 |
|
|
fixup_symbol_section (sfn, 0);
|
856 |
|
|
if (section_is_overlay (SYMBOL_BFD_SECTION (sfn)) &&
|
857 |
|
|
!section_is_mapped (SYMBOL_BFD_SECTION (sfn)))
|
858 |
|
|
{
|
859 |
|
|
if (!query ("WARNING!!! Destination is in unmapped overlay! Jump anyway? "))
|
860 |
|
|
{
|
861 |
|
|
error ("Not confirmed.");
|
862 |
|
|
/* NOTREACHED */
|
863 |
|
|
}
|
864 |
|
|
}
|
865 |
|
|
}
|
866 |
|
|
|
867 |
|
|
addr = sal.pc;
|
868 |
|
|
|
869 |
|
|
if (from_tty)
|
870 |
|
|
{
|
871 |
|
|
printf_filtered ("Continuing at ");
|
872 |
|
|
print_address_numeric (addr, 1, gdb_stdout);
|
873 |
|
|
printf_filtered (".\n");
|
874 |
|
|
}
|
875 |
|
|
|
876 |
|
|
clear_proceed_status ();
|
877 |
|
|
proceed (addr, TARGET_SIGNAL_0, 0);
|
878 |
|
|
}
|
879 |
|
|
|
880 |
|
|
|
881 |
|
|
/* Go to line or address in current procedure */
|
882 |
|
|
static void
|
883 |
|
|
go_command (char *line_no, int from_tty)
|
884 |
|
|
{
|
885 |
|
|
if (line_no == (char *) NULL || !*line_no)
|
886 |
|
|
printf_filtered (GO_USAGE);
|
887 |
|
|
else
|
888 |
|
|
{
|
889 |
|
|
tbreak_command (line_no, from_tty);
|
890 |
|
|
jump_command (line_no, from_tty);
|
891 |
|
|
}
|
892 |
|
|
}
|
893 |
|
|
|
894 |
|
|
|
895 |
|
|
/* Continue program giving it specified signal. */
|
896 |
|
|
|
897 |
|
|
static void
|
898 |
|
|
signal_command (char *signum_exp, int from_tty)
|
899 |
|
|
{
|
900 |
|
|
enum target_signal oursig;
|
901 |
|
|
|
902 |
|
|
dont_repeat (); /* Too dangerous. */
|
903 |
|
|
ERROR_NO_INFERIOR;
|
904 |
|
|
|
905 |
|
|
if (!signum_exp)
|
906 |
|
|
error_no_arg ("signal number");
|
907 |
|
|
|
908 |
|
|
/* It would be even slicker to make signal names be valid expressions,
|
909 |
|
|
(the type could be "enum $signal" or some such), then the user could
|
910 |
|
|
assign them to convenience variables. */
|
911 |
|
|
oursig = target_signal_from_name (signum_exp);
|
912 |
|
|
|
913 |
|
|
if (oursig == TARGET_SIGNAL_UNKNOWN)
|
914 |
|
|
{
|
915 |
|
|
/* No, try numeric. */
|
916 |
|
|
int num = parse_and_eval_long (signum_exp);
|
917 |
|
|
|
918 |
|
|
if (num == 0)
|
919 |
|
|
oursig = TARGET_SIGNAL_0;
|
920 |
|
|
else
|
921 |
|
|
oursig = target_signal_from_command (num);
|
922 |
|
|
}
|
923 |
|
|
|
924 |
|
|
if (from_tty)
|
925 |
|
|
{
|
926 |
|
|
if (oursig == TARGET_SIGNAL_0)
|
927 |
|
|
printf_filtered ("Continuing with no signal.\n");
|
928 |
|
|
else
|
929 |
|
|
printf_filtered ("Continuing with signal %s.\n",
|
930 |
|
|
target_signal_to_name (oursig));
|
931 |
|
|
}
|
932 |
|
|
|
933 |
|
|
clear_proceed_status ();
|
934 |
|
|
/* "signal 0" should not get stuck if we are stopped at a breakpoint.
|
935 |
|
|
FIXME: Neither should "signal foo" but when I tried passing
|
936 |
|
|
(CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't
|
937 |
|
|
tried to track down yet. */
|
938 |
|
|
proceed (oursig == TARGET_SIGNAL_0 ? (CORE_ADDR) -1 : stop_pc, oursig, 0);
|
939 |
|
|
}
|
940 |
|
|
|
941 |
|
|
/* Call breakpoint_auto_delete on the current contents of the bpstat
|
942 |
|
|
pointed to by arg (which is really a bpstat *). */
|
943 |
|
|
|
944 |
|
|
static void
|
945 |
|
|
breakpoint_auto_delete_contents (PTR arg)
|
946 |
|
|
{
|
947 |
|
|
breakpoint_auto_delete (*(bpstat *) arg);
|
948 |
|
|
}
|
949 |
|
|
|
950 |
|
|
|
951 |
|
|
/* Execute a "stack dummy", a piece of code stored in the stack
|
952 |
|
|
by the debugger to be executed in the inferior.
|
953 |
|
|
|
954 |
|
|
To call: first, do PUSH_DUMMY_FRAME.
|
955 |
|
|
Then push the contents of the dummy. It should end with a breakpoint insn.
|
956 |
|
|
Then call here, passing address at which to start the dummy.
|
957 |
|
|
|
958 |
|
|
The contents of all registers are saved before the dummy frame is popped
|
959 |
|
|
and copied into the buffer BUFFER.
|
960 |
|
|
|
961 |
|
|
The dummy's frame is automatically popped whenever that break is hit.
|
962 |
|
|
If that is the first time the program stops, run_stack_dummy
|
963 |
|
|
returns to its caller with that frame already gone and returns 0.
|
964 |
|
|
|
965 |
|
|
Otherwise, run_stack-dummy returns a non-zero value.
|
966 |
|
|
If the called function receives a random signal, we do not allow the user
|
967 |
|
|
to continue executing it as this may not work. The dummy frame is poped
|
968 |
|
|
and we return 1.
|
969 |
|
|
If we hit a breakpoint, we leave the frame in place and return 2 (the frame
|
970 |
|
|
will eventually be popped when we do hit the dummy end breakpoint). */
|
971 |
|
|
|
972 |
|
|
int
|
973 |
|
|
run_stack_dummy (CORE_ADDR addr, struct regcache *buffer)
|
974 |
|
|
{
|
975 |
|
|
struct cleanup *old_cleanups = make_cleanup (null_cleanup, 0);
|
976 |
|
|
int saved_async = 0;
|
977 |
|
|
|
978 |
|
|
/* Now proceed, having reached the desired place. */
|
979 |
|
|
clear_proceed_status ();
|
980 |
|
|
|
981 |
|
|
if (CALL_DUMMY_BREAKPOINT_OFFSET_P)
|
982 |
|
|
{
|
983 |
|
|
struct breakpoint *bpt;
|
984 |
|
|
struct symtab_and_line sal;
|
985 |
|
|
|
986 |
|
|
INIT_SAL (&sal); /* initialize to zeroes */
|
987 |
|
|
if (CALL_DUMMY_LOCATION == AT_ENTRY_POINT)
|
988 |
|
|
{
|
989 |
|
|
sal.pc = CALL_DUMMY_ADDRESS ();
|
990 |
|
|
}
|
991 |
|
|
else
|
992 |
|
|
{
|
993 |
|
|
sal.pc = addr - CALL_DUMMY_START_OFFSET + CALL_DUMMY_BREAKPOINT_OFFSET;
|
994 |
|
|
}
|
995 |
|
|
sal.section = find_pc_overlay (sal.pc);
|
996 |
|
|
|
997 |
|
|
/* Set up a FRAME for the dummy frame so we can pass it to
|
998 |
|
|
set_momentary_breakpoint. We need to give the breakpoint a
|
999 |
|
|
frame in case there is only one copy of the dummy (e.g.
|
1000 |
|
|
CALL_DUMMY_LOCATION == AFTER_TEXT_END). */
|
1001 |
|
|
flush_cached_frames ();
|
1002 |
|
|
set_current_frame (create_new_frame (read_fp (), sal.pc));
|
1003 |
|
|
|
1004 |
|
|
/* If defined, CALL_DUMMY_BREAKPOINT_OFFSET is where we need to put
|
1005 |
|
|
a breakpoint instruction. If not, the call dummy already has the
|
1006 |
|
|
breakpoint instruction in it.
|
1007 |
|
|
|
1008 |
|
|
addr is the address of the call dummy plus the CALL_DUMMY_START_OFFSET,
|
1009 |
|
|
so we need to subtract the CALL_DUMMY_START_OFFSET. */
|
1010 |
|
|
bpt = set_momentary_breakpoint (sal,
|
1011 |
|
|
get_current_frame (),
|
1012 |
|
|
bp_call_dummy);
|
1013 |
|
|
bpt->disposition = disp_del;
|
1014 |
|
|
|
1015 |
|
|
/* If all error()s out of proceed ended up calling normal_stop (and
|
1016 |
|
|
perhaps they should; it already does in the special case of error
|
1017 |
|
|
out of resume()), then we wouldn't need this. */
|
1018 |
|
|
make_cleanup (breakpoint_auto_delete_contents, &stop_bpstat);
|
1019 |
|
|
}
|
1020 |
|
|
|
1021 |
|
|
disable_watchpoints_before_interactive_call_start ();
|
1022 |
|
|
proceed_to_finish = 1; /* We want stop_registers, please... */
|
1023 |
|
|
|
1024 |
|
|
if (target_can_async_p ())
|
1025 |
|
|
saved_async = target_async_mask (0);
|
1026 |
|
|
|
1027 |
|
|
proceed (addr, TARGET_SIGNAL_0, 0);
|
1028 |
|
|
|
1029 |
|
|
if (saved_async)
|
1030 |
|
|
target_async_mask (saved_async);
|
1031 |
|
|
|
1032 |
|
|
enable_watchpoints_after_interactive_call_stop ();
|
1033 |
|
|
|
1034 |
|
|
discard_cleanups (old_cleanups);
|
1035 |
|
|
|
1036 |
|
|
/* We can stop during an inferior call because a signal is received. */
|
1037 |
|
|
if (stopped_by_random_signal)
|
1038 |
|
|
return 1;
|
1039 |
|
|
|
1040 |
|
|
/* We may also stop prematurely because we hit a breakpoint in the
|
1041 |
|
|
called routine. */
|
1042 |
|
|
if (!stop_stack_dummy)
|
1043 |
|
|
return 2;
|
1044 |
|
|
|
1045 |
|
|
/* On normal return, the stack dummy has been popped already. */
|
1046 |
|
|
regcache_cpy_no_passthrough (buffer, stop_registers);
|
1047 |
|
|
return 0;
|
1048 |
|
|
}
|
1049 |
|
|
|
1050 |
|
|
/* Proceed until we reach a different source line with pc greater than
|
1051 |
|
|
our current one or exit the function. We skip calls in both cases.
|
1052 |
|
|
|
1053 |
|
|
Note that eventually this command should probably be changed so
|
1054 |
|
|
that only source lines are printed out when we hit the breakpoint
|
1055 |
|
|
we set. This may involve changes to wait_for_inferior and the
|
1056 |
|
|
proceed status code. */
|
1057 |
|
|
|
1058 |
|
|
/* ARGSUSED */
|
1059 |
|
|
static void
|
1060 |
|
|
until_next_command (int from_tty)
|
1061 |
|
|
{
|
1062 |
|
|
struct frame_info *frame;
|
1063 |
|
|
CORE_ADDR pc;
|
1064 |
|
|
struct symbol *func;
|
1065 |
|
|
struct symtab_and_line sal;
|
1066 |
|
|
|
1067 |
|
|
clear_proceed_status ();
|
1068 |
|
|
|
1069 |
|
|
frame = get_current_frame ();
|
1070 |
|
|
|
1071 |
|
|
/* Step until either exited from this function or greater
|
1072 |
|
|
than the current line (if in symbolic section) or pc (if
|
1073 |
|
|
not). */
|
1074 |
|
|
|
1075 |
|
|
pc = read_pc ();
|
1076 |
|
|
func = find_pc_function (pc);
|
1077 |
|
|
|
1078 |
|
|
if (!func)
|
1079 |
|
|
{
|
1080 |
|
|
struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
|
1081 |
|
|
|
1082 |
|
|
if (msymbol == NULL)
|
1083 |
|
|
error ("Execution is not within a known function.");
|
1084 |
|
|
|
1085 |
|
|
step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
|
1086 |
|
|
step_range_end = pc;
|
1087 |
|
|
}
|
1088 |
|
|
else
|
1089 |
|
|
{
|
1090 |
|
|
sal = find_pc_line (pc, 0);
|
1091 |
|
|
|
1092 |
|
|
step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
|
1093 |
|
|
step_range_end = sal.end;
|
1094 |
|
|
}
|
1095 |
|
|
|
1096 |
|
|
step_over_calls = STEP_OVER_ALL;
|
1097 |
|
|
step_frame_address = FRAME_FP (frame);
|
1098 |
|
|
step_sp = read_sp ();
|
1099 |
|
|
|
1100 |
|
|
step_multi = 0; /* Only one call to proceed */
|
1101 |
|
|
|
1102 |
|
|
proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
|
1103 |
|
|
}
|
1104 |
|
|
|
1105 |
|
|
static void
|
1106 |
|
|
until_command (char *arg, int from_tty)
|
1107 |
|
|
{
|
1108 |
|
|
int async_exec = 0;
|
1109 |
|
|
|
1110 |
|
|
if (!target_has_execution)
|
1111 |
|
|
error ("The program is not running.");
|
1112 |
|
|
|
1113 |
|
|
/* Find out whether we must run in the background. */
|
1114 |
|
|
if (arg != NULL)
|
1115 |
|
|
async_exec = strip_bg_char (&arg);
|
1116 |
|
|
|
1117 |
|
|
/* If we must run in the background, but the target can't do it,
|
1118 |
|
|
error out. */
|
1119 |
|
|
if (event_loop_p && async_exec && !target_can_async_p ())
|
1120 |
|
|
error ("Asynchronous execution not supported on this target.");
|
1121 |
|
|
|
1122 |
|
|
/* If we are not asked to run in the bg, then prepare to run in the
|
1123 |
|
|
foreground, synchronously. */
|
1124 |
|
|
if (event_loop_p && !async_exec && target_can_async_p ())
|
1125 |
|
|
{
|
1126 |
|
|
/* Simulate synchronous execution */
|
1127 |
|
|
async_disable_stdin ();
|
1128 |
|
|
}
|
1129 |
|
|
|
1130 |
|
|
if (arg)
|
1131 |
|
|
until_break_command (arg, from_tty);
|
1132 |
|
|
else
|
1133 |
|
|
until_next_command (from_tty);
|
1134 |
|
|
}
|
1135 |
|
|
|
1136 |
|
|
|
1137 |
|
|
/* Print the result of a function at the end of a 'finish' command. */
|
1138 |
|
|
static void
|
1139 |
|
|
print_return_value (int structure_return, struct type *value_type)
|
1140 |
|
|
{
|
1141 |
|
|
struct value *value;
|
1142 |
|
|
static struct ui_stream *stb = NULL;
|
1143 |
|
|
|
1144 |
|
|
if (!structure_return)
|
1145 |
|
|
{
|
1146 |
|
|
value = value_being_returned (value_type, stop_registers, structure_return);
|
1147 |
|
|
stb = ui_out_stream_new (uiout);
|
1148 |
|
|
ui_out_text (uiout, "Value returned is ");
|
1149 |
|
|
ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));
|
1150 |
|
|
ui_out_text (uiout, " = ");
|
1151 |
|
|
value_print (value, stb->stream, 0, Val_no_prettyprint);
|
1152 |
|
|
ui_out_field_stream (uiout, "return-value", stb);
|
1153 |
|
|
ui_out_text (uiout, "\n");
|
1154 |
|
|
}
|
1155 |
|
|
else
|
1156 |
|
|
{
|
1157 |
|
|
/* We cannot determine the contents of the structure because
|
1158 |
|
|
it is on the stack, and we don't know where, since we did not
|
1159 |
|
|
initiate the call, as opposed to the call_function_by_hand case */
|
1160 |
|
|
#ifdef VALUE_RETURNED_FROM_STACK
|
1161 |
|
|
value = 0;
|
1162 |
|
|
ui_out_text (uiout, "Value returned has type: ");
|
1163 |
|
|
ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
|
1164 |
|
|
ui_out_text (uiout, ".");
|
1165 |
|
|
ui_out_text (uiout, " Cannot determine contents\n");
|
1166 |
|
|
#else
|
1167 |
|
|
value = value_being_returned (value_type, stop_registers, structure_return);
|
1168 |
|
|
stb = ui_out_stream_new (uiout);
|
1169 |
|
|
ui_out_text (uiout, "Value returned is ");
|
1170 |
|
|
ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));
|
1171 |
|
|
ui_out_text (uiout, " = ");
|
1172 |
|
|
value_print (value, stb->stream, 0, Val_no_prettyprint);
|
1173 |
|
|
ui_out_field_stream (uiout, "return-value", stb);
|
1174 |
|
|
ui_out_text (uiout, "\n");
|
1175 |
|
|
#endif
|
1176 |
|
|
}
|
1177 |
|
|
}
|
1178 |
|
|
|
1179 |
|
|
/* Stuff that needs to be done by the finish command after the target
|
1180 |
|
|
has stopped. In asynchronous mode, we wait for the target to stop in
|
1181 |
|
|
the call to poll or select in the event loop, so it is impossible to
|
1182 |
|
|
do all the stuff as part of the finish_command function itself. The
|
1183 |
|
|
only chance we have to complete this command is in
|
1184 |
|
|
fetch_inferior_event, which is called by the event loop as soon as it
|
1185 |
|
|
detects that the target has stopped. This function is called via the
|
1186 |
|
|
cmd_continuation pointer. */
|
1187 |
|
|
void
|
1188 |
|
|
finish_command_continuation (struct continuation_arg *arg)
|
1189 |
|
|
{
|
1190 |
|
|
register struct symbol *function;
|
1191 |
|
|
struct breakpoint *breakpoint;
|
1192 |
|
|
struct cleanup *cleanups;
|
1193 |
|
|
|
1194 |
|
|
breakpoint = (struct breakpoint *) arg->data.pointer;
|
1195 |
|
|
function = (struct symbol *) arg->next->data.pointer;
|
1196 |
|
|
cleanups = (struct cleanup *) arg->next->next->data.pointer;
|
1197 |
|
|
|
1198 |
|
|
if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
|
1199 |
|
|
&& function != 0)
|
1200 |
|
|
{
|
1201 |
|
|
struct type *value_type;
|
1202 |
|
|
CORE_ADDR funcaddr;
|
1203 |
|
|
int struct_return;
|
1204 |
|
|
|
1205 |
|
|
value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
|
1206 |
|
|
if (!value_type)
|
1207 |
|
|
internal_error (__FILE__, __LINE__,
|
1208 |
|
|
"finish_command: function has no target type");
|
1209 |
|
|
|
1210 |
|
|
if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
|
1211 |
|
|
{
|
1212 |
|
|
do_exec_cleanups (cleanups);
|
1213 |
|
|
return;
|
1214 |
|
|
}
|
1215 |
|
|
|
1216 |
|
|
funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function));
|
1217 |
|
|
|
1218 |
|
|
struct_return = using_struct_return (value_of_variable (function, NULL),
|
1219 |
|
|
funcaddr,
|
1220 |
|
|
check_typedef (value_type),
|
1221 |
|
|
BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function)));
|
1222 |
|
|
|
1223 |
|
|
print_return_value (struct_return, value_type);
|
1224 |
|
|
}
|
1225 |
|
|
do_exec_cleanups (cleanups);
|
1226 |
|
|
}
|
1227 |
|
|
|
1228 |
|
|
/* "finish": Set a temporary breakpoint at the place
|
1229 |
|
|
the selected frame will return to, then continue. */
|
1230 |
|
|
|
1231 |
|
|
static void
|
1232 |
|
|
finish_command (char *arg, int from_tty)
|
1233 |
|
|
{
|
1234 |
|
|
struct symtab_and_line sal;
|
1235 |
|
|
register struct frame_info *frame;
|
1236 |
|
|
register struct symbol *function;
|
1237 |
|
|
struct breakpoint *breakpoint;
|
1238 |
|
|
struct cleanup *old_chain;
|
1239 |
|
|
struct continuation_arg *arg1, *arg2, *arg3;
|
1240 |
|
|
|
1241 |
|
|
int async_exec = 0;
|
1242 |
|
|
|
1243 |
|
|
/* Find out whether we must run in the background. */
|
1244 |
|
|
if (arg != NULL)
|
1245 |
|
|
async_exec = strip_bg_char (&arg);
|
1246 |
|
|
|
1247 |
|
|
/* If we must run in the background, but the target can't do it,
|
1248 |
|
|
error out. */
|
1249 |
|
|
if (event_loop_p && async_exec && !target_can_async_p ())
|
1250 |
|
|
error ("Asynchronous execution not supported on this target.");
|
1251 |
|
|
|
1252 |
|
|
/* If we are not asked to run in the bg, then prepare to run in the
|
1253 |
|
|
foreground, synchronously. */
|
1254 |
|
|
if (event_loop_p && !async_exec && target_can_async_p ())
|
1255 |
|
|
{
|
1256 |
|
|
/* Simulate synchronous execution */
|
1257 |
|
|
async_disable_stdin ();
|
1258 |
|
|
}
|
1259 |
|
|
|
1260 |
|
|
if (arg)
|
1261 |
|
|
error ("The \"finish\" command does not take any arguments.");
|
1262 |
|
|
if (!target_has_execution)
|
1263 |
|
|
error ("The program is not running.");
|
1264 |
|
|
if (selected_frame == NULL)
|
1265 |
|
|
error ("No selected frame.");
|
1266 |
|
|
|
1267 |
|
|
frame = get_prev_frame (selected_frame);
|
1268 |
|
|
if (frame == 0)
|
1269 |
|
|
error ("\"finish\" not meaningful in the outermost frame.");
|
1270 |
|
|
|
1271 |
|
|
clear_proceed_status ();
|
1272 |
|
|
|
1273 |
|
|
sal = find_pc_line (frame->pc, 0);
|
1274 |
|
|
sal.pc = frame->pc;
|
1275 |
|
|
|
1276 |
|
|
breakpoint = set_momentary_breakpoint (sal, frame, bp_finish);
|
1277 |
|
|
|
1278 |
|
|
if (!event_loop_p || !target_can_async_p ())
|
1279 |
|
|
old_chain = make_cleanup_delete_breakpoint (breakpoint);
|
1280 |
|
|
else
|
1281 |
|
|
old_chain = make_exec_cleanup_delete_breakpoint (breakpoint);
|
1282 |
|
|
|
1283 |
|
|
/* Find the function we will return from. */
|
1284 |
|
|
|
1285 |
|
|
function = find_pc_function (selected_frame->pc);
|
1286 |
|
|
|
1287 |
|
|
/* Print info on the selected frame, including level number
|
1288 |
|
|
but not source. */
|
1289 |
|
|
if (from_tty)
|
1290 |
|
|
{
|
1291 |
|
|
printf_filtered ("Run till exit from ");
|
1292 |
|
|
print_stack_frame (selected_frame,
|
1293 |
|
|
frame_relative_level (selected_frame), 0);
|
1294 |
|
|
}
|
1295 |
|
|
|
1296 |
|
|
/* If running asynchronously and the target support asynchronous
|
1297 |
|
|
execution, set things up for the rest of the finish command to be
|
1298 |
|
|
completed later on, when gdb has detected that the target has
|
1299 |
|
|
stopped, in fetch_inferior_event. */
|
1300 |
|
|
if (event_loop_p && target_can_async_p ())
|
1301 |
|
|
{
|
1302 |
|
|
arg1 =
|
1303 |
|
|
(struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
|
1304 |
|
|
arg2 =
|
1305 |
|
|
(struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
|
1306 |
|
|
arg3 =
|
1307 |
|
|
(struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
|
1308 |
|
|
arg1->next = arg2;
|
1309 |
|
|
arg2->next = arg3;
|
1310 |
|
|
arg3->next = NULL;
|
1311 |
|
|
arg1->data.pointer = breakpoint;
|
1312 |
|
|
arg2->data.pointer = function;
|
1313 |
|
|
arg3->data.pointer = old_chain;
|
1314 |
|
|
add_continuation (finish_command_continuation, arg1);
|
1315 |
|
|
}
|
1316 |
|
|
|
1317 |
|
|
proceed_to_finish = 1; /* We want stop_registers, please... */
|
1318 |
|
|
proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
|
1319 |
|
|
|
1320 |
|
|
/* Do this only if not running asynchronously or if the target
|
1321 |
|
|
cannot do async execution. Otherwise, complete this command when
|
1322 |
|
|
the target actually stops, in fetch_inferior_event. */
|
1323 |
|
|
if (!event_loop_p || !target_can_async_p ())
|
1324 |
|
|
{
|
1325 |
|
|
|
1326 |
|
|
/* Did we stop at our breakpoint? */
|
1327 |
|
|
if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
|
1328 |
|
|
&& function != 0)
|
1329 |
|
|
{
|
1330 |
|
|
struct type *value_type;
|
1331 |
|
|
CORE_ADDR funcaddr;
|
1332 |
|
|
int struct_return;
|
1333 |
|
|
|
1334 |
|
|
value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
|
1335 |
|
|
if (!value_type)
|
1336 |
|
|
internal_error (__FILE__, __LINE__,
|
1337 |
|
|
"finish_command: function has no target type");
|
1338 |
|
|
|
1339 |
|
|
/* FIXME: Shouldn't we do the cleanups before returning? */
|
1340 |
|
|
if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
|
1341 |
|
|
return;
|
1342 |
|
|
|
1343 |
|
|
funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function));
|
1344 |
|
|
|
1345 |
|
|
struct_return =
|
1346 |
|
|
using_struct_return (value_of_variable (function, NULL),
|
1347 |
|
|
funcaddr,
|
1348 |
|
|
check_typedef (value_type),
|
1349 |
|
|
BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function)));
|
1350 |
|
|
|
1351 |
|
|
print_return_value (struct_return, value_type);
|
1352 |
|
|
}
|
1353 |
|
|
do_cleanups (old_chain);
|
1354 |
|
|
}
|
1355 |
|
|
}
|
1356 |
|
|
|
1357 |
|
|
/* ARGSUSED */
|
1358 |
|
|
static void
|
1359 |
|
|
program_info (char *args, int from_tty)
|
1360 |
|
|
{
|
1361 |
|
|
bpstat bs = stop_bpstat;
|
1362 |
|
|
int num = bpstat_num (&bs);
|
1363 |
|
|
|
1364 |
|
|
if (!target_has_execution)
|
1365 |
|
|
{
|
1366 |
|
|
printf_filtered ("The program being debugged is not being run.\n");
|
1367 |
|
|
return;
|
1368 |
|
|
}
|
1369 |
|
|
|
1370 |
|
|
target_files_info ();
|
1371 |
|
|
printf_filtered ("Program stopped at %s.\n",
|
1372 |
|
|
local_hex_string ((unsigned long) stop_pc));
|
1373 |
|
|
if (stop_step)
|
1374 |
|
|
printf_filtered ("It stopped after being stepped.\n");
|
1375 |
|
|
else if (num != 0)
|
1376 |
|
|
{
|
1377 |
|
|
/* There may be several breakpoints in the same place, so this
|
1378 |
|
|
isn't as strange as it seems. */
|
1379 |
|
|
while (num != 0)
|
1380 |
|
|
{
|
1381 |
|
|
if (num < 0)
|
1382 |
|
|
{
|
1383 |
|
|
printf_filtered ("It stopped at a breakpoint that has ");
|
1384 |
|
|
printf_filtered ("since been deleted.\n");
|
1385 |
|
|
}
|
1386 |
|
|
else
|
1387 |
|
|
printf_filtered ("It stopped at breakpoint %d.\n", num);
|
1388 |
|
|
num = bpstat_num (&bs);
|
1389 |
|
|
}
|
1390 |
|
|
}
|
1391 |
|
|
else if (stop_signal != TARGET_SIGNAL_0)
|
1392 |
|
|
{
|
1393 |
|
|
printf_filtered ("It stopped with signal %s, %s.\n",
|
1394 |
|
|
target_signal_to_name (stop_signal),
|
1395 |
|
|
target_signal_to_string (stop_signal));
|
1396 |
|
|
}
|
1397 |
|
|
|
1398 |
|
|
if (!from_tty)
|
1399 |
|
|
{
|
1400 |
|
|
printf_filtered ("Type \"info stack\" or \"info registers\" ");
|
1401 |
|
|
printf_filtered ("for more information.\n");
|
1402 |
|
|
}
|
1403 |
|
|
}
|
1404 |
|
|
|
1405 |
|
|
static void
|
1406 |
|
|
environment_info (char *var, int from_tty)
|
1407 |
|
|
{
|
1408 |
|
|
if (var)
|
1409 |
|
|
{
|
1410 |
|
|
register char *val = get_in_environ (inferior_environ, var);
|
1411 |
|
|
if (val)
|
1412 |
|
|
{
|
1413 |
|
|
puts_filtered (var);
|
1414 |
|
|
puts_filtered (" = ");
|
1415 |
|
|
puts_filtered (val);
|
1416 |
|
|
puts_filtered ("\n");
|
1417 |
|
|
}
|
1418 |
|
|
else
|
1419 |
|
|
{
|
1420 |
|
|
puts_filtered ("Environment variable \"");
|
1421 |
|
|
puts_filtered (var);
|
1422 |
|
|
puts_filtered ("\" not defined.\n");
|
1423 |
|
|
}
|
1424 |
|
|
}
|
1425 |
|
|
else
|
1426 |
|
|
{
|
1427 |
|
|
register char **vector = environ_vector (inferior_environ);
|
1428 |
|
|
while (*vector)
|
1429 |
|
|
{
|
1430 |
|
|
puts_filtered (*vector++);
|
1431 |
|
|
puts_filtered ("\n");
|
1432 |
|
|
}
|
1433 |
|
|
}
|
1434 |
|
|
}
|
1435 |
|
|
|
1436 |
|
|
static void
|
1437 |
|
|
set_environment_command (char *arg, int from_tty)
|
1438 |
|
|
{
|
1439 |
|
|
register char *p, *val, *var;
|
1440 |
|
|
int nullset = 0;
|
1441 |
|
|
|
1442 |
|
|
if (arg == 0)
|
1443 |
|
|
error_no_arg ("environment variable and value");
|
1444 |
|
|
|
1445 |
|
|
/* Find seperation between variable name and value */
|
1446 |
|
|
p = (char *) strchr (arg, '=');
|
1447 |
|
|
val = (char *) strchr (arg, ' ');
|
1448 |
|
|
|
1449 |
|
|
if (p != 0 && val != 0)
|
1450 |
|
|
{
|
1451 |
|
|
/* We have both a space and an equals. If the space is before the
|
1452 |
|
|
equals, walk forward over the spaces til we see a nonspace
|
1453 |
|
|
(possibly the equals). */
|
1454 |
|
|
if (p > val)
|
1455 |
|
|
while (*val == ' ')
|
1456 |
|
|
val++;
|
1457 |
|
|
|
1458 |
|
|
/* Now if the = is after the char following the spaces,
|
1459 |
|
|
take the char following the spaces. */
|
1460 |
|
|
if (p > val)
|
1461 |
|
|
p = val - 1;
|
1462 |
|
|
}
|
1463 |
|
|
else if (val != 0 && p == 0)
|
1464 |
|
|
p = val;
|
1465 |
|
|
|
1466 |
|
|
if (p == arg)
|
1467 |
|
|
error_no_arg ("environment variable to set");
|
1468 |
|
|
|
1469 |
|
|
if (p == 0 || p[1] == 0)
|
1470 |
|
|
{
|
1471 |
|
|
nullset = 1;
|
1472 |
|
|
if (p == 0)
|
1473 |
|
|
p = arg + strlen (arg); /* So that savestring below will work */
|
1474 |
|
|
}
|
1475 |
|
|
else
|
1476 |
|
|
{
|
1477 |
|
|
/* Not setting variable value to null */
|
1478 |
|
|
val = p + 1;
|
1479 |
|
|
while (*val == ' ' || *val == '\t')
|
1480 |
|
|
val++;
|
1481 |
|
|
}
|
1482 |
|
|
|
1483 |
|
|
while (p != arg && (p[-1] == ' ' || p[-1] == '\t'))
|
1484 |
|
|
p--;
|
1485 |
|
|
|
1486 |
|
|
var = savestring (arg, p - arg);
|
1487 |
|
|
if (nullset)
|
1488 |
|
|
{
|
1489 |
|
|
printf_filtered ("Setting environment variable ");
|
1490 |
|
|
printf_filtered ("\"%s\" to null value.\n", var);
|
1491 |
|
|
set_in_environ (inferior_environ, var, "");
|
1492 |
|
|
}
|
1493 |
|
|
else
|
1494 |
|
|
set_in_environ (inferior_environ, var, val);
|
1495 |
|
|
xfree (var);
|
1496 |
|
|
}
|
1497 |
|
|
|
1498 |
|
|
static void
|
1499 |
|
|
unset_environment_command (char *var, int from_tty)
|
1500 |
|
|
{
|
1501 |
|
|
if (var == 0)
|
1502 |
|
|
{
|
1503 |
|
|
/* If there is no argument, delete all environment variables.
|
1504 |
|
|
Ask for confirmation if reading from the terminal. */
|
1505 |
|
|
if (!from_tty || query ("Delete all environment variables? "))
|
1506 |
|
|
{
|
1507 |
|
|
free_environ (inferior_environ);
|
1508 |
|
|
inferior_environ = make_environ ();
|
1509 |
|
|
}
|
1510 |
|
|
}
|
1511 |
|
|
else
|
1512 |
|
|
unset_in_environ (inferior_environ, var);
|
1513 |
|
|
}
|
1514 |
|
|
|
1515 |
|
|
/* Handle the execution path (PATH variable) */
|
1516 |
|
|
|
1517 |
|
|
static const char path_var_name[] = "PATH";
|
1518 |
|
|
|
1519 |
|
|
/* ARGSUSED */
|
1520 |
|
|
static void
|
1521 |
|
|
path_info (char *args, int from_tty)
|
1522 |
|
|
{
|
1523 |
|
|
puts_filtered ("Executable and object file path: ");
|
1524 |
|
|
puts_filtered (get_in_environ (inferior_environ, path_var_name));
|
1525 |
|
|
puts_filtered ("\n");
|
1526 |
|
|
}
|
1527 |
|
|
|
1528 |
|
|
/* Add zero or more directories to the front of the execution path. */
|
1529 |
|
|
|
1530 |
|
|
static void
|
1531 |
|
|
path_command (char *dirname, int from_tty)
|
1532 |
|
|
{
|
1533 |
|
|
char *exec_path;
|
1534 |
|
|
char *env;
|
1535 |
|
|
dont_repeat ();
|
1536 |
|
|
env = get_in_environ (inferior_environ, path_var_name);
|
1537 |
|
|
/* Can be null if path is not set */
|
1538 |
|
|
if (!env)
|
1539 |
|
|
env = "";
|
1540 |
|
|
exec_path = xstrdup (env);
|
1541 |
|
|
mod_path (dirname, &exec_path);
|
1542 |
|
|
set_in_environ (inferior_environ, path_var_name, exec_path);
|
1543 |
|
|
xfree (exec_path);
|
1544 |
|
|
if (from_tty)
|
1545 |
|
|
path_info ((char *) NULL, from_tty);
|
1546 |
|
|
}
|
1547 |
|
|
|
1548 |
|
|
|
1549 |
|
|
#ifdef REGISTER_NAMES
|
1550 |
|
|
char *gdb_register_names[] = REGISTER_NAMES;
|
1551 |
|
|
#endif
|
1552 |
|
|
/* Print out the machine register regnum. If regnum is -1, print all
|
1553 |
|
|
registers (print_all == 1) or all non-float and non-vector
|
1554 |
|
|
registers (print_all == 0).
|
1555 |
|
|
|
1556 |
|
|
For most machines, having all_registers_info() print the
|
1557 |
|
|
register(s) one per line is good enough. If a different format is
|
1558 |
|
|
required, (eg, for MIPS or Pyramid 90x, which both have lots of
|
1559 |
|
|
regs), or there is an existing convention for showing all the
|
1560 |
|
|
registers, define the architecture method PRINT_REGISTERS_INFO to
|
1561 |
|
|
provide that format. */
|
1562 |
|
|
|
1563 |
|
|
void
|
1564 |
|
|
default_print_registers_info (struct gdbarch *gdbarch,
|
1565 |
|
|
struct ui_file *file,
|
1566 |
|
|
struct frame_info *frame,
|
1567 |
|
|
int regnum, int print_all)
|
1568 |
|
|
{
|
1569 |
|
|
int i;
|
1570 |
|
|
const int numregs = NUM_REGS + NUM_PSEUDO_REGS;
|
1571 |
|
|
char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE);
|
1572 |
|
|
char *virtual_buffer = alloca (MAX_REGISTER_VIRTUAL_SIZE);
|
1573 |
|
|
|
1574 |
|
|
/* FIXME: cagney/2002-03-08: This should be deprecated. */
|
1575 |
|
|
if (DO_REGISTERS_INFO_P ())
|
1576 |
|
|
{
|
1577 |
|
|
DO_REGISTERS_INFO (regnum, print_all);
|
1578 |
|
|
return;
|
1579 |
|
|
}
|
1580 |
|
|
|
1581 |
|
|
for (i = 0; i < numregs; i++)
|
1582 |
|
|
{
|
1583 |
|
|
/* Decide between printing all regs, non-float / vector regs, or
|
1584 |
|
|
specific reg. */
|
1585 |
|
|
if (regnum == -1)
|
1586 |
|
|
{
|
1587 |
|
|
if (!print_all)
|
1588 |
|
|
{
|
1589 |
|
|
if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
|
1590 |
|
|
continue;
|
1591 |
|
|
if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (i)))
|
1592 |
|
|
continue;
|
1593 |
|
|
}
|
1594 |
|
|
}
|
1595 |
|
|
else
|
1596 |
|
|
{
|
1597 |
|
|
if (i != regnum)
|
1598 |
|
|
continue;
|
1599 |
|
|
}
|
1600 |
|
|
|
1601 |
|
|
/* If the register name is empty, it is undefined for this
|
1602 |
|
|
processor, so don't display anything. */
|
1603 |
|
|
if (REGISTER_NAME (i) == NULL || *(REGISTER_NAME (i)) == '\0')
|
1604 |
|
|
continue;
|
1605 |
|
|
|
1606 |
|
|
fputs_filtered (REGISTER_NAME (i), file);
|
1607 |
|
|
print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), file);
|
1608 |
|
|
|
1609 |
|
|
/* Get the data in raw format. */
|
1610 |
|
|
if (! frame_register_read (frame, i, raw_buffer))
|
1611 |
|
|
{
|
1612 |
|
|
fprintf_filtered (file, "*value not available*\n");
|
1613 |
|
|
continue;
|
1614 |
|
|
}
|
1615 |
|
|
|
1616 |
|
|
/* FIXME: cagney/2002-08-03: This code shouldn't be necessary.
|
1617 |
|
|
The function frame_register_read() should have returned the
|
1618 |
|
|
pre-cooked register so no conversion is necessary. */
|
1619 |
|
|
/* Convert raw data to virtual format if necessary. */
|
1620 |
|
|
if (REGISTER_CONVERTIBLE (i))
|
1621 |
|
|
{
|
1622 |
|
|
REGISTER_CONVERT_TO_VIRTUAL (i, REGISTER_VIRTUAL_TYPE (i),
|
1623 |
|
|
raw_buffer, virtual_buffer);
|
1624 |
|
|
}
|
1625 |
|
|
else
|
1626 |
|
|
{
|
1627 |
|
|
memcpy (virtual_buffer, raw_buffer,
|
1628 |
|
|
REGISTER_VIRTUAL_SIZE (i));
|
1629 |
|
|
}
|
1630 |
|
|
|
1631 |
|
|
/* If virtual format is floating, print it that way, and in raw
|
1632 |
|
|
hex. */
|
1633 |
|
|
if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
|
1634 |
|
|
{
|
1635 |
|
|
int j;
|
1636 |
|
|
|
1637 |
|
|
val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
|
1638 |
|
|
file, 0, 1, 0, Val_pretty_default);
|
1639 |
|
|
|
1640 |
|
|
fprintf_filtered (file, "\t(raw 0x");
|
1641 |
|
|
for (j = 0; j < REGISTER_RAW_SIZE (i); j++)
|
1642 |
|
|
{
|
1643 |
|
|
int idx;
|
1644 |
|
|
if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
|
1645 |
|
|
idx = j;
|
1646 |
|
|
else
|
1647 |
|
|
idx = REGISTER_RAW_SIZE (i) - 1 - j;
|
1648 |
|
|
fprintf_filtered (file, "%02x", (unsigned char) raw_buffer[idx]);
|
1649 |
|
|
}
|
1650 |
|
|
fprintf_filtered (file, ")");
|
1651 |
|
|
}
|
1652 |
|
|
else
|
1653 |
|
|
{
|
1654 |
|
|
/* Print the register in hex. */
|
1655 |
|
|
val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
|
1656 |
|
|
file, 'x', 1, 0, Val_pretty_default);
|
1657 |
|
|
/* If not a vector register, print it also according to its
|
1658 |
|
|
natural format. */
|
1659 |
|
|
if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (i)) == 0)
|
1660 |
|
|
{
|
1661 |
|
|
fprintf_filtered (file, "\t");
|
1662 |
|
|
val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
|
1663 |
|
|
file, 0, 1, 0, Val_pretty_default);
|
1664 |
|
|
}
|
1665 |
|
|
}
|
1666 |
|
|
|
1667 |
|
|
/* The SPARC wants to print even-numbered float regs as doubles
|
1668 |
|
|
in addition to printing them as floats. */
|
1669 |
|
|
#ifdef PRINT_REGISTER_HOOK
|
1670 |
|
|
PRINT_REGISTER_HOOK (i);
|
1671 |
|
|
#endif
|
1672 |
|
|
|
1673 |
|
|
fprintf_filtered (file, "\n");
|
1674 |
|
|
}
|
1675 |
|
|
}
|
1676 |
|
|
|
1677 |
|
|
void
|
1678 |
|
|
registers_info (char *addr_exp, int fpregs)
|
1679 |
|
|
{
|
1680 |
|
|
int regnum, numregs;
|
1681 |
|
|
register char *end;
|
1682 |
|
|
|
1683 |
|
|
if (!target_has_registers)
|
1684 |
|
|
error ("The program has no registers now.");
|
1685 |
|
|
if (selected_frame == NULL)
|
1686 |
|
|
error ("No selected frame.");
|
1687 |
|
|
|
1688 |
|
|
if (!addr_exp)
|
1689 |
|
|
{
|
1690 |
|
|
gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
|
1691 |
|
|
selected_frame, -1, fpregs);
|
1692 |
|
|
return;
|
1693 |
|
|
}
|
1694 |
|
|
|
1695 |
|
|
do
|
1696 |
|
|
{
|
1697 |
|
|
if (addr_exp[0] == '$')
|
1698 |
|
|
addr_exp++;
|
1699 |
|
|
end = addr_exp;
|
1700 |
|
|
while (*end != '\0' && *end != ' ' && *end != '\t')
|
1701 |
|
|
++end;
|
1702 |
|
|
numregs = NUM_REGS + NUM_PSEUDO_REGS;
|
1703 |
|
|
|
1704 |
|
|
regnum = frame_map_name_to_regnum (addr_exp, end - addr_exp);
|
1705 |
|
|
if (regnum >= 0)
|
1706 |
|
|
goto found;
|
1707 |
|
|
|
1708 |
|
|
regnum = numregs;
|
1709 |
|
|
|
1710 |
|
|
if (*addr_exp >= '0' && *addr_exp <= '9')
|
1711 |
|
|
regnum = atoi (addr_exp); /* Take a number */
|
1712 |
|
|
if (regnum >= numregs) /* Bad name, or bad number */
|
1713 |
|
|
error ("%.*s: invalid register", (int) (end - addr_exp), addr_exp);
|
1714 |
|
|
|
1715 |
|
|
found:
|
1716 |
|
|
gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
|
1717 |
|
|
selected_frame, regnum, fpregs);
|
1718 |
|
|
|
1719 |
|
|
addr_exp = end;
|
1720 |
|
|
while (*addr_exp == ' ' || *addr_exp == '\t')
|
1721 |
|
|
++addr_exp;
|
1722 |
|
|
}
|
1723 |
|
|
while (*addr_exp != '\0');
|
1724 |
|
|
}
|
1725 |
|
|
|
1726 |
|
|
void
|
1727 |
|
|
all_registers_info (char *addr_exp, int from_tty)
|
1728 |
|
|
{
|
1729 |
|
|
registers_info (addr_exp, 1);
|
1730 |
|
|
}
|
1731 |
|
|
|
1732 |
|
|
void
|
1733 |
|
|
nofp_registers_info (char *addr_exp, int from_tty)
|
1734 |
|
|
{
|
1735 |
|
|
registers_info (addr_exp, 0);
|
1736 |
|
|
}
|
1737 |
|
|
|
1738 |
|
|
static void
|
1739 |
|
|
print_vector_info (struct gdbarch *gdbarch, struct ui_file *file,
|
1740 |
|
|
struct frame_info *frame, const char *args)
|
1741 |
|
|
{
|
1742 |
|
|
if (gdbarch_print_vector_info_p (gdbarch))
|
1743 |
|
|
gdbarch_print_vector_info (gdbarch, file, frame, args);
|
1744 |
|
|
else
|
1745 |
|
|
{
|
1746 |
|
|
int regnum;
|
1747 |
|
|
int printed_something = 0;
|
1748 |
|
|
|
1749 |
|
|
if (!target_has_registers)
|
1750 |
|
|
error ("The program has no registers now.");
|
1751 |
|
|
if (selected_frame == NULL)
|
1752 |
|
|
error ("No selected frame.");
|
1753 |
|
|
|
1754 |
|
|
for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
|
1755 |
|
|
{
|
1756 |
|
|
if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (regnum)))
|
1757 |
|
|
{
|
1758 |
|
|
printed_something = 1;
|
1759 |
|
|
gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
|
1760 |
|
|
}
|
1761 |
|
|
}
|
1762 |
|
|
if (!printed_something)
|
1763 |
|
|
fprintf_filtered (file, "No vector information\n");
|
1764 |
|
|
}
|
1765 |
|
|
}
|
1766 |
|
|
|
1767 |
|
|
static void
|
1768 |
|
|
vector_info (char *args, int from_tty)
|
1769 |
|
|
{
|
1770 |
|
|
print_vector_info (current_gdbarch, gdb_stdout, selected_frame, args);
|
1771 |
|
|
}
|
1772 |
|
|
|
1773 |
|
|
|
1774 |
|
|
/*
|
1775 |
|
|
* TODO:
|
1776 |
|
|
* Should save/restore the tty state since it might be that the
|
1777 |
|
|
* program to be debugged was started on this tty and it wants
|
1778 |
|
|
* the tty in some state other than what we want. If it's running
|
1779 |
|
|
* on another terminal or without a terminal, then saving and
|
1780 |
|
|
* restoring the tty state is a harmless no-op.
|
1781 |
|
|
* This only needs to be done if we are attaching to a process.
|
1782 |
|
|
*/
|
1783 |
|
|
|
1784 |
|
|
/*
|
1785 |
|
|
attach_command --
|
1786 |
|
|
takes a program started up outside of gdb and ``attaches'' to it.
|
1787 |
|
|
This stops it cold in its tracks and allows us to start debugging it.
|
1788 |
|
|
and wait for the trace-trap that results from attaching. */
|
1789 |
|
|
|
1790 |
|
|
void
|
1791 |
|
|
attach_command (char *args, int from_tty)
|
1792 |
|
|
{
|
1793 |
|
|
char *exec_file;
|
1794 |
|
|
char *full_exec_path = NULL;
|
1795 |
|
|
|
1796 |
|
|
dont_repeat (); /* Not for the faint of heart */
|
1797 |
|
|
|
1798 |
|
|
if (target_has_execution)
|
1799 |
|
|
{
|
1800 |
|
|
if (query ("A program is being debugged already. Kill it? "))
|
1801 |
|
|
target_kill ();
|
1802 |
|
|
else
|
1803 |
|
|
error ("Not killed.");
|
1804 |
|
|
}
|
1805 |
|
|
|
1806 |
|
|
target_attach (args, from_tty);
|
1807 |
|
|
|
1808 |
|
|
/* Set up the "saved terminal modes" of the inferior
|
1809 |
|
|
based on what modes we are starting it with. */
|
1810 |
|
|
target_terminal_init ();
|
1811 |
|
|
|
1812 |
|
|
/* Install inferior's terminal modes. */
|
1813 |
|
|
target_terminal_inferior ();
|
1814 |
|
|
|
1815 |
|
|
/* Set up execution context to know that we should return from
|
1816 |
|
|
wait_for_inferior as soon as the target reports a stop. */
|
1817 |
|
|
init_wait_for_inferior ();
|
1818 |
|
|
clear_proceed_status ();
|
1819 |
|
|
|
1820 |
|
|
/* No traps are generated when attaching to inferior under Mach 3
|
1821 |
|
|
or GNU hurd. */
|
1822 |
|
|
#ifndef ATTACH_NO_WAIT
|
1823 |
|
|
stop_soon_quietly = 1;
|
1824 |
|
|
wait_for_inferior ();
|
1825 |
|
|
#endif
|
1826 |
|
|
|
1827 |
|
|
/*
|
1828 |
|
|
* If no exec file is yet known, try to determine it from the
|
1829 |
|
|
* process itself.
|
1830 |
|
|
*/
|
1831 |
|
|
exec_file = (char *) get_exec_file (0);
|
1832 |
|
|
if (!exec_file)
|
1833 |
|
|
{
|
1834 |
|
|
exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid));
|
1835 |
|
|
if (exec_file)
|
1836 |
|
|
{
|
1837 |
|
|
/* It's possible we don't have a full path, but rather just a
|
1838 |
|
|
filename. Some targets, such as HP-UX, don't provide the
|
1839 |
|
|
full path, sigh.
|
1840 |
|
|
|
1841 |
|
|
Attempt to qualify the filename against the source path.
|
1842 |
|
|
(If that fails, we'll just fall back on the original
|
1843 |
|
|
filename. Not much more we can do...)
|
1844 |
|
|
*/
|
1845 |
|
|
if (!source_full_path_of (exec_file, &full_exec_path))
|
1846 |
|
|
full_exec_path = savestring (exec_file, strlen (exec_file));
|
1847 |
|
|
|
1848 |
|
|
exec_file_attach (full_exec_path, from_tty);
|
1849 |
|
|
symbol_file_add_main (full_exec_path, from_tty);
|
1850 |
|
|
}
|
1851 |
|
|
}
|
1852 |
|
|
|
1853 |
|
|
#ifdef SOLIB_ADD
|
1854 |
|
|
/* Add shared library symbols from the newly attached process, if any. */
|
1855 |
|
|
SOLIB_ADD ((char *) 0, from_tty, ¤t_target, auto_solib_add);
|
1856 |
|
|
re_enable_breakpoints_in_shlibs ();
|
1857 |
|
|
#endif
|
1858 |
|
|
|
1859 |
|
|
/* Take any necessary post-attaching actions for this platform.
|
1860 |
|
|
*/
|
1861 |
|
|
target_post_attach (PIDGET (inferior_ptid));
|
1862 |
|
|
|
1863 |
|
|
normal_stop ();
|
1864 |
|
|
|
1865 |
|
|
if (attach_hook)
|
1866 |
|
|
attach_hook ();
|
1867 |
|
|
}
|
1868 |
|
|
|
1869 |
|
|
/*
|
1870 |
|
|
* detach_command --
|
1871 |
|
|
* takes a program previously attached to and detaches it.
|
1872 |
|
|
* The program resumes execution and will no longer stop
|
1873 |
|
|
* on signals, etc. We better not have left any breakpoints
|
1874 |
|
|
* in the program or it'll die when it hits one. For this
|
1875 |
|
|
* to work, it may be necessary for the process to have been
|
1876 |
|
|
* previously attached. It *might* work if the program was
|
1877 |
|
|
* started via the normal ptrace (PTRACE_TRACEME).
|
1878 |
|
|
*/
|
1879 |
|
|
|
1880 |
|
|
static void
|
1881 |
|
|
detach_command (char *args, int from_tty)
|
1882 |
|
|
{
|
1883 |
|
|
dont_repeat (); /* Not for the faint of heart */
|
1884 |
|
|
target_detach (args, from_tty);
|
1885 |
|
|
#if defined(SOLIB_RESTART)
|
1886 |
|
|
SOLIB_RESTART ();
|
1887 |
|
|
#endif
|
1888 |
|
|
if (detach_hook)
|
1889 |
|
|
detach_hook ();
|
1890 |
|
|
}
|
1891 |
|
|
|
1892 |
|
|
/* Stop the execution of the target while running in async mode, in
|
1893 |
|
|
the backgound. */
|
1894 |
|
|
|
1895 |
|
|
void
|
1896 |
|
|
interrupt_target_command_wrapper (char *args, int from_tty)
|
1897 |
|
|
{
|
1898 |
|
|
interrupt_target_command (args, from_tty);
|
1899 |
|
|
}
|
1900 |
|
|
|
1901 |
|
|
static void
|
1902 |
|
|
interrupt_target_command (char *args, int from_tty)
|
1903 |
|
|
{
|
1904 |
|
|
if (event_loop_p && target_can_async_p ())
|
1905 |
|
|
{
|
1906 |
|
|
dont_repeat (); /* Not for the faint of heart */
|
1907 |
|
|
target_stop ();
|
1908 |
|
|
}
|
1909 |
|
|
}
|
1910 |
|
|
|
1911 |
|
|
/* ARGSUSED */
|
1912 |
|
|
static void
|
1913 |
|
|
print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
|
1914 |
|
|
struct frame_info *frame, const char *args)
|
1915 |
|
|
{
|
1916 |
|
|
if (gdbarch_print_float_info_p (gdbarch))
|
1917 |
|
|
gdbarch_print_float_info (gdbarch, file, frame, args);
|
1918 |
|
|
else
|
1919 |
|
|
{
|
1920 |
|
|
#ifdef FLOAT_INFO
|
1921 |
|
|
#if GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL
|
1922 |
|
|
#error "FLOAT_INFO defined in multi-arch"
|
1923 |
|
|
#endif
|
1924 |
|
|
FLOAT_INFO;
|
1925 |
|
|
#else
|
1926 |
|
|
int regnum;
|
1927 |
|
|
int printed_something = 0;
|
1928 |
|
|
|
1929 |
|
|
if (!target_has_registers)
|
1930 |
|
|
error ("The program has no registers now.");
|
1931 |
|
|
if (selected_frame == NULL)
|
1932 |
|
|
error ("No selected frame.");
|
1933 |
|
|
|
1934 |
|
|
for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
|
1935 |
|
|
{
|
1936 |
|
|
if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT)
|
1937 |
|
|
{
|
1938 |
|
|
printed_something = 1;
|
1939 |
|
|
gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
|
1940 |
|
|
}
|
1941 |
|
|
}
|
1942 |
|
|
if (!printed_something)
|
1943 |
|
|
fprintf_filtered (file, "\
|
1944 |
|
|
No floating-point info available for this processor.\n");
|
1945 |
|
|
#endif
|
1946 |
|
|
}
|
1947 |
|
|
}
|
1948 |
|
|
|
1949 |
|
|
static void
|
1950 |
|
|
float_info (char *args, int from_tty)
|
1951 |
|
|
{
|
1952 |
|
|
print_float_info (current_gdbarch, gdb_stdout, selected_frame, args);
|
1953 |
|
|
}
|
1954 |
|
|
|
1955 |
|
|
/* ARGSUSED */
|
1956 |
|
|
static void
|
1957 |
|
|
unset_command (char *args, int from_tty)
|
1958 |
|
|
{
|
1959 |
|
|
printf_filtered ("\"unset\" must be followed by the name of ");
|
1960 |
|
|
printf_filtered ("an unset subcommand.\n");
|
1961 |
|
|
help_list (unsetlist, "unset ", -1, gdb_stdout);
|
1962 |
|
|
}
|
1963 |
|
|
|
1964 |
|
|
void
|
1965 |
|
|
_initialize_infcmd (void)
|
1966 |
|
|
{
|
1967 |
|
|
struct cmd_list_element *c;
|
1968 |
|
|
|
1969 |
|
|
c = add_com ("tty", class_run, tty_command,
|
1970 |
|
|
"Set terminal for future runs of program being debugged.");
|
1971 |
|
|
set_cmd_completer (c, filename_completer);
|
1972 |
|
|
|
1973 |
|
|
c = add_set_cmd ("args", class_run, var_string_noescape,
|
1974 |
|
|
(char *) &inferior_args,
|
1975 |
|
|
"Set argument list to give program being debugged when it is started.\n\
|
1976 |
|
|
Follow this command with any number of args, to be passed to the program.",
|
1977 |
|
|
&setlist);
|
1978 |
|
|
set_cmd_completer (c, filename_completer);
|
1979 |
|
|
set_cmd_sfunc (c, notice_args_set);
|
1980 |
|
|
c = add_show_from_set (c, &showlist);
|
1981 |
|
|
set_cmd_sfunc (c, notice_args_read);
|
1982 |
|
|
|
1983 |
|
|
c = add_cmd
|
1984 |
|
|
("environment", no_class, environment_info,
|
1985 |
|
|
"The environment to give the program, or one variable's value.\n\
|
1986 |
|
|
With an argument VAR, prints the value of environment variable VAR to\n\
|
1987 |
|
|
give the program being debugged. With no arguments, prints the entire\n\
|
1988 |
|
|
environment to be given to the program.", &showlist);
|
1989 |
|
|
set_cmd_completer (c, noop_completer);
|
1990 |
|
|
|
1991 |
|
|
add_prefix_cmd ("unset", no_class, unset_command,
|
1992 |
|
|
"Complement to certain \"set\" commands.",
|
1993 |
|
|
&unsetlist, "unset ", 0, &cmdlist);
|
1994 |
|
|
|
1995 |
|
|
c = add_cmd ("environment", class_run, unset_environment_command,
|
1996 |
|
|
"Cancel environment variable VAR for the program.\n\
|
1997 |
|
|
This does not affect the program until the next \"run\" command.",
|
1998 |
|
|
&unsetlist);
|
1999 |
|
|
set_cmd_completer (c, noop_completer);
|
2000 |
|
|
|
2001 |
|
|
c = add_cmd ("environment", class_run, set_environment_command,
|
2002 |
|
|
"Set environment variable value to give the program.\n\
|
2003 |
|
|
Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
|
2004 |
|
|
VALUES of environment variables are uninterpreted strings.\n\
|
2005 |
|
|
This does not affect the program until the next \"run\" command.",
|
2006 |
|
|
&setlist);
|
2007 |
|
|
set_cmd_completer (c, noop_completer);
|
2008 |
|
|
|
2009 |
|
|
c = add_com ("path", class_files, path_command,
|
2010 |
|
|
"Add directory DIR(s) to beginning of search path for object files.\n\
|
2011 |
|
|
$cwd in the path means the current working directory.\n\
|
2012 |
|
|
This path is equivalent to the $PATH shell variable. It is a list of\n\
|
2013 |
|
|
directories, separated by colons. These directories are searched to find\n\
|
2014 |
|
|
fully linked executable files and separately compiled object files as needed.");
|
2015 |
|
|
set_cmd_completer (c, filename_completer);
|
2016 |
|
|
|
2017 |
|
|
c = add_cmd ("paths", no_class, path_info,
|
2018 |
|
|
"Current search path for finding object files.\n\
|
2019 |
|
|
$cwd in the path means the current working directory.\n\
|
2020 |
|
|
This path is equivalent to the $PATH shell variable. It is a list of\n\
|
2021 |
|
|
directories, separated by colons. These directories are searched to find\n\
|
2022 |
|
|
fully linked executable files and separately compiled object files as needed.",
|
2023 |
|
|
&showlist);
|
2024 |
|
|
set_cmd_completer (c, noop_completer);
|
2025 |
|
|
|
2026 |
|
|
add_com ("attach", class_run, attach_command,
|
2027 |
|
|
"Attach to a process or file outside of GDB.\n\
|
2028 |
|
|
This command attaches to another target, of the same type as your last\n\
|
2029 |
|
|
\"target\" command (\"info files\" will show your target stack).\n\
|
2030 |
|
|
The command may take as argument a process id or a device file.\n\
|
2031 |
|
|
For a process id, you must have permission to send the process a signal,\n\
|
2032 |
|
|
and it must have the same effective uid as the debugger.\n\
|
2033 |
|
|
When using \"attach\" with a process id, the debugger finds the\n\
|
2034 |
|
|
program running in the process, looking first in the current working\n\
|
2035 |
|
|
directory, or (if not found there) using the source file search path\n\
|
2036 |
|
|
(see the \"directory\" command). You can also use the \"file\" command\n\
|
2037 |
|
|
to specify the program, and to load its symbol table.");
|
2038 |
|
|
|
2039 |
|
|
add_com ("detach", class_run, detach_command,
|
2040 |
|
|
"Detach a process or file previously attached.\n\
|
2041 |
|
|
If a process, it is no longer traced, and it continues its execution. If\n\
|
2042 |
|
|
you were debugging a file, the file is closed and gdb no longer accesses it.");
|
2043 |
|
|
|
2044 |
|
|
add_com ("signal", class_run, signal_command,
|
2045 |
|
|
"Continue program giving it signal specified by the argument.\n\
|
2046 |
|
|
An argument of \"0\" means continue program without giving it a signal.");
|
2047 |
|
|
|
2048 |
|
|
add_com ("stepi", class_run, stepi_command,
|
2049 |
|
|
"Step one instruction exactly.\n\
|
2050 |
|
|
Argument N means do this N times (or till program stops for another reason).");
|
2051 |
|
|
add_com_alias ("si", "stepi", class_alias, 0);
|
2052 |
|
|
|
2053 |
|
|
add_com ("nexti", class_run, nexti_command,
|
2054 |
|
|
"Step one instruction, but proceed through subroutine calls.\n\
|
2055 |
|
|
Argument N means do this N times (or till program stops for another reason).");
|
2056 |
|
|
add_com_alias ("ni", "nexti", class_alias, 0);
|
2057 |
|
|
|
2058 |
|
|
add_com ("finish", class_run, finish_command,
|
2059 |
|
|
"Execute until selected stack frame returns.\n\
|
2060 |
|
|
Upon return, the value returned is printed and put in the value history.");
|
2061 |
|
|
|
2062 |
|
|
add_com ("next", class_run, next_command,
|
2063 |
|
|
"Step program, proceeding through subroutine calls.\n\
|
2064 |
|
|
Like the \"step\" command as long as subroutine calls do not happen;\n\
|
2065 |
|
|
when they do, the call is treated as one instruction.\n\
|
2066 |
|
|
Argument N means do this N times (or till program stops for another reason).");
|
2067 |
|
|
add_com_alias ("n", "next", class_run, 1);
|
2068 |
|
|
if (xdb_commands)
|
2069 |
|
|
add_com_alias ("S", "next", class_run, 1);
|
2070 |
|
|
|
2071 |
|
|
add_com ("step", class_run, step_command,
|
2072 |
|
|
"Step program until it reaches a different source line.\n\
|
2073 |
|
|
Argument N means do this N times (or till program stops for another reason).");
|
2074 |
|
|
add_com_alias ("s", "step", class_run, 1);
|
2075 |
|
|
|
2076 |
|
|
c = add_com ("until", class_run, until_command,
|
2077 |
|
|
"Execute until the program reaches a source line greater than the current\n\
|
2078 |
|
|
or a specified line or address or function (same args as break command).\n\
|
2079 |
|
|
Execution will also stop upon exit from the current stack frame.");
|
2080 |
|
|
set_cmd_completer (c, location_completer);
|
2081 |
|
|
add_com_alias ("u", "until", class_run, 1);
|
2082 |
|
|
|
2083 |
|
|
c = add_com ("jump", class_run, jump_command,
|
2084 |
|
|
"Continue program being debugged at specified line or address.\n\
|
2085 |
|
|
Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
|
2086 |
|
|
for an address to start at.");
|
2087 |
|
|
set_cmd_completer (c, location_completer);
|
2088 |
|
|
|
2089 |
|
|
if (xdb_commands)
|
2090 |
|
|
{
|
2091 |
|
|
c = add_com ("go", class_run, go_command,
|
2092 |
|
|
"Usage: go <location>\n\
|
2093 |
|
|
Continue program being debugged, stopping at specified line or \n\
|
2094 |
|
|
address.\n\
|
2095 |
|
|
Give as argument either LINENUM or *ADDR, where ADDR is an \n\
|
2096 |
|
|
expression for an address to start at.\n\
|
2097 |
|
|
This command is a combination of tbreak and jump.");
|
2098 |
|
|
set_cmd_completer (c, location_completer);
|
2099 |
|
|
}
|
2100 |
|
|
|
2101 |
|
|
if (xdb_commands)
|
2102 |
|
|
add_com_alias ("g", "go", class_run, 1);
|
2103 |
|
|
|
2104 |
|
|
add_com ("continue", class_run, continue_command,
|
2105 |
|
|
"Continue program being debugged, after signal or breakpoint.\n\
|
2106 |
|
|
If proceeding from breakpoint, a number N may be used as an argument,\n\
|
2107 |
|
|
which means to set the ignore count of that breakpoint to N - 1 (so that\n\
|
2108 |
|
|
the breakpoint won't break until the Nth time it is reached).");
|
2109 |
|
|
add_com_alias ("c", "cont", class_run, 1);
|
2110 |
|
|
add_com_alias ("fg", "cont", class_run, 1);
|
2111 |
|
|
|
2112 |
|
|
c = add_com ("run", class_run, run_command,
|
2113 |
|
|
"Start debugged program. You may specify arguments to give it.\n\
|
2114 |
|
|
Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
|
2115 |
|
|
Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
|
2116 |
|
|
With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
|
2117 |
|
|
To cancel previous arguments and run with no arguments,\n\
|
2118 |
|
|
use \"set args\" without arguments.");
|
2119 |
|
|
set_cmd_completer (c, filename_completer);
|
2120 |
|
|
add_com_alias ("r", "run", class_run, 1);
|
2121 |
|
|
if (xdb_commands)
|
2122 |
|
|
add_com ("R", class_run, run_no_args_command,
|
2123 |
|
|
"Start debugged program with no arguments.");
|
2124 |
|
|
|
2125 |
|
|
add_com ("interrupt", class_run, interrupt_target_command,
|
2126 |
|
|
"Interrupt the execution of the debugged program.");
|
2127 |
|
|
|
2128 |
|
|
add_info ("registers", nofp_registers_info,
|
2129 |
|
|
"List of integer registers and their contents, for selected stack frame.\n\
|
2130 |
|
|
Register name as argument means describe only that register.");
|
2131 |
|
|
add_info_alias ("r", "registers", 1);
|
2132 |
|
|
|
2133 |
|
|
if (xdb_commands)
|
2134 |
|
|
add_com ("lr", class_info, nofp_registers_info,
|
2135 |
|
|
"List of integer registers and their contents, for selected stack frame.\n\
|
2136 |
|
|
Register name as argument means describe only that register.");
|
2137 |
|
|
add_info ("all-registers", all_registers_info,
|
2138 |
|
|
"List of all registers and their contents, for selected stack frame.\n\
|
2139 |
|
|
Register name as argument means describe only that register.");
|
2140 |
|
|
|
2141 |
|
|
add_info ("program", program_info,
|
2142 |
|
|
"Execution status of the program.");
|
2143 |
|
|
|
2144 |
|
|
add_info ("float", float_info,
|
2145 |
|
|
"Print the status of the floating point unit\n");
|
2146 |
|
|
|
2147 |
|
|
add_info ("vector", vector_info,
|
2148 |
|
|
"Print the status of the vector unit\n");
|
2149 |
|
|
|
2150 |
|
|
inferior_environ = make_environ ();
|
2151 |
|
|
init_environ (inferior_environ);
|
2152 |
|
|
}
|