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 248616 - gdbserver: pause and breakpoint does not work for a running code, OS is Windows 7.
Summary: gdbserver: pause and breakpoint does not work for a running code, OS is Windo...
Status: NEW
Alias: None
Product: cnd
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 8.0
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Assignee: Maria Tishkova
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-13 10:32 UTC by nitishp
Modified: 2016-07-06 14:38 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
C Program containing infinte while loop without any printf statements. (188 bytes, application/octet-stream)
2014-12-19 06:08 UTC, nitishp
Details
C program with infinite loop with printf statements (274 bytes, application/octet-stream)
2014-12-19 06:09 UTC, nitishp
Details
MinGw Gdb-GdbServer (locally) log for debugWithoutPrintf.c using externalTerminal (10.90 KB, application/octet-stream)
2014-12-19 06:10 UTC, nitishp
Details
MinGw Gdb-Gdbserver(locally)log for debugWithPrintf using internalTerminal (11.22 KB, application/octet-stream)
2014-12-19 06:11 UTC, nitishp
Details
MinGw Gdb-GdbSever (locally) log for debugWithoutPrintf using internalTerminal (11.34 KB, application/octet-stream)
2014-12-19 06:12 UTC, nitishp
Details
MinGw Gdb-norma local debugging log for debugWithPrintf.c using internalTerminal (927.59 KB, application/octet-stream)
2014-12-19 06:21 UTC, nitishp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nitishp 2014-11-13 10:32:56 UTC
Hi, 
I am new to the community, so please forgive me if i have made any mistake in composing this mail.

I know there is a similar bug filed for linux i.e Bug Number: 224840.

This is a very high priority issue in our project using netbeans(I cannot reveal the project details as its internal), so any help or tips is appreciated.
 
After connecting gdb to gdbserver (via attachDebugger), if run the code without any breakpoints, i am unable to pause or even add breakpoints at run time.Due to this behaviour i can no longer control the target.This behaviour was observed in MinGw, cygwin & arm-none-eabi-gdb.exe.

I even observed this behaviour in normal localhost debugging, after analysing for a whole day i found that if the output terminal is "Internal" the pause and breakpoint is not working, but by changing the Output terminal to "External" or "Standard output" then its working.It seems the windows interrupt goes correctly to the external terminal based output but not for internal terminal (i.e console inside netbeans).I tried the same steps as above in gdbserver but it did not work.

 
OS: Windows 7
compiler : 
     MinGW v4.8.1, cygwin v4.8.2, arm-none-eabi-gcc 4.8.3 20140228 (release)
Gdb:
     MinGW-gdb v7.6.1, cygwin-gdb 7.6.50.20130728-cvs, 
     arm-none-eabi-gdb  7.6.0.20140228-cvs.
Gdbserver: 
     MingGw-gdbserver v7.6.1, 

The sample application used for testing is :
-------------------------------------------------------
main.c
-------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>

void foo() {
    printf("Hello world");
}

/*
 * 
 */
int main(int argc, char** argv) {
    int i = 0;
    while (1) {
        i++;
        if (i % 6 == 0) {
            foo();
        }
    }
    return (EXIT_SUCCESS);
}


After analysing the netbens "org.netbeans.modules.cnd.debugger.common2" source code i found that the pause in windows triggers a Windows interrupt via the application "GdbKillProc.ex" present inside the "netbeans_installed_loc/cnd/bin/".I thought by changing its code as below it would work, the code works in normal way however the the bug was still there.

----------------------------------
GdbKillProc.c
----------------------------------

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif

#include <Windows.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    unsigned pid = (unsigned) strtol(argv[3], NULL, 0);
    if (pid == 0) {
        printf("Process not found, returning 1.");
	return 1;
    }
    HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD) pid);
    if (proc == NULL) {
        printf("Process not found, returning 2.");
	return 2;
    }
//    if (!DebugBreakProcess(proc)) {
//	return 3;
//    }
    int rc = -1;
    while(rc == -1) {
        rc = DebugBreakProcess(proc);
        if (rc == -1)
            Sleep(10);
    }    
    printf("Success.");
    CloseHandle(proc);
    return 0;
}


Is the pause & breakpoint event lost when we run a code (without any intial breakpoint)?

Due to this bug i am unable to do normal debugging in my project.
Since this a high priority issue for my project any help would be greatly appreciated.

