How to debug core file generated with perl?

0

I have abc.bin file which is created from a perl script file.

Now how to debug a core file which is generated with this "abc.bin"

By doing,

gdb abc.bin -c core_file 

I am getting and error saying "not in executable format: File format not recognized"

Is there any other option to debug such file in GDB or is there any other tool to do so

Edit:

Lets forget about abc.bin, Is there a way to debug core file generated with perl file, I have one abc.pl file which is causing a core dump, Is there way to debug this core with abc.pl ?

Edit

Output of file for abc.bin

ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped

Edit:

Output of "gdb abc.bin"

<M> l1143425:/root # gdb /var/storage/cores/abc.bin.11413
GNU gdb (GDB; Astaro Security Gateway) 7.9.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-suse-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.opensuse.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
[New LWP 11413]
Core was generated by `app_name [module_name]'.
Program terminated with signal SIGABRT, Aborted.
#0  0xf7733440 in __kernel_vsyscall ()
"/var/storage/cores/abc.bin.11413" is a core file.
Please specify an executable to debug.
(gdb) bt
#0  0xf7733440 in __kernel_vsyscall ()
#1  0xf754bbb0 in ?? ()
#2  0xf768f000 in ?? ()
#3  0xf754d4e5 in ?? ()
#4  0x00000006 in ?? ()
#5  0xffba33e0 in ?? ()
#6  0xf64b6185 in ?? ()
#7  0x00000000 in ?? ()
(gdb) f 2
#2  0xf768f000 in ?? ()
(gdb) list
No symbol table is loaded.  Use the "file" command.
(gdb)

Edit

Scenario :

  1. I have a perl file lets say abc.pl
  2. Using perlapp I am converting this perl file to executable lets say abc.bin
  3. Now I am running this abc.bin as a simple executable, not using perl, So now debug using GDB is possible? Is there any other way to debug?
linux
perl
gdb
asked on Stack Overflow Aug 3, 2018 by chirag • edited Aug 6, 2018 by chirag

1 Answer

2

You're lacking the debug info. My GDB says:

› gdb /usr/bin/perl
GNU gdb (GDB; openSUSE Tumbleweed) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.opensuse.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/perl...Missing separate debuginfo for /usr/bin/perl
Try: zypper install -C "debuginfo(build-id)=33dd6e73e6f617df00f76a78a397b854f49d6df1"
(no debugging symbols found)...done.
(gdb) r -e CORE::dump
Starting program: /usr/bin/perl -e CORE::dump
Missing separate debuginfo for /lib64/ld-linux-x86-64.so.2
Try: zypper install -C "debuginfo(build-id)=d1f6bf237ba196265561924d1baaf522e036281f"
Missing separate debuginfo for /lib64/libm.so.6
Try: zypper install -C "debuginfo(build-id)=1fc13b3ef7db0024a3f401933c6da8b266a8e06c"
Missing separate debuginfo for /lib64/libdl.so.2
Try: zypper install -C "debuginfo(build-id)=b21e9d59d1465db80fa52e72a4803f1901202e6d"
Missing separate debuginfo for /lib64/libcrypt.so.1
Try: zypper install -C "debuginfo(build-id)=b043217f12c9950ff058956c57320d8b03cee06b"
Missing separate debuginfo for /lib64/libpthread.so.0
Try: zypper install -C "debuginfo(build-id)=b5ad7ea10e4e88d4e2cc038e5c3288bdea82e20b"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Missing separate debuginfo for /lib64/libc.so.6
Try: zypper install -C "debuginfo(build-id)=5926416cd74d1dfe53d37374041bca37ee80c598"

Program received signal SIGABRT, Aborted.
0x00007ffff705e367 in kill () from /lib64/libc.so.6

The package capabilities resolve to the package names: glibc-debuginfo glibc-debugsource perl-base-debuginfo perl-debugsource

After installing the missing packages there is a meaningful backtrace:

› gdb /usr/bin/perl
GNU gdb (GDB; openSUSE Tumbleweed) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.opensuse.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/perl...Reading symbols from /usr/lib/debug/usr/bin/perl-5.26.2-1.4.x86_64.debug...done.
done.
(gdb) r -e CORE::dump
Starting program: /usr/bin/perl -e CORE::dump
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGABRT, Aborted.
0x00007ffff705e367 in kill () at ../sysdeps/unix/syscall-template.S:78
78      T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
(gdb) bt full
#0  0x00007ffff705e367 in kill () at ../sysdeps/unix/syscall-template.S:78
No locals.
#1  0x00005555555a42e9 in Perl_my_unexec (my_perl=<optimized out>) at perl.c:3685
No locals.
#2  0x0000555555678554 in Perl_pp_goto (my_perl=0x555555956260) at pp_ctl.c:3082
        sp = <optimized out>
        retop = 0x0
        ix = <optimized out>
        cx = <optimized out>
        enterops = {0x0, 0xeda3fe532dabdd00, 0x555555712140 <arg_counts>, 0x5555559591e0, 0x555555956260, 0x7fffffffd458, 0x5555559758c0,
          0x555555956260, 0x555555956260, 0x5555556391e1 <Perl_sv_free2+97>, 0x5555559758c0, 0x555555956260, 0xffffffffffffffff,
          0x55555566945e <Perl_free_tmps+78>, 0x5555559758c0, 0x0, 0x1, 0x5555555a9efd <perl_parse+5165>, 0x555555956260, 0x0,
          0x555555582800 <xs_init>, 0x0, 0x0, 0x100000000000001, 0x7fefffffffffffff, 0x555555956980, 0x6400000000, 0x0, 0x0, 0x0,
          0x54552e45445f6564, 0x6500382d46, 0x0, 0x0, 0x0, 0x2020002020000000, 0x6, 0x405, 0x1, 0x21b6, 0x0, 0x103, 0x0, 0x1000, 0x0,
          0x5b59e189, 0x13c9eb00, 0x5b59e189, 0x13c9eb00, 0x5b59e189, 0x13c9eb00, 0x0, 0x0, 0x0, 0x0, 0x6e00000061, 0x0, 0x770000007c, 0x2,
          0x0, 0x0, 0x0, 0x0, 0x0}
        label = <optimized out>
        label_len = 0
        label_flags = <optimized out>
        do_dump = true
        must_have_label = 0x555555712332 "goto must have label"
#3  0x000055555562b1d6 in Perl_runops_standard (my_perl=0x555555956260) at run.c:42
        op = <optimized out>
#4  0x00005555555ab027 in S_run_body (oldscope=<optimized out>, my_perl=<optimized out>) at perl.c:2532
No locals.
#5  perl_run (my_perl=0x555555956260) at perl.c:2455
        oldscope = 1
        ret = <optimized out>
        cur_env = {je_prev = 0x5555559565e8, je_buf = {{__jmpbuf = {0, -4037406656558474170, 93824992421648, 140737488344128, 0, 0,
                -7877616891281744826, -4037406257967473594}, __mask_was_saved = 0, __saved_mask = {__val = {0, 0, 0, 0, 0, 0, 0, 0, 0,
                  17123809841394736384, 139637976727552, 93824996434528, 93824992421648, 17123809841394736384, 0, 0}}}}, je_ret = 0,
          je_mustcatch = false, je_old_delaymagic = 0}
        _p = <optimized out>
---Type <return> to continue, or q <return> to quit---
        _p = <optimized out>
#6  0x00005555555826f2 in main (argc=<optimized out>, argv=<optimized out>, env=<optimized out>) at perlmain.c:123
        exitstatus = <optimized out>
        i = <optimized out>
answered on Stack Overflow Aug 6, 2018 by daxim

User contributions licensed under CC BY-SA 3.0