On Sat, 24 Jul 2004, Gennady wrote: > Hi, guys > > The great thing about this list is that you can expect an answer to any > reasonable technical question here. You are the best, guys. > > Now the question ;-). Does anybody know how to generate a core file from > within a process without terminating it on Linux or Solaris? I know that > at any point I can call abort() and have the core, or send itself a > signal that terminates a process with generating a core file. But it is > not what I need, unfortunately. > > I hold little hope for a positive answer as I am in Unix C/C++ > development for around 15 years, however maybe I am missing something. > > Here's the problem. In my C++ program I have an exception class, say, > NoSuchElementException. It is being handled accordingly throughout the > code, however there are some places where it sneaks through. I want to > get an execution stack at the time when the exception is first created > so that I can trace where it was thrown from (much like in Ruby where > you can get #backtrace from an exception, Ruby rules :-) !!!) . > > So I thought if I could generate a core file from > NoSuchElementException's constructor and let it go on, I would be able > to analyze the last core file and pin-point the place immediately (now I > have to put more trace output to find it). > > Thanks a lot, > Gennady. > > P.S. I also tried to use gdb and specify command to be executed at a > given breakpoint (like { backtrace, continue }). It works fine, however, > executing a program from within gdb is not always an option in a > production environment :-(, you often need to do post-mortem analysis. ~ > echo $$ 14075 ~ > gcore $$ ~ > file core.14075 core.14075: ELF 32-bit LSB core file Intel 80386, version 1 (SYSV), SVR4-style, from 'bash' you could call it with a system call. also, it seems like forking and then calling abort would do? regards. -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; | and a weed grows, even though we do not love it. | --Dogen ===============================================================================