Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!

Bug 170488

Summary: gdbserver: pause issues
Product: cnd Reporter: Egor Ushakov <gorrus>
Component: DebuggerAssignee: henk89
Status: RESOLVED FIXED QA Contact: issues <issues.netbeans.org>
Priority: P2 CC: darbie, darwin_te, dhauck, gsmcmullin, henk89, mmirilovic, rmartins, sehughes, TubaTim
Version: 6.x   
Target Milestone: 7.3   
Hardware: All   
OS: All   
Whiteboard:
Issue Type: DEFECT Exception Report:
Bug Depends on: 182147, 182386    
Bug Blocks: 224840    
Attachments: Patch to fix pause of remote target.
Log file from gdb
Fix to gdb/gdbserver pause issue
proposed fix

Description Egor Ushakov 2009-08-17 16:45:11 UTC
pause does not work during gdbserver attach session,
because of that breakpoint setting on the fly also is not available
Comment 1 Egor Ushakov 2009-08-19 17:15:19 UTC
*** Issue 170483 has been marked as a duplicate of this issue. ***
Comment 2 Egor Ushakov 2009-08-19 17:15:39 UTC
*** Issue 170480 has been marked as a duplicate of this issue. ***
Comment 3 Egor Ushakov 2009-10-30 14:47:46 UTC
will not work without new execution infrastructure
Comment 4 Egor Ushakov 2010-03-19 16:19:04 UTC
made all necessary fixes in debugger code:
http://hg.netbeans.org/cnd-main/rev/e493aed1ea82
now waiting for execution fixes
Comment 5 Quality Engineering 2010-03-20 06:29:48 UTC
Integrated into 'main-golden', will be available in build *201003200200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/e493aed1ea82
User: Egor Ushakov <gorrus@netbeans.org>
Log: fixing #170488 (gdbserver: pause does not work)
Comment 6 Alexander Pepin 2010-11-02 17:14:53 UTC
It's not for 7.0.
Comment 7 Alexander Simon 2011-04-27 14:16:24 UTC
escalate because issue has 2 votes
Comment 8 gsmcmullin 2012-01-25 07:58:25 UTC
Created attachment 115218 [details]
Patch to fix pause of remote target.

SIGINT does work, but it must be sent to GDB intself, not the PID reported by GDB to be the inferior.  GDB always reports the child PID as 42000 when doing remote debugging.

I've attached a patch that fixes this issue, at least on Unix.  This is not the ideal solution as it may cause problems if you happen to have an inferior with a pid of 42000.  There should be some way to find out if gdb is attached to a remote target.

The situation is more complicated on Windows, as there is no kill(2).  The windows API function GenerateConsoleCtrlEvent() is the only way I can get this to work, but it has the problem that GDB needs to share a console window with the front-end.  I have no idea how to achieve that in NetBeans.  Sending a '\x03' into GDB's stdin certainly doesn't work.
Comment 9 Egor Ushakov 2012-02-02 17:30:06 UTC
fixed in:
http://hg.netbeans.org/cnd-main/rev/8d47b263aab6
for remote targets it really works to send SIGINT to gdb itself, thanks Gareth!
Comment 10 Egor Ushakov 2012-03-21 15:24:39 UTC
still reproduced according to users@cnd
Comment 11 Egor Ushakov 2012-04-17 10:37:51 UTC
could someone please attach gdb log from the debug session where pause did not work? (http://wiki.netbeans.org/GdbLog) Or just the content of the debugger console window (Main menu/window/debugging/debugger console).
Comment 12 cbalfour 2012-04-17 16:55:42 UTC
I can take a look at this. What do I have to do to test it? I am using Netbean 7.1.1 not nightly just the release?

I can help out if needed.
Comment 13 Egor Ushakov 2012-04-18 08:01:36 UTC
(In reply to comment #12)
> I can take a look at this. What do I have to do to test it? I am using Netbean
> 7.1.1 not nightly just the release?
> 
> I can help out if needed.

Just try to attach to the gdbserver, let the application work and then press pause. If it does not work - attach here content of the Debugger console (se below).
Comment 14 Egor Ushakov 2012-04-18 10:14:55 UTC
also please try to attach to a local process (not gdbserver) and try to pause it
Comment 15 mthebault 2012-04-19 13:33:26 UTC
Created attachment 118511 [details]
Log file from gdb
Comment 16 mthebault 2012-04-19 13:34:38 UTC
Hello,

Not use this would be useful as I am not even sure my compilation and linkage are corrects.
Compiled with : gcc.exe -DMYOPTION   -c -g -w -I../some_lib  -MMD -MP -MF test.o.d -o test.o test.c
Linked with : gcc.exe -DMYOPTION -shared -o test.dll test.o test.dll.
I have a doubt on the options. It seems that -g is ignore if -s option is used when linking and I do not even know if -s and -shared are the same option. If yes, please ignore my post and delte it. If not, here is the gdb-cmds excerpt.

Thanx for your work
Comment 17 darwin_te 2012-09-24 18:42:40 UTC
Not yet fixed in:

Product Version: NetBeans IDE 7.2 (Build 201207171143)
Java: 1.7.0_07; OpenJDK Server VM 23.2-b09
System: Linux version 3.2.0-31-generic-pae running on i386; UTF-8; en_CA (nb)
User directory: /home/darwin/.netbeans/7.2
Cache directory: /home/darwin/.cache/netbeans/7.2
Comment 18 darwin_te 2012-09-24 19:01:37 UTC
A work around:

on another console, run the command:

kill -2 `pidof gdb` 

then on the netbeans debug console window, i can send commands again to the gdbserver.
Comment 19 Egor Ushakov 2012-10-01 12:45:04 UTC
(In reply to comment #18)
> kill -2 `pidof gdb` 

that's what it does right now, for some reason it does not work,
would you please attach gdb log here?
http://wiki.netbeans.org/GdbLog
Comment 20 Egor Ushakov 2012-10-25 15:39:31 UTC
*** Bug 220254 has been marked as a duplicate of this bug. ***
Comment 21 Alexander Simon 2012-12-06 19:14:24 UTC
more then 10 votes => P2
Comment 22 Leonid Lenyashin 2012-12-06 22:56:37 UTC
Alexander, there is a partial fix that helped many users (that is why, I believe, it was downgraded). Some users still see the issue, but Egor is not sure what is the reason.
Another point is that it is not in the main product, it is on update center. I'm not sure it is worth holding the release.
Comment 23 sehughes 2012-12-09 17:02:30 UTC
Created attachment 129109 [details]
Fix to gdb/gdbserver pause issue

This version of the patch has been tested and seems to work.
Comment 24 sehughes 2012-12-09 17:11:18 UTC
The patch I attached is based on the earlier patch  by gsmcmullin.

The issue with the earlier patch is that when running a gdb/gdbserver session you need to send a SIGINT to the host side gdb process.  In GdbDebuggerImpl.java "targetAttached" was being set when for remoteTarget.  As a result, the variant of the pause being called was the one to the process group, not the specific pid (in Gdb.java).

I'm not claiming this is the final fix, as I'm sure there was a reason for the "targetAttached" flag and I may therefore have broken something in another debugging scenario.

Anyhow for my specific test case of debugging a remote arm target with gdb/gdbserver it does work.
Comment 25 Leonid Lenyashin 2012-12-10 09:26:19 UTC
Egor, would you please review the proposed patch and if it is ok then help with the integration.
Comment 26 Egor Ushakov 2012-12-19 09:35:06 UTC
Thanks for the patch! Although it looks too dangerous for the rest of the debugging functionality, I've got the point. Will try to make less dangerous patch.
Comment 27 Egor Ushakov 2012-12-19 10:26:26 UTC
Created attachment 129535 [details]
proposed fix

could someone please verify that it works
Comment 28 Egor Ushakov 2012-12-20 13:42:37 UTC
should be fixed in:
http://hg.netbeans.org/cnd-main/rev/508e3aef0257

please try when available in NB dev build and reopen if it does not help
Comment 29 Quality Engineering 2012-12-22 02:28:39 UTC
Integrated into 'main-golden', will be available in build *201212220001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/508e3aef0257
User: Egor Ushakov <gorrus@netbeans.org>
Log: fixed #170488 - gdbserver: pause does not work
Comment 30 sehughes 2012-12-24 16:26:17 UTC
Hi Egor,

I just had a change to re-test the patches you posted.  Unfortunately they don't seem to work.

If you set a breakpoint and run, then you stop and re-stop at the breakpoint if you resume as expected.  However, if you then remove the breakpoint and resume and then try to pause, the pause action does not control the target.  This is the same behaviour as before: pause not being able to interrupt a running remote gdbserver session.

I tested this against release72_base.

Regards, Stuart.
Comment 31 sehughes 2012-12-24 16:28:30 UTC
Hi Egor,

I just had a chance to re-test the patches you posted.  Unfortunately they don't seem to work.

If you set a breakpoint and run, then you stop and re-stop at the breakpoint if you resume as expected.  However, if you then remove the breakpoint and resume and then try to pause, the pause action does not control the target.  This is the same behaviour as before: pause not being able to interrupt a running remote gdbserver session.

I tested this against release72_base.

Regards, Stuart.
Comment 32 henk89 2012-12-25 11:23:06 UTC
Could you, please, test the development build, as it seems to work. I tried debugging a sample application using gdbserver and was able to pause and continue the session.
Comment 33 Leonid Lenyashin 2012-12-25 14:49:48 UTC
Please test against 7.3 development build. We are not able to reproduce the issue after the fix was integrated.
Comment 34 sehughes 2012-12-25 21:41:34 UTC
I couldn't figure out how to build/run the Mercurial main-golden tip (I feel a bit stupid, I've asked Henk in an email reply).

Anyhow I downloaded the latest nightly build and re-tested, and I can confirm in my debugging scenario you cannot pause the remote target (as previously described).

Just so there's no confusion, here's what I'm doing:

1/ I create a test project with a single hello.c file:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char** argv) {
    int run = 1;
    while ( run ) {
        printf("hello world\n");
        sleep(1);
    }
    return (EXIT_SUCCESS);
}

2/ I build this using a cross compiler setup in code assistant (arm-linux-gcc) this is a gcc-4.2.4 soft-float toolchain.  I've also tried other versions on different ARM targets with the same issue (can't pause).

3/ I copy the executable to the target, which in this test is a Cirrus Logic EDB9302 development board.

4/ On the target I run: gdbserver :1234 hello

5/ On the netbeans host, I set a breakpoint at the printf line.

6/ With the gdbserver plugin installed, I click on "attach debugger" and enter the target IP address and port number

7/ As expected netbeans debugger stops at the breakpoint. If you click continue, the target will continue again until it again hits the breakpoint.

8/ I now disable (or remove) the breakpoint and click on continue, execution resumes as expected.

9/ I click on pause, nothing happens.  The host has lost control of the target.  The only way to get control back again is to find the pid of the host gdb executable and send it a SIGINT at the command line
Comment 35 Egor Ushakov 2012-12-26 07:02:14 UTC
Just in case, what is the host OS?
Comment 36 Vladimir Voskresensky 2012-12-26 08:37:04 UTC
Egor, Nikolay, can you attach 7.3based nbm of plug-in here for user to just try without need of full build of NB?
Comment 37 Egor Ushakov 2012-12-26 08:41:28 UTC
(In reply to comment #36)
> Egor, Nikolay, can you attach 7.3based nbm of plug-in here for user to just try
> without need of full build of NB?

all changes are in NB, so that will not help
Comment 38 sehughes 2012-12-26 10:29:44 UTC
(In reply to comment #35)
> Just in case, what is the host OS?

This test was on Linux: Ubuntu 9.10.  However I originally ran into the bug on a machine running Ubuntu 10.10.
Comment 39 soldatov 2012-12-26 19:23:00 UTC
(In reply to comment #34)
> Just so there's no confusion, here's what I'm doing:
I will see this scenario tomorrow
Comment 40 Egor Ushakov 2013-01-11 11:31:14 UTC
I start to think that it really depends on the platform, do fixes made so far helped anyone here? Please report if pause WORK for you. If NOT then please try the latest dev NB http://bits.netbeans.org/download/trunk/nightly/latest/ and write here the results WITH the platforms you're working on.
Also please try running gdbserver on the localhost and check if pause works in this case.
And really thanks to everyone, it is hard to find the root cause but without your help it is impossible.
Comment 41 TubaTim 2013-01-11 11:45:12 UTC
Just to say I only encountered this issue yesterday when I tried netbeans with gdbserver plugin for the first time.  With Netbeans 7.2 I encountered the problem of pause not working.  Having then seen this issue, I downloaded the nightly build 201301100107 and this fixed the issue for me.

My host platform is x86 i686 Ubuntu 10.04 (kernel 2.6.32), target is AMD Geode LX x86 i586 Gentoo (kernel 3.5.7), gdb 7.5, gcc 4.5.4.
Comment 42 Egor Ushakov 2013-01-11 11:57:34 UTC
(In reply to comment #41)
> Just to say I only encountered this issue yesterday when I tried netbeans with
> gdbserver plugin for the first time.  With Netbeans 7.2 I encountered the
> problem of pause not working.  Having then seen this issue, I downloaded the
> nightly build 201301100107 and this fixed the issue for me.
> 
> My host platform is x86 i686 Ubuntu 10.04 (kernel 2.6.32), target is AMD Geode
> LX x86 i586 Gentoo (kernel 3.5.7), gdb 7.5, gcc 4.5.4.

Perfect, thanks! It means that at least the latest fix works for some people!
Comment 43 Egor Ushakov 2013-01-14 10:26:16 UTC
It really looks like the problem is platform specific, or even depend on the combination of host-target platforms.
I will close this bug as fixed because the latest fix really helped some people (configurations), and this bug now contains too much irrelevant information. For those who still can reproduce it:
1. Try the latest developers build from: http://bits.netbeans.org/download/trunk/nightly/latest/
2. If the bug is still there try the latest gdb and gdbserver
3. If no success, please open a NEW BUG with as much details as you can: operating systems, gdb versions, gdb-log, etc.
Comment 44 sehughes 2013-01-14 10:52:09 UTC
Unfortunately, I just tried netbeans-dev-201301120001 and I can confirm that the pause bug had not been fixed (for me) in the scenario I describe in comment 34.

I'm not sure this is relevant, but the gdb I'm using is: GNU gdb (Wind River Linux Sourcery G++ 4.3-242).  This is not something I can change as I need to use the same toolchain for compile/link/debug.
Comment 45 Egor Ushakov 2013-01-14 11:32:10 UTC
Thanks! I've filed new bug 224840.
Please update that bug if needed.

(In reply to comment #44)
> Unfortunately, I just tried netbeans-dev-201301120001 and I can confirm that
> the pause bug had not been fixed (for me) in the scenario I describe in comment
> 34.
> 
> I'm not sure this is relevant, but the gdb I'm using is: GNU gdb (Wind River
> Linux Sourcery G++ 4.3-242).  This is not something I can change as I need to
> use the same toolchain for compile/link/debug.
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo