[comp.unix.questions] Restarting a process from a core file

carl@neocad.com (Carl Stern) (05/02/91)

     Ideally what I'd like to do is to be able to save the state of a
process at a given point in time and then restart it for debugging purposes.
I thought I could send it a signal to dump core, (I've tried QUIT, ABRT, TRAP),
and then use dbx to debug the core file.  I can't continue execution though,
which is what I want to be able to do.  I believe this is because there is
no active process for dbx to debug.  So is there a way, or an existing program,
that can take a core file and use it to initialize a process and run it?
i.e. reload the core file and restart it as a process.
If not, why not?

The main reason I want to do this is I have a bug that occurs after about 
30-40 minutes of run time.  Obviusly it would be nice to restart at time
T=30 instead of T=0 when bringing it around again to find the bug.

I'm using Sun OS 4.1.1 on a sparc.  Thanks for any help.

-- 
   Carl Stern
   NeoCAD                     carl@neocad.com
   2585 Central Ave.        
   Boulder, CO 80301          Phone: (303) 442-9121

weimer@garden.ssd.kodak.com (Gary Weimer (253-7796)) (05/02/91)

In article <1991May1.170008.12258@neocad.com>, carl@neocad.com (Carl
Stern) writes:
|> 
|>      Ideally what I'd like to do is to be able to save the state of a
|> process at a given point in time and then restart it for debugging purposes.
|> I thought I could send it a signal to dump core, (I've tried QUIT,
ABRT, TRAP),
|> and then use dbx to debug the core file.  I can't continue execution though,
|> which is what I want to be able to do.  I believe this is because there is
|> no active process for dbx to debug.  So is there a way, or an
existing program,
|> that can take a core file and use it to initialize a process and run it?
|> i.e. reload the core file and restart it as a process.
|> If not, why not?

Have you tried sending SEGV then using 'cont' in dbx (I haven't)?

weimer@ssd.kodak.com ( Gary Weimer )

matteo@ghost.unimi.it (Matteo Gelosa) (05/03/91)

	Have you ever seen a system call called  ptrace(2) ?  It
	is the system call used by debuggers to communicate with
	a process, you can stop a program to perform trace, read
	and  write  into  text  area,  data  area  and  obviosly
	register  area.  You can obtain an image of these  areas
	from a core  file.  You may  try (I  said  MAY  TRY)  to
	re-loading  these areas into a process reading them from
	a core file, and then  re-start  execution,  but I don't
	assure that it will work at all.
	Anyway,  ptrace(2) is a valid  instrument  to treat this
	kind of stuff.

---
Matteo Gelosa					Phone  : +39-2-7575242
Universita' Statale di Milano			Fax    : +39-2-76110556
Dipartimento di Scienze dell'Informazione	Telex  : 335199 - MIDSII
Via Moretto da Brescia, 9                       E-Mail : matteo@ghost.unimi.it
I-20133 Milano - Italy - `92 Europe