2 Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 #include <sys/param.h>
27 #include <sys/ioctl.h>
31 #include <sys/ptrace.h>
32 #define PTRACE_ATTACH PT_ATTACH
33 #define PTRACE_DETACH PT_FREEPROC
38 /* Work with core dump and executable files, for GDB.
39 This code would be in corefile.c if it weren't machine-dependent. */
42 core_file_command (filename
, from_tty
)
48 /* Discard all vestiges of any previous core file
49 and mark data and stack spaces as empty. */
61 stack_start
= STACK_END_ADDR
;
62 stack_end
= STACK_END_ADDR
;
64 /* Now, if a new core file was specified, open it and digest it. */
68 filename
= tilde_expand (filename
);
69 make_cleanup (free
, filename
);
71 if (have_inferior_p ())
72 error ("To look at a core file, you must kill the program with \"kill\".");
73 corechan
= open (filename
, O_RDONLY
, 0);
75 perror_with_name (filename
);
76 /* 4.2-style (and perhaps also sysV-style) core dump file. */
81 val
= myread (corechan
, &u
, sizeof u
);
83 perror_with_name (filename
);
84 data_start
= exec_data_start
;
86 data_end
= data_start
+ u
.pt_dsize
;
87 stack_start
= stack_end
- u
.pt_ssize
;
88 data_offset
= sizeof u
;
89 stack_offset
= data_offset
+ u
.pt_dsize
;
92 memcpy (&core_aouthdr
, &u
.pt_aouthdr
, sizeof (AOUTHDR
));
93 printf_unfiltered ("Core file is from \"%s\".\n", u
.pt_comm
);
95 printf_unfiltered ("Program terminated with signal %d, %s.\n",
96 u
.pt_signal
, safe_strsignal (u
.pt_signal
));
98 /* Read the register values out of the core file and store
99 them where `read_register' will find them. */
104 for (regno
= 0; regno
< NUM_REGS
; regno
++)
106 char buf
[MAX_REGISTER_RAW_SIZE
];
108 val
= lseek (corechan
, register_addr (regno
, reg_offset
), 0);
110 perror_with_name (filename
);
112 val
= myread (corechan
, buf
, sizeof buf
);
114 perror_with_name (filename
);
115 supply_register (regno
, buf
);
119 if (filename
[0] == '/')
120 corefile
= savestring (filename
, strlen (filename
));
123 corefile
= concat (current_directory
, "/", filename
, NULL
);
126 flush_cached_frames ();
127 select_frame (get_current_frame (), 0);
131 printf_unfiltered ("No core file now.\n");
This page took 0.033123 seconds and 5 git commands to generate.