Once again about GDB

A really great post from Frits Hoogland has appeared recently How to obtain semaphore information in gdb when the symbols are missing.
Methodology described there can be used much wide actually, not limited to standard libraries but rather you can apply really any structure on Oracle internal structures.

I have tried to reproduce results of Alexander Anokhin’s dbtrace script on LInux system Dynamic tracing of Oracle logical I/O

And it works!!!

So steps to reproduce
First create a C file with structures definitions:

vi lio.c

/*      0. Several standard oratype.h declarations */

typedef unsigned long long ub8; /* unsigned int of length 8 */
typedef unsigned int       ub4;
typedef unsigned short     ub2;
typedef unsigned char      ub1;
typedef int       sb4;

/*  */
typedef sb4 kobjd;
typedef sb4 kobjn;
typedef ub4 ktsn;
typedef ub4 krdba;

/* definition from MOS note 8103.1 */

typedef struct kdbafr /* full relative dba */
    ktsn tsn_kdbafr;  /* a tablespace number */
    krdba dba_kdbafr; /* a relative dba */
} kdbafr;

typedef struct ktid /* relative dba + objd */
    struct kdbafr dbr_ktid; /* a relative dba */
    kobjd objd_ktid; /* data object number */
    kobjn objn_ktid; /* dictionary object number */
} ktid;

typedef struct kcbds
    struct ktid kcbdstid; /* full relative DBA plus object number */
    /* Here unknown (yet ;-)) part of the structure */
} kcbds;

then compile your C file into an object file:

gcc -c -g lio.c -o lio.o

attach to your Oracle session process:

gdb attach 4930

load debug information from the object file:

add-symbol-file /root/lio.o 0

Set up a break point on “lio” function

b kcbgtcr

Do some SQL in your sqlplus session, you stopped at breakpoint
and do the trick

print (struct kcbds *) $rdi
$3 = (struct kcbds *) 0x7ffe0eaa8c90
(gdb) p *$3
$4 = {kcbdstid = {dbr_ktid = {tsn_kdbafr = 4, dba_kdbafr = 29360258}, objd_ktid = 74589, objn_ktid = 74588}}

Tablespace number and obj_id corresponds to my table, have not checked yes, RBA and other stuff but see no reason for an issue.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s