This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 142454 - Regression: debugging on Mac broken (no remote setup)
Summary: Regression: debugging on Mac broken (no remote setup)
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: Egor Ushakov
URL:
Keywords:
: 146691 (view as bug list)
Depends on:
Blocks: 147938
  Show dependency tree
 
Reported: 2008-07-31 18:40 UTC by Thomas Preisler
Modified: 2009-06-25 10:59 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
log file (2.01 KB, text/plain)
2008-08-01 16:07 UTC, Thomas Preisler
Details
log file (6.16 KB, text/plain)
2008-08-01 17:59 UTC, Thomas Preisler
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Preisler 2008-07-31 18:40:29 UTC
I get the exception below when trying to start the debugger on Mac:. Note no remote setup and working locally.

java.lang.StringIndexOutOfBoundsException: String index out of range: -203
	at java.lang.String.substring(String.java:1768)
	at org.netbeans.modules.cnd.debugger.gdb.utils.GdbUtils.createMapFromString(GdbUtils.java:291)
	at org.netbeans.modules.cnd.debugger.gdb.GdbDebugger.resultRecord(GdbDebugger.java:849)
	at org.netbeans.modules.cnd.debugger.gdb.proxy.GdbProxyEngine.processMessage(GdbProxyEngine.java:321)
	at org.netbeans.modules.cnd.debugger.gdb.proxy.GdbProxyEngine.access$000(GdbProxyEngine.java:76)
	at org.netbeans.modules.cnd.debugger.gdb.proxy.GdbProxyEngine$2.run(GdbProxyEngine.java:207)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
Comment 1 _ gordonp 2008-08-01 02:30:43 UTC
It looks like its processing data returned from stopping at a breakpoint. To really
verify this we need to use the same test program with the same breakpoint. Do you
remember what program and what line of code your breakpoint was set at? Was it a
C or C++ program?

When gdb stops it sends various pieces of data back. This exception happened while
parsing that data. Thats why knowing the program and line of the bp are so important.
We could be failing on a specific set of data received from gdb, but stopping in
other programs or at other lines may not send data we can't parse.
Comment 2 Thomas Preisler 2008-08-01 05:13:44 UTC
It chokes when parsing the following string:

"number="1",type="breakpoint",disp="del",enabled="y",addr="0x00001f97",func="main",file="src/args.c",line="50",shlib="/Users/thp/NetBeansProjects/Arg
uments_1/dist/Debug/GNU-
MacOSX/args",times="0"},time={wallclock="0.00062",user="0.00039",system="0.00023",start="1217563641.232985",end="1217563641.233601""

when it gets to shlib....

It happens with *any* program I'm trying to debug.
Comment 3 Egor Ushakov 2008-08-01 14:47:03 UTC
please attach full gdb-log
Comment 4 Thomas Preisler 2008-08-01 14:48:55 UTC
and where do I find it?
Comment 5 Egor Ushakov 2008-08-01 15:22:26 UTC
usually at /var/tmp/gdb-cmds####.log or /tmp/gdb-cmds####.log
Comment 6 _ gordonp 2008-08-01 15:49:52 UTC
> and where do I find it?

I seem to remember it being harder to find on a Mac. If you can't find it,
copy ~gordonp/NetBeansProjects/SystemProperties/dist/SystemProperties.jar,
run it, and check the value of java.io.tmpdir.

The jar file dumps the output of System.getProperties()...
Comment 7 Thomas Preisler 2008-08-01 16:07:07 UTC
Created attachment 66327 [details]
log file
Comment 8 Egor Ushakov 2008-08-01 16:29:11 UTC
The problem is that for some reason "timings" is enabled on your version of gdb,
because of that gdb adds time=... epilog to every response and we do not expect that.
Proposed fix is to send -enable-timings no to the debugger at the beginning,
I implemented it in the changeset:
http://hg.netbeans.org/main/rev/05acbd98cefc
Comment 9 Thomas Preisler 2008-08-01 17:30:42 UTC
Wouldn't it be better to just parse the string correctly?
Comment 10 Egor Ushakov 2008-08-01 17:43:58 UTC
I think that if we do not use this information, why shouldn't we disable it?
It can double gdb transport traffic.
Comment 11 _ gordonp 2008-08-01 17:49:54 UTC
While I agree we shouldn't turn on timing, we should also parse the line correctly
if it is on. This problem shows that there is at least 1 case where GdbUtils.findMatchingCurly()
fails. If there's on, how do we know there aren't others?

I do think your fix resolves the P1, though. I suggest closing this as fixed and
opening a P2 on findMatchingCurly() (or possibly a P3 since we've only seen this
one case of it failing).
Comment 12 Thomas Preisler 2008-08-01 17:58:22 UTC
No, it didn't fix th problem. It fails same plase as before. New log attached.
Comment 13 Thomas Preisler 2008-08-01 17:59:07 UTC
Created attachment 66338 [details]
log file
Comment 14 Thomas Preisler 2008-08-01 18:07:45 UTC
I noticed debugging fails only if I do 'Step Into' but seems to work if I do Debug. I don't know if it helps.....
Comment 15 _ gordonp 2008-08-01 19:12:57 UTC
I borrowed Thomas' Mac so I could debug in his enviornment. First off, it looks like
Apple broke gdb/mi wrt -enable-timer because even though you explicitly turn it off,
its still on. Thomas said he downloaded a new X-Code recently and probably got an
updated gdb with this problem.

But the actual cause of the problem isn't in GdbUtils, its in GdbDebugger.resulteRecord
where it processes "^done,bkpt=". There is an assumption that the entire msg is the
breakpoint data so we strip off the 1st and last characters ('{' and '}') before
passing the string to GdbUtils.createMapFromString(). Since this assumption is incorrect,
we end up with "},time={" in the middle of the string passed to cMFS.

In his 2nd log, the same thing is happening in "^done,stack={...},time={...}". Again, we
assume one outer set of curly braces, strip them off, and assume everything left is part
of the stack.

There are several other places where we make this same assumption. We should probably
find the closing curly and send a substring rather than make this assumption (although
its really an Apple gdb bug causing the problem). We probably don't need to explicitly
send the -enable-timer off flag (since it doesn't work, anyway:-)
Comment 16 Egor Ushakov 2008-08-01 20:54:09 UTC
-enable-timings does not work because gdb does not recognize this command:
104^error,msg="Undefined MI command: enable-timings"
Comment 17 Egor Ushakov 2008-08-04 10:02:27 UTC
Now we check every debugger response for timing info and cut it out,
implemented in the changeset:
http://hg.netbeans.org/main/rev/8f3fc2197825
Comment 18 Thomas Preisler 2008-08-04 15:47:56 UTC
Fix confirmed: Debugging now works again on my Mac. 
Comment 19 _ gordonp 2008-09-13 01:56:00 UTC
*** Issue 146691 has been marked as a duplicate of this issue. ***
Comment 20 Alexander Pepin 2008-09-17 13:30:57 UTC
Verified in trunk by Thomas. The fix should be included into patch 4.
Comment 21 bradford653 2008-09-23 16:24:07 UTC
Will the fix be incorporated into the 6.1 tree at all?  Some of us have no immediate plans to upgrade to 6.5 until it has been stable for a while.
Comment 22 _ gordonp 2008-09-23 16:31:46 UTC
> Will the fix be incorporated into the 6.1 tree at all?

Yes. The fix is scheduled for patch 4 (the next patch).
Comment 24 Alexander Pepin 2008-10-08 14:53:15 UTC
verified in patch4