Thank you.
Comment 1 nitishp 2014-11-14 04:51:39 UTC
This bug was observed in netbeans 7.4, 8.0 and 8.0.1
Comment 2 nitishp 2014-11-24 06:44:33 UTC
Any updates regarding this issue?
Comment 3 nitishp 2014-12-17 11:14:13 UTC
Is there any updates regarding this bug?

Any workarounds would be gladly appreciated.
Comment 4 nitishp 2014-12-19 06:08:44 UTC
Created attachment 151196 [details]
C Program containing infinte while loop without any printf statements.
Comment 5 nitishp 2014-12-19 06:09:37 UTC
Created attachment 151197 [details]
C program with infinite loop with printf statements
Comment 6 nitishp 2014-12-19 06:10:19 UTC
Created attachment 151198 [details]
MinGw Gdb-GdbServer (locally) log for debugWithoutPrintf.c using externalTerminal
Comment 7 nitishp 2014-12-19 06:11:10 UTC
Created attachment 151199 [details]
MinGw Gdb-Gdbserver(locally)log for debugWithPrintf using internalTerminal
Comment 8 nitishp 2014-12-19 06:12:03 UTC
Created attachment 151200 [details]
MinGw Gdb-GdbSever (locally) log for debugWithoutPrintf using internalTerminal
Comment 9 nitishp 2014-12-19 06:21:46 UTC
Created attachment 151201 [details]
MinGw Gdb-norma local debugging log for debugWithPrintf.c using internalTerminal
Comment 10 nitishp 2014-12-19 06:28:13 UTC
I have currently provided the issue logs corresponding to MinGw, 

I do not have the setup of cygwin and arm-none-eabi-gdb.exe for providing the log files however I know both suffer from the same sort of issues.
 
Debugging steps done on a program that runs a infinite while loop (program is attached below)
 
Prerequisite: When debugging is started, the code runs continuously without any breakpoints

 
Local debugging (without gdbserver):
--------------------------------------------
  	Using Internal terminal:       
		First program debugWithoutPrintf.c works fine.
        
		For second program debugWithPrintf.c (there is a printf being printed in the code)
            		    Pause button does not work
                 	    Breakpoint addition does not work.	 
			    Log file: gdb-normalDebugging-MinGw-debugWithPrintf-internalTerminal.log 
 
                        
	Using External terminal:
       		 Both debugWithPrintf.c and debugWithoutPrintf.c works fine.
 
	Using Standard output:
		Both debugWithPrintf.c and debugWithoutPrintf.c works fine.
 

Debugging locally using MinGw-gdbserver:
----------------------------------------------------

  Using Internal terminal:

	First program debugWithoutPrintf.c:
		Pause button does not work
		Breakpoint addition does not work.	

		Error in terminal:
			C:\MinGW\bin>gdbserver.exe localhost:3333  D:\programs\DebugWithoutPrintf\dist\Debug\MinGW-Windows\debugwithoutprintf.exe
			Process D:\programs\DebugWithoutPrintf\dist\Debug\MinGW-Windows\debugwithoutprintf.exe created; pid = 2852
			Listening on port 3333
			Remote debugging from host 127.0.0.1
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')	
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			
		Log file: : gdb-gdbSeverLocal-MinGw-debugWithoutPrintf-internalTerminal.log 
 
	
	Second program debugWithPrintf.c:
		Pause button does not work
		Breakpoint addition does not work.

		Error in terminal:
			C:\MinGW\bin>gdbserver.exe localhost:3333  D:\programs\DebugWithoutPrintf\dist\Debug\MinGW-Windows\debugwithoutprintf.exe
			Process D:\programs\DebugWithoutPrintf\dist\Debug\MinGW-Windows\debugwithoutprintf.exe created; pid = 2852
			Listening on port 3333
			Remote debugging from host 127.0.0.1
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')	
			input_interrupt, count = -1 c = 0 (' ')
			input_interrupt, count = -1 c = 0 (' ')

		Log file: gdb-gdbServerLocal-MinGw-debugWithPrintf-internalTerminal.log 


	The same problem occurs for external and standard output

		Log file: gdb-gdbServerLocal-MinGw-debugWithoutPrintf-externalTerminal.log 


I have attached all the log files and the c files.