Re: stack trace without core



On 2007-06-23, Bin Chen <binary.chen@xxxxxxxxx> wrote:
On Jun 23, 2:33 am, RezaRob <Reza...@xxxxxxxxx> wrote:
On Jun 22, 7:04 am, Jasen <j...@xxxxxxxxxxx> wrote:

On 2007-06-22, RezaRob <Reza...@xxxxxxxxx> wrote:

Is there a way to generate a brief view of the stack without dumping
entire core?

attach gdb to the process?

This isn't an option because it's in "production mode" and only in the
event of an exception I need a stack trace.

It is an option because you can attach gdb to yourself when some
exception occurs.
[...]
sprintf(buf, "/usr/bin/gdbserver :9988 --attach %d", pid);

pid = fork();
if (pid == 0) {
system(buf);


Well. I've never used the gdbserver, but using regular gdb the whole
thing is possible. Generally you want to install signal handler that
does

echo "bt\ndetach\nquit\n" | gdb -batch -x /dev/stdin path_to_file pid

Then you need to catch the output from gdb.

One can use this simple piece of code for that

void
write_stack(int no)
{
char path[4096];
char str[256];
path[readlink("/proc/self/exe", path, -1 + sizeof(path))] = 0;
sprintf(str,
"echo 'bt\ndetach\nquit\n' | gdb -batch -x /dev/stdin %s %d",
path, getpid());
system(str);
}

If you catch stdout in some file already, then you'll get it right
there.

There's a catch here though. At least in my case. Somehow I was getting
only first line of the stack trace and nothing else. So I had to get rid
of "system" call and arrange piping of the input and output thru pipes
between processes.

--
Minds, like parachutes, function best when open
.



Relevant Pages

  • Re: The IListSource does not contain any data sources.
    ... The IListSource does not contain any data sources. ... Exception Details: System.Web.HttpException: The IListSource does not ... be identified using the exception stack trace below. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Intermittant Server Error reading an MS Access DB
    ... Chuck ... > Dim i As Integer ... >> exception can be identified using the exception stack trace below. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASP.NET 2.0 Web Page Problem?
    ... Based on the stack trace you've shown the problem is when the Operations_HBMBlockStatus page's Repeater1 ItemCreated event is being raised. ... You sister site might be hiding the exception by logging it or ignoring them somehow, I'd need to see the code to say for sure. ... I have obtained a scripted database and compiled ASP.NET 2.0 application from a sister site that I'm trying to implement locally. ... An unhandled exception occurred during the execution of the current web request. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: The IListSource does not contain any data sources.
    ... You said that things break after you try to login, ... The IListSource does not contain any data sources. ... Exception Details: System.Web.HttpException: The IListSource does ... be identified using the exception stack trace below. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Running PSIM (PowerPC simulator) under GDB
    ... in which Special Register 81 is ... Exception 10, not Exception 7. ... Replaced with an instruction which explicitly sets the MSR, ... :> Running under Cygwin, with GDB and the embedded PowerPC simulator, ...
    (comp.arch.embedded)