KWDB not recognizing DLKM type names (102 Views)
Reply
Advisor
Vivek Srivastava
Posts: 14
Registered: ‎02-05-2008
Message 1 of 10 (102 Views)
Accepted Solution

KWDB not recognizing DLKM type names

Hi,

While analyzing a crash dump (from HP-UX 11.31 IA), I am passing -m flag to kwdb to enable DLKM debugging. kwdb can recognize symbols from our DLKM module, but it is not recognizing type names. Couple of examples:

1. _fsh_fs_info_tbl is a global. kwdb can find it, but can't recognize its type.
q4> print &_fsh_fs_info_tbl
$1 = ( *) 0x4f12270

2. Directly printing a type doesn't work too.
q4> ptype struct fsh_fstype_info_st
No struct type named fsh_fstype_info_st.

How can I make kwdb recognize type names from our DLKM module?

I wrote a small C file (sym.c) with a few data structures defined in it and then compiled it using the command line: /opt/ansic/bin/cc +DD64 -D_KERNEL -g -c sym.c (_KERNEL is defined to include kernel space declarations). Then I used the 'adddebug' command inside kwdb to load these symbols:

q4> adddebug sym.o
Reading debug info from /var/adm/crash.3/sym.o...
expanding to full symbols...Reading debug info ...done.

Still the symbols defined in sym.c are not visible inside kwdb. I must be missing something. How can I get this to work?

kwdb version is 3.2.1.

Thanks,
Vivek
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,978
Registered: ‎03-06-2006
Message 2 of 10 (102 Views)

Re: KWDB not recognizing DLKM type names

>How can I make kwdb recognize type names from our DLKM module?

What does "ptype &_fsh_fs_info_tbl" show?

Can you toss kwdb out and use a normal C executable with sym.c and see if gdb finds that type?

What aC++ compiler version are you using?
Please use plain text.
Advisor
Vivek Srivastava
Posts: 14
Registered: ‎02-05-2008
Message 3 of 10 (102 Views)

Re: KWDB not recognizing DLKM type names

> What does "ptype &_fsh_fs_info_tbl" show?

q4> ptype &_fsh_fs_info_tbl
type = *

> What aC++ compiler version are you using?

B9007AA C.11.31.04.2 HP C/aC++ Developer's Bundle

I think I've figured out the problem. It's got something to do with the Itanium compiler's behaviour. Things are fine on PA-RISC.

I created a simple program foo.c:

typedef struct mytype
{
int a;
long b;
} mytype_t;

main()
{
}

Then compiled it both on IA and PA using the cmd: /opt/ansic/bin/cc +DD64 -g -c foo.c

When I 'adddebug'ed foo.o on kwdb (or gdb) running on a PA machine, kwdb showed 'mytype' in the catalog.

However, on IA machine, kwdb didn't show 'mytype'.

I figured out that if you _use_ a variable of a type then that type will show up in kwdb on IA. So changing main to:

main()
{
mytype_t t1;

t1.a = 10;
}

will cause kwdb to recognize 'mytype'. Note that simply declaring a variable is not enough; you have to actually use that variable. I guess the IA compiler is removing unused code even in the presence of -g flag. I don't know if a flag can be used to change this behaviour. PA compiler doesn't need this extra work.

Regards,
Vivek
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,978
Registered: ‎03-06-2006
Message 4 of 10 (102 Views)

Re: KWDB not recognizing DLKM type names

>B9007AA C.11.31.04.2

This is A.06.20. The latest is A.06.25.01.

>I guess the IA compiler is removing unused code even in the presence of -g flag.

Yes. A C++ compiler can't afford to put unused info into the debug info.

>I don't know if a flag can be used to change this behaviour.

I can't duplicate your problem. If you use +kernel and -g, unused types are put into the debug info. I assume you also used +noobjdebug?
Please use plain text.
Advisor
Vivek Srivastava
Posts: 14
Registered: ‎02-05-2008
Message 5 of 10 (102 Views)

Re: KWDB not recognizing DLKM type names

> Yes. A C++ compiler can't afford to put unused info into the debug info.

I would think that any optimizations should not be applied when -g flag is specified _and_ none of the optimization flags are specified. PA compiler seems to work differently in this regard, which is along (my) expected lines.

> If you use +kernel and -g, unused types are put into
> the debug info. I assume you also used +noobjdebug?

I didn't use +noobjdebug.

However, using +kernel makes it work. I no longer have to use the types to make them appear in debugger.

What does this option really do? It is not listed at A.06.25's online help page (http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/Online_Help/options.htm ).

Regards,
Vivek
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,978
Registered: ‎03-06-2006
Message 6 of 10 (102 Views)

Re: KWDB not recognizing DLKM type names

>I would think that any optimizations should not be applied when -g flag

This isn't really an optimization. Customers don't like it when their object files are massive.

>PA compiler seems to work differently in this regard

That's because it is a C only compiler, not aC++.

>our DLKM module
>using +kernel makes it work.
>What does this option really do?

This is a required option for DLKMs. If you are creating DLKMs, you must follow the info in the DDK guides.
http://www.hp.com/go/hpux_ddk
http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=cb08b3f1e...
Please use plain text.
Advisor
Vivek Srivastava
Posts: 14
Registered: ‎02-05-2008
Message 7 of 10 (102 Views)

Re: KWDB not recognizing DLKM type names

> That's because it is a C only compiler, not aC++.

Hmm, yes. I didn't know this. On Itanium:

# ls -l /opt/ansic
lrwxrwxrwx 1 bin bin 3 Jul 22 04:45 /opt/ansic -> aCC

> +kernel ... This is a required option for DLKMs.

Our DLKM is actually built using this option (along with several others); just that I didn't use it for my test program, more so because PA compiler did not require it. But things are better now.

Thanks a lot, Dennis, for all the help.

Regards,
Vivek
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,978
Registered: ‎03-06-2006
Message 8 of 10 (102 Views)

Re: KWDB not recognizing DLKM type names

>Thanks a lot, Dennis, for all the help.

If you are happy with the answers you were given, please read the following about how to assign points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33
Please use plain text.
Advisor
Vivek Srivastava
Posts: 14
Registered: ‎02-05-2008
Message 9 of 10 (102 Views)

Re: KWDB not recognizing DLKM type names

I have assigned points in all my threads in the past, though I do it at the end. Doing so now.

Regards,
Vivek
Please use plain text.
Advisor
Vivek Srivastava
Posts: 14
Registered: ‎02-05-2008
Message 10 of 10 (102 Views)

Re: KWDB not recognizing DLKM type names

Closing thread. Use the +kernel option together with -g when using IA C compiler.

Vivek
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation