Bug 5740 - break m<TAB> causes an NPE
Summary: break m<TAB> causes an NPE
Status: NEW
Alias: None
Product: frysk
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks: 2246
  Show dependency treegraph
 
Reported: 2008-02-06 13:12 UTC by Phil Muldoon
Modified: 2008-02-06 13:23 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Phil Muldoon 2008-02-06 13:12:39 UTC
break <TAB> causes same:

[pmuldoon@localhost frysk-core]$ ./frysk/bindir/fhpd 
(fhpd) load /bin/sleep 
Loaded executable file: /bin/sleep

(fhpd) start
Attached to process 17018
starting/running with this command: /bin/sleep 

(fhpd) break mjava.lang.NullPointerException
   at frysk.debuginfo.ObjectDeclarationSearchEngine.complete(fhpd)
   at frysk.expr.IncompleteIdentifierException.complete(fhpd)
   at frysk.expr.ExpressionFactory.complete(fhpd)
   at frysk.hpd.CompletionFactory.completeExpression(fhpd)
   at frysk.hpd.BreakpointCommand.completer(fhpd)
   at frysk.hpd.ParameterizedCommand.complete(fhpd)
   at frysk.hpd.MultiLevelCom
mand.complete(fhpd)
   at frysk.hpd.CLI.complete(fhpd)
   at frysk.bindir.fhpd$FhpdCompletor.complete(fhpd)
   at jline.ConsoleReader.complete(fhpd)
   at jline.ConsoleReader.readLine(fhpd)
   at jline.ConsoleReader.readLine(fhpd)
   at frysk.bindir.fhpd.main(fhpd)
breakpoint 0 deferred
Comment 1 Mark Wielaard 2008-02-06 13:23:54 UTC
This comes from not checking whether the compilation unit for the current
address actually exists.

Quick and dirty patch that seems to work around the issue.
The XXX in the comments suggest this is code isn't finished though.

diff --git a/frysk-core/frysk/debuginfo/ObjectDeclarationSearchEngine.java b/fry
index 94aee90..86e8e1b 100644
--- a/frysk-core/frysk/debuginfo/ObjectDeclarationSearchEngine.java
+++ b/frysk-core/frysk/debuginfo/ObjectDeclarationSearchEngine.java
@@ -139,16 +139,18 @@ public class ObjectDeclarationSearchEngine implements Expr
     /**
      * XXX: Who knows if this works; it is certainly not implemented
      * correctly as it should use the ObjectDeclaration.
      */
     public void complete(String incomplete, List candidates) {
        long pc = frame.getAdjustedAddress();
        Dwfl dwfl = DwflCache.getDwfl(frame.getTask());
        DwflDieBias bias = dwfl.getCompilationUnit(pc);
+       if (bias == null)
+         return;
        DwarfDie die = bias.die;
        DwarfDie[] allDies = die.getScopes(pc - bias.bias);
        List candidates_p = die.getScopeVarNames(allDies, incomplete);
        for (Iterator i = candidates_p.iterator(); i.hasNext();) {
             String sNext = (String) i.next();
             candidates.add(sNext);
         }
     }