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 86069 - toggle(line) breakpoints are ignored in makefile-based projects.
Summary: toggle(line) breakpoints are ignored in makefile-based projects.
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 5.x
Hardware: All All
: P1 blocker (vote)
Assignee: Nikolay Molchanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-28 16:14 UTC by alexandrov
Modified: 2009-06-25 10:59 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description alexandrov 2006-09-28 16:14:23 UTC
Lets assume the next example:
1. mkdir /export/home/tester/1
2. cd /export/home/tester/1
3. vi args.c
-----------------------------------------
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char**argv) {
    int i;
    
    // Prints arguments
    printf("Arguments:\n");
    for (i = 0; i < argc; i++) {
        printf("%i: %s\n", i, argv[i]);
    }
    
    return 0;
}
-----------------------------------------

4. vi Makefile

---------------------------------
args: args.c
    gcc -g -o args args.c
----------------------------------

5. Start Netbeans
6. New project with existing Makefile
6.1 Project Name and Location set default(project location is ~/MakefileProject1)
6.2 Build actions: choose Working directory: /export/home/tester/1
Build command: make
Output file: args
6.3 On "Source File Folders" add /export/home/tester/1
Click Finish.
7. Build project
8. Due to IZ 86064 we need to point output file in project properties by hands.
Open Properties/Configuration Properties/Make, set "/export/home/tester/1/args"
in Output property.  
9. Open args.c in editor. Set Toggle breakpoint at line 10.
10.  Run debugger. It ignores breakpoint and just execute the program
Comment 1 Nikolay Molchanov 2006-10-02 07:05:32 UTC
It looks like this problem is not reproducible on Windows, so there is
some Unix specific (file name?). I'll check it out tomorrow on Solaris.
Alexander, if you still can reproduce this problem, could you please add 
all messages, that you see in "Debugger Console", to this bug report?
(to stop the program you can set a function breakpoint on "_exit").
Comment 2 alexandrov 2006-10-02 08:14:40 UTC
Nik, problem is still reproduced on Linux-machine, exactly on sqao35.
gdb output is the next:

Start debugger gdb
gdb_cmd=gdb --nw --interpreter=mi --tty /dev/pts/3
~"GNU gdb Red Hat Linux (6.1post-1.20040607.41rh)\n"
~"Copyright 2004 Free Software Foundation, Inc.\n"
~"GDB is free software, covered by the GNU General Public License, and you are\n"
~"welcome to change it and/or distribute copies of it under certain conditions.\n"
~"Type \"show copying\" to see the conditions.\n"
~"There is absolutely no warranty for GDB.  Type \"show warranty\" for details.\n"
~"This GDB was configured as \"i386-redhat-linux-gnu\"."
~"\n"
(gdb)
212-file-exec-and-symbols /export/home/tester/MakefileProject5/../1/args
~"Using host libthread_db library \"/lib/tls/libthread_db.so.1\".\n"
212^done
501-break-insert /export/home/tester/1/args.c:10
(gdb)
&"No source file named /export/home/tester/1/args.c.\n"
501^error,msg="No source file named /export/home/tester/1/args.c."
(gdb)
-exec-run
^running
(gdb)


To receive this output I've included program stopper line: scanf(); after
breakpoint. In other cases Debugger Console were immediately closed as program
finished.
Comment 3 alexandrov 2006-10-02 08:18:57 UTC
function breakpoint on _exit is also ignored...
Comment 4 Nikolay Molchanov 2006-10-03 05:07:07 UTC
Yes, there is no _exit function. You can try to set function breakpoint 
in _fini function.
Comment 5 Nikolay Molchanov 2006-10-03 05:14:51 UTC
I investigated the problem, and it seems that the root of it is in some bug in 
gdb 6.1 - it does not work properly with filename in "-break-insert" command.

It works properly in one case: when current directory is the same where the
executable is. Please take a look at 2 scenarios below: in first case gdb
works just fine, in second case it failed. The only difference is that in
second case I changed current directory to "/".
Alexander, could you please try a small test? Do the same steps as you
described, and when program hangs on scanf(), interrupt it with Ctrl-C (or send
-INT signal to args process). After that gdb will stop the program, and you
can type in commands in "Debugger Console" window. Type in the following 
commands in "Debugger Console" input text field:

cd  /export/home/tester/1

shell pwd

501-break-insert /export/home/tester/1/args.c:10

-exec-run

This should set the breakpoint, restart the execution, and it should stop 
at breakpoint.



============ Scenario 1 ===================

sside-linux tester/1> pwd
/export/home/tester/1

sside-linux tester/1> ls -l
-rwxrwxr-x  1 nikm wheel 13141 2006-10-02 17:25 args
-rw-rw-r--  1 nikm wheel   389 2006-10-02 17:25 args.c
-rw-rw-r--  1 nikm wheel    62 2006-10-02 17:25 Makefile

sside-linux tester/1> gdb --nw --interpreter=mi --tty /dev/pts/6
~"GNU gdb 6.1\n"
~"Copyright 2004 Free Software Foundation, Inc.\n"
~"GDB is free software, covered by the GNU General Public License, and you are\n"
~"welcome to change it and/or distribute copies of it under certain conditions.\n"
~"Type \"show copying\" to see the conditions.\n"
~"There is absolutely no warranty for GDB.  Type \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-suse-linux\"."
~"\n"
(gdb)
212-file-exec-and-symbols /export/home/tester/1/args
~"Using host libthread_db library \"/lib64/tls/libthread_db.so.1\".\n"
212^done
(gdb)
501-break-insert /export/home/tester/1/args.c:10
501^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000
0000004005a0",func="main",file="args.c",line="10",times="0"}
(gdb)

============ Scenario 2 ===================

sside-linux tester/MakefileProject5> cd /
Directory: /

sside-linux /> gdb --nw --interpreter=mi --tty /dev/pts/6
~"GNU gdb 6.1\n"
~"Copyright 2004 Free Software Foundation, Inc.\n"
~"GDB is free software, covered by the GNU General Public License, and you are\n"
~"welcome to change it and/or distribute copies of it under certain conditions.\n"
~"Type \"show copying\" to see the conditions.\n"
~"There is absolutely no warranty for GDB.  Type \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-suse-linux\"."
~"\n"
(gdb)
212-file-exec-and-symbols /export/home/tester/1/args
~"Using host libthread_db library \"/lib64/tls/libthread_db.so.1\".\n"
212^done
(gdb)
501-break-insert /export/home/tester/1/args.c:10
&"No source file named /export/home/tester/1/args.c.\n"
501^error,msg="No source file named /export/home/tester/1/args.c."
(gdb)
==================================================================

Comment 6 alexandrov 2006-10-03 16:40:07 UTC
I have gdb 6.2.1 on my local machine. Your scenarios have the same output on gdb
6.2.1
And I don't know how to send INT signal to debugged process. I do not see the
process args or any new processes after starting debugger in my process
list(command "top"). And in the Runtime window of Netbeans there is no debugged
process in "Processes"(for Java debugging processes I can see new 'java' process
in top comand and 'debug' process in Runtime window)...  
Comment 7 Nikolay Molchanov 2006-10-03 23:16:09 UTC
I found out that we can help gdb to find source files. There is special
command "directory":

directory -- Add directory DIR to beginning of search path for source files

The suggested fix is to pass the following command to gdb before setting
breakpoints:

  directory /...

where "/..." is the directory name where executable is.
I verified that the fix works just fine on Linux with gdb 6.1.
The fix is integrated in "release55" branch.

--------------------------------------------------------------

Tag: release55
User: NikMolchanov
Date: 2006/10/03 15:03:03

Modified:
   cnd/gdb/src/org/netbeans/modules/cnd/debugger/gdb/GdbProxyCL.java

Log:
 IZ 86069 toggle(line) breakpoints are ignored in makefile-based projects.
 - Added "directory" setting to help gdb 6.1 and gdb 6.2 to find source file.

File Changes:

Directory: /cnd/gdb/src/org/netbeans/modules/cnd/debugger/gdb/
==============================================================

File [changed]: GdbProxyCL.java
Url:
http://cnd.netbeans.org/source/browse/cnd/gdb/src/org/netbeans/modules/cnd/debugger/gdb/GdbProxyCL.java?r1=1.2.2.10&r2=1.2.2.11
Delta lines:  +16 -3
--------------------
--- GdbProxyCL.java	1 Oct 2006 01:52:14 -0000	1.2.2.10
+++ GdbProxyCL.java	3 Oct 2006 22:03:00 -0000	1.2.2.11
@@ -362,6 +362,17 @@
         // Tell low level to send the command to the debugger
         reply = gdbProxy.gdbProxyML.sendCommand(cmd);
         if ( reply != null) return reply;
+        // Set directory for search path (for gdb 6.1 and gdb 6.2)
+        if (!isWindows) {
+            int i = program.lastIndexOf('/');
+            if (i >= 0) {
+                if (gdbVersion.startsWith("6.1") || gdbVersion.startsWith("6.2")) {
+                    String directory = "directory "; // NOI18N
+                    directory += program.substring(0, i); // IZ 86069
+                    gdbProxy.gdbProxyML.sendCommand(directory);
+                }
+            }
+        }
         // Set external terminal (not implemented yet)
         // -inferior-tty-set /dev/pts/1
         // -inferior-tty-show
@@ -1816,9 +1827,11 @@
             gdbVersion=message.substring(s1.length());
             //log.fine("DEBUG: extractGdbVersion gdbVersion = "+gdbVersion); //
DEBUG
         }
+        if (isWindows) {
 	if (message.toLowerCase().contains("cygwin")) {
 	    gdbIsCygwin = true;
 	}
+        }
     }
     
     /**

---------------------------------------------------------------------
Comment 8 alexandrov 2006-10-04 10:21:11 UTC
ok, debugger became working, but no annotations, no current pc appears as it
described for function breakpoints in 86067