IBM Support

== DEBUGGING CORE FILES [03] == HOW TO LOAD A CORE FILE IN A DEBUGGER?

Technical Blog Post


Abstract

== DEBUGGING CORE FILES [03] == HOW TO LOAD A CORE FILE IN A DEBUGGER?

Body


== DEBUGGING CORE FILES [03] == HOW TO LOAD A CORE FILE IN A DEBUGGER?

Once you have packaged the core file with all the objects required you
need to load it into the debugger. If you are running the debugger on
the same machine as the one where the core file was generated then
not much of an issue, the debugger should be able to locate all required
objects. However, if you are running the debugger on a different machine
then you need to tell the debugger where to find the objects.

So let's see how we can load the core file in the debugger depending on
the machine you're running on. Note that some commands might be changing
depending on the version of the debugger you are using.


- SOLARIS -

  [/home/dalla/files] ls -l
  drwxr-xr-x   3 dalla    pdxdb2       512 Nov 22 15:58 lib
  -rw-r--r--   1 dalla    pdxdb2   18071156055 Nov 17  2016 mycore
  drwxr-xr-x   3 dalla    pdxdb2       512 Nov 22 15:58 platform
  drwxr-xr-x   3 dalla    pdxdb2       512 Nov 22 15:58 usr

  [/home/dalla/files] dbx
  For information about new features see `help changes'
  To remove this message, put `dbxenv suppress_startup_message 7.4' in your .dbxrc
  (dbx) dbxenv core_lo_pathmap on
  (dbx) pathmap /lib /home/dalla/files/lib
  (dbx) pathmap /platform /home/dalla/files/platform
  (dbx) pathmap /usr /home/dalla/files/usr
  (dbx) pathmap /db2home/sqllib /home/dalla/sqllib
  (dbx) pathmap /opt/IBM/db2/V10.1/lib64 /home/dalla/sqllib/lib64
  (dbx) debug -f /home/dalla/sqllib/adm/db2sysc mycore
  core file header read successfully
  Reading ld.so.1
  Reading libdb2e.so.1
  Reading libdb2osse.so.1
  Reading libm.so.2
  Reading libsocket.so.1
  ...

  NOTES:

    core_lo_pathmap: By default the debugger will attempt to load objects
                     from the same location they were loaded by the running
                     process. With 'core_lo_pathmap' set to 'on' the debugger
                     will construct a new path using values declared in the
                     'pathmap' commands.

    -f             : By default 'debug' will ignore the core dump if it is
                     older than the executable. The '-f' will force loading
                     the core file even if it is older.


- AIX -

  [/data1/dalla/files] ls -l
  -rw-r--r--    1 dalla    build    13952229538 Dec 20 20:46 mycore

  [/data1/dalla/files] ulimit -m unlimited
  [/data1/dalla/files] ulimit -d unlimited
  [/data1/dalla/files] dbx -v -p /=/data1/dalla/files/ ./sqllib/adm/db2sysc mycore

  NOTES:

    -v: By default 'dbx' will ignore the core dump if it is
        older than the executable. The '-v' will force loading
        the core file even if it is older.

    -p: Used to map one path to another. Multiple paths can be remapped by
        separating them with ':'.

  To make things easy you can add all options to a shell script and run the shell
  script to load the core file as opposed to entering the above commands everytime
  you need to look at the core file. For example:

    [/data1/dalla/files] cat dodbx
    ulimit -m unlimited
    ulimit -d unlimited
    dbx -v -p /=/data1/dalla/files/ ./sqllib/adm/db2sysc mycore

  Then you just need to run 'dodbx' to load the core file.


- HP -

  [/home/dalla/files/CORE1] ls -l
  -rwxr-xr-x   1 dbguest0   pdxdb2     1019432 Mar 20 11:30 bsicall
  drwxr-xr-x   3 dbguest0   pdxdb2          96 Apr 19 19:04 db2
  -rw-r-----   1 26381      pdxdb2     21568800 Apr 19 19:07 mycore
  drwxr-xr-x   3 dbguest0   pdxdb2          96 Apr 19 19:04 pstenv1
  drwxr-xr-x   3 dbguest0   pdxdb2          96 Apr 19 19:04 usr

  [/home/dalla/files/CORE1] GDB_SHLIB_ROOT=`pwd`
  [/home/dalla/files/CORE1] export GDB_SHLIB_ROOT
  [/home/dalla/files/CORE1] gdb ./bsicall mycore

  NOTES:

  HP has it's own port of 'gdb' (/opt/langtools/bin/gdb). To reset the mapping
  for libraries and other objects it uses an envirnment variable 'GDB_SHLIB_ROOT'.


- LINUX -

  [/home/dalla/files] ls -l
  -rw-r--r-- 1 dalla pdxdb2 10776042 2015-09-15 20:36 mycore

  [/home/dalla/files] gdb
  (gdb) set solib-absolute-prefix /home/dalla/sqllib/lib64
  (gdb) set solib-search-path /home/dalla/sqllib/lib64
  (gdb) file /home/dalla/sqllib/adm/db2sysc
  (gdb) core-file mycore

  NOTES:

  Depending on the version of 'gdb' you are using the 'solib-absolute-prefix' and
  'solib-search-path' can be replaced by 'set sysroot' command to let the debugger
  know that the '/' from the customer's machine should be prepended with 'path'
  on the local machine. For example:

    (gdb) set sysroot /home/dalla/files/

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

UID

ibm11140238