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., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 #include <sys/param.h>
28 #include <sys/ioctl.h>
32 #include <sys/ptrace.h>
33 #define PTRACE_ATTACH PT_ATTACH
34 #define PTRACE_DETACH PT_FREEPROC
39 /* Work with core dump and executable files, for GDB.
40 This code would be in core.c if it weren't machine-dependent. */
43 core_file_command (filename
, from_tty
)
48 extern char registers
[];
50 /* Discard all vestiges of any previous core file
51 and mark data and stack spaces as empty. */
63 stack_start
= STACK_END_ADDR
;
64 stack_end
= STACK_END_ADDR
;
66 /* Now, if a new core file was specified, open it and digest it. */
70 filename
= tilde_expand (filename
);
71 make_cleanup (free
, filename
);
73 if (have_inferior_p ())
74 error ("To look at a core file, you must kill the inferior with \"kill\".");
75 corechan
= open (filename
, O_RDONLY
, 0);
77 perror_with_name (filename
);
78 /* 4.2-style (and perhaps also sysV-style) core dump file. */
83 val
= myread (corechan
, &u
, sizeof u
);
85 perror_with_name (filename
);
86 data_start
= exec_data_start
;
88 data_end
= data_start
+ u
.pt_dsize
;
89 stack_start
= stack_end
- u
.pt_ssize
;
90 data_offset
= sizeof u
;
91 stack_offset
= data_offset
+ u
.pt_dsize
;
94 bcopy (&u
.pt_aouthdr
, &core_aouthdr
, sizeof (AOUTHDR
));
95 printf ("Core file is from \"%s\".\n", u
.pt_comm
);
97 printf ("Program terminated with signal %d, %s.\n",
100 ? sys_siglist
[u
.pt_signal
]
103 /* Read the register values out of the core file and store
104 them where `read_register' will find them. */
109 for (regno
= 0; regno
< NUM_REGS
; regno
++)
111 char buf
[MAX_REGISTER_RAW_SIZE
];
113 val
= lseek (corechan
, register_addr (regno
, reg_offset
), 0);
115 perror_with_name (filename
);
117 val
= myread (corechan
, buf
, sizeof buf
);
119 perror_with_name (filename
);
120 supply_register (regno
, buf
);
124 if (filename
[0] == '/')
125 corefile
= savestring (filename
, strlen (filename
));
128 corefile
= concat (current_directory
, "/", filename
, NULL
);
131 set_current_frame ( create_new_frame (read_register (FP_REGNUM
),
133 select_frame (get_current_frame (), 0);
137 printf ("No core file now.\n");
This page took 0.039865 seconds and 4 git commands to generate.