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