This is the mail archive of the
frysk@sources.redhat.com
mailing list for the frysk project.
Re: NullPointerException at inua.elf.PrintNote.print(inua.PrintWriter)
- From: Wu Zhou <woodzltc at cn dot ibm dot com>
- To: frysk at sources dot redhat dot com
- Date: Wed, 4 Jan 2006 20:57:21 +0800 (CST)
- Subject: Re: NullPointerException at inua.elf.PrintNote.print(inua.PrintWriter)
- References: <Pine.LNX.4.64.0601041039180.30652@localhost.localdomain>
On Wed, 4 Jan 2006, Wu Zhou wrote:
> Happy new year, Frysk developers!
>
> I am playing with Frysk. Although I don't get any successful experience
> of getting Frysk to report anything when an observed process terminates,
> But I do find something interesting. The inua package is one of them.
> But I met a nullpointer exception when playing with readelf. Here is the
> failing scenario:
>
> ./readelf -n addr2line
> Exception in thread "main" java.lang.RuntimeException:
> java.lang.NullPointerException
> at inua.util.readelf.main(java.lang.String[])
> (/usr/src/redhat/BUILD/frysk-0.0.1.2005.12.14.15.12/frysk-0.0.1.2005.12.14.15.12/frysk-imports/inua/util/readelf.java:67)
> at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)
> at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
> Caused by: java.lang.NullPointerException
> at inua.elf.PrintNote.print(inua.PrintWriter)
> (/usr/src/redhat/BUILD/frysk-0.0.1.2005.12.14.15.12/frysk-0.0.1.2005.12.14.15.12/frysk-imports/inua/elf/PrintNote.java:64)
> at inua.util.readelf.main(java.lang.String[])
> (/usr/src/redhat/BUILD/frysk-0.0.1.2005.12.14.15.12/frysk-0.0.1.2005.12.14.15.12/frysk-imports/inua/util/readelf.java:172)
> ...2 more
>
> Other options seem to work ok.
>
> What is the problem?
I think I had found the reason. The following patch could fix this:
*** ./PrintNote.java.old 2006-01-04 20:01:13.000000000 +0800
--- ./PrintNote.java 2006-01-04 20:01:57.000000000 +0800
*************** public class PrintNote
*** 53,59 ****
for (int i = 0; i < phdrs.length; i++) {
Phdr phdr = phdrs[i];
Note[] notes = phdr.asNotes ();
! if (notes == null) {
o.print ("Notes at offset 0x");
o.printx (8, '0', phdr.offset);
o.print (" with length 0x");
--- 53,59 ----
for (int i = 0; i < phdrs.length; i++) {
Phdr phdr = phdrs[i];
Note[] notes = phdr.asNotes ();
! if (notes != null) {
o.print ("Notes at offset 0x");
o.printx (8, '0', phdr.offset);
o.print (" with length 0x");
Regards
- Wu Zhou