in reply to Re^2: stack trace from thread exit
in thread stack trace from thread exit
Could you elaborate on (or reference to) how you use them in this context?
I am not sure which context you refer to by this context.
With regard to Perl programs in general, I have rarely used gdb and, even less often, core dumps: to investigate perl initialization, lexing and parsing, to study and customize the regular expression engine and once to track down a bug in PerlIO that produced a core dump during initialization when attempting to read a UTF-16 encoded file. I don't recall any other use at the moment...
Much more often, I use logging and test cases to investigate Perl programs and programs in general. I developed my debugging habits about the time Brian Kernighan wrote: The most effective debugging tool is still careful thought, coupled with judiciously placed print statements., and I remain very much in that camp. But there have been times when I have found debuggers and core dumps very helpful. For example, I once found a bug in the perl tokenizer that could not be isolated with test Perl programs and print statements, and tracing the execution was much more effective that merely reading the source in toke.c.
I haven't done much with XS, but once outside the realm of the Perl interpreter gdb can be a helpful tool.
When I do use them with Perl programs (gdb and core dumps) I do so as I would for any other program. There are various manuals and tutorials available on the net, including http://www.gnu.org/software/gdb/documentation/ and http://www.cs.cmu.edu/~gilpin/tutorial/. I always build perl from source with -g flag and generally investigate the issue by other means first. While it is possible to attach gdb to live programs, I very much prefer small test cases run in isolation.
If by this context you mean the situation of the OP, I have not used gdb or core dumps to investigate crashing threaded Perl programs using possibly buggy XS modules. I would try other means to isolate the fault first, but might use gdb if core files were being produced, at least to get some idea where in the code the fault was occuring, if other approaches proved unsatisfactory.
I was merely responding to the OP who said: I'd like to trap the fault in gdb. Given that specific objective and the warning, I thought a core dump produced in the context of the warning might be what the OP was wanting.
The test program I provided produces a core dump, if resource limits permit (I am assuming *nix system). It is easily accessed in gdb with:
gdb /usr/bin/perl core
(Substitute the path to the relevant instance of perl on your system.)
The C stack is easily displayed with the bt command. Beyond that, one would have to know perl and the relevant Perl and XS programs in some detail to know where to look.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: stack trace from thread exit
by falan95054 (Novice) on Oct 26, 2010 at 21:04 UTC | |
by BrowserUk (Patriarch) on Oct 27, 2010 at 08:01 UTC | |
by ig (Vicar) on Oct 27, 2010 at 03:49 UTC |