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 86067 - Source editor is not shown during Makefile based projects debugging
Summary: Source editor is not shown during Makefile based projects debugging
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: USABILITY
Depends on:
Blocks:
 
Reported: 2006-09-28 15:58 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 15:58:44 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. Add "main" function breakpoint.
10. Run debugger.
Debugger stoppes at args.c:9(you can see it in debugger console, in call stack
view), but editor was not shown.
Comment 1 Nikolay Molchanov 2006-10-03 23:47:25 UTC
This problem should have the same root, as the problem described in IZ 86069.
Comment 2 Nikolay Molchanov 2006-10-04 00:22:30 UTC
I fixed IZ 86069, so I mark this IZ FIXED. Feel free to reopen it if this 
problem is still reproducible. The fix will be avaiable in nightly build 10/04.
Comment 3 alexandrov 2006-10-04 10:28:37 UTC
Problem described in 86069 reduced to this one. This problem were not solved and
for line breakpoints the same problem is actual. Editor were not opened,
annotations for function bpts do not appear, current pc is invisible. 
I am increasing the priority of this bug, because from user point of view it
seems  debugger does not work at all. 
Comment 4 Nikolay Molchanov 2006-10-04 15:32:05 UTC
Please add the "Debugger Console" log to the bug report (all lines).
Comment 5 alexandrov 2006-10-05 17:53:11 UTC
here is the debugger console log:

Start debugger gdb
gdb_cmd=gdb --nw --interpreter=mi --tty /dev/pts/10
~"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 \"i686-pc-linux-gnu\"."
~"\n"
(gdb) 
212-file-exec-and-symbols /export/home/tester/1/args
~"Using host libthread_db library \"/lib/tls/libthread_db.so.1\".\n"
212^done
directory /export/home/tester/1
(gdb) 
&"directory /export/home/tester/1\n"
502-break-insert main
^done
(gdb) 
502^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x080483e8",func="main",file="args.c",line="10",times="0"}
(gdb) 
-exec-run 
^running
(gdb) 
*stopped,reason="breakpoint-hit",bkptno="1",thread-id="0",frame={addr="0x080483e8",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbfffe5d4"}],file="args.c",line="10"}
(gdb) 
info proc
&"info proc\n"
~"process 5909\n"
-stack-list-locals --all-values
~"cmdline = '/export/home/tester/1/args'\n"
~"cwd = '/home/aa157712/MakefileProject6'\n"
-stack-list-locals --simple-values
~"exe = '/export/home/tester/1/args'\n"
^done
-stack-list-frames
(gdb) 
^done,locals=[{name="i",value="1075006456"},{name="line",value="\"\\214K\\023@4\\345\\377\\277H\\345\""}]
(gdb) 
^done,locals=[{name="i",type="int",value="1075006456"},{name="line",type="char
[10]"}]
(gdb) 
^done,stack=[frame={level="0",addr="0x080483e8",func="main",file="args.c",line="10"}]
(gdb) 
Comment 6 Nikolay Molchanov 2006-10-06 10:10:21 UTC
The root of the problem is that old gdb versions did not report fullname:

-stack-list-frames
(gdb) 
^done,stack=[frame={level="0",addr="0x080483e8",func="main",file="args.c",line="10"}]

As a result gdb-lite could not pass correct filename to the editor.
The suggested fix is to check if fullname is reported, and if not, use 
additional command ("-file-list-exec-source-file") to get fullname.

The fix is integrated in "release55" branch, and will be available in nightly
build 10/07.

Comment 7 alexandrov 2006-10-09 14:09:21 UTC
Nik, problem disappeared only for Windows where is gdb 6.5 should be supported.
But for Linux with gdb 6.1 and for Solaris with gdb 6.2 it is still alive.
Here is the log for gdb 6.1:

Start debugger gdb
gdb_cmd=gdb --nw --interpreter=mi --tty /dev/pts/10
~"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 \"i686-pc-linux-gnu\"."
~"\n"
(gdb) 
212-file-exec-and-symbols /export/home/tester/1/args
~"Using host libthread_db library \"/lib/tls/libthread_db.so.1\".\n"
212^done
directory /export/home/tester/1
(gdb) 
&"directory /export/home/tester/1\n"
501-break-insert /export/home/tester/1/args.c:10
^done
(gdb) 
501^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x080483e8",func="main",file="args.c",line="10",times="0"}
(gdb) 
-exec-run 
^running
(gdb) 
*stopped,reason="breakpoint-hit",bkptno="1",thread-id="0",frame={addr="0x080483e8",func="main",args=[{name="argc",value="1"},{name="argv",value="0xbfffe554"}],file="args.c",line="10"}
(gdb) 
info proc
&"info proc\n"
~"process 1494\n"
-stack-list-locals --all-values
~"cmdline = '/export/home/tester/1/args'\n"
~"cwd = '/home/aa157712/MakefileProject7'\n"
-stack-list-locals --simple-values
~"exe = '/export/home/tester/1/args'\n"
^done
215-file-list-exec-source-file
(gdb) 
^done,locals=[{name="i",value="1075006456"},{name="line",value="\"\\214K\\023@\\264\\344\\377\\277\\310\\344\""}]
(gdb) 
^done,locals=[{name="i",type="int",value="1075006456"},{name="line",type="char
[10]"}]
(gdb) 
215^done,line="10",file="args.c",fullname="/export/home/tester/1/args.c"
(gdb) 
-stack-list-frames
^done,stack=[frame={level="0",addr="0x080483e8",func="main",file="args.c",line="10"}]
(gdb) 


Though file-list-exec-source-file were added annotation, current pc do not appear...
Comment 8 Nikolay Molchanov 2006-10-10 00:45:14 UTC
I reproduced the problem, so I reopen this issue.
Comment 9 Nikolay Molchanov 2006-10-11 04:12:03 UTC
I changed my fix a little, and it seems to better now. So I mark this IZ FIXED.
Please, try nightly build, and feel free to reopen this issue, if there is
still a problem. The fix is integrated in "release55" branch, and will be 
available in build 10/11/2006.


Tag: release55
User: NikMolchanov
Date: 2006/10/10 16:54:14

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

Log:
 IZ 86067 Source editor is not shown during Makefile based projects debugging
 - Simulate "correct" gdb output.

File Changes:

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

File [changed]: GdbProxyVL.java
Url:
http://cnd.netbeans.org/source/browse/cnd/gdb/src/org/netbeans/modules/cnd/debugger/gdb/GdbProxyVL.java?r1=1.2.2.13&r2=1.2.2.14
Delta lines:  +6 -2
-------------------
--- GdbProxyVL.java	10 Oct 2006 23:12:30 -0000	1.2.2.13
+++ GdbProxyVL.java	10 Oct 2006 23:54:12 -0000	1.2.2.14
@@ -208,16 +208,20 @@
      */
     public void reportStackUpdate(String info) {
         if (gdbProxy.gdbSupport != null) {
-            List CallStackList =  createListFromString(info);
+            // Check if fullname is reported
             String fullname = null;
             String key = "fullname"; // NOI18N
             int i = info.indexOf("\"," + key + "=\""); // NOI18N
             if (i < 0) {
+                // Simulate "correct" gdb output.
                 if (saveCallStackMap != null) {
                     fullname = (String) saveCallStackMap.get(key);
-                    CallStackList.add(key + "=" + fullname); // NOI18N
                 }
+                String s1 = info.substring(0, info.length() -2);
+                String s2 = info.substring(info.length() -2);
+                info = s1 + "\"," + key + "=\"" + fullname +s2; // NOI18N
             }
+            List CallStackList =  createListFromString(info);
             gdbProxy.gdbSupport.stackUpdate(CallStackList);
         }
     }

---------------------------------------------------------------------
Comment 10 Nikolay Molchanov 2006-10-20 09:38:04 UTC
I found out that this issue was not completely fixed. The fix worked only in
main(), but did not show PC pointer (green arrow) in called functions. 
I modified the fix and now it works correct (at least with my tests).

Tag: release55
User: NikMolchanov
Date: 2006/10/19 22:34:20

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

Log:
 IZ 86067 Source editor is not shown during Makefile based projects debugging
 - Corrected previous fix. Now it works in called functions as well, not just in
main())

File Changes:

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

File [changed]: GdbProxyVL.java
Url:
http://cnd.netbeans.org/source/browse/cnd/gdb/src/org/netbeans/modules/cnd/debugger/gdb/GdbProxyVL.java?r1=1.2.2.15&r2=1.2.2.16
Delta lines:  +35 -25
---------------------
--- GdbProxyVL.java	11 Oct 2006 21:42:10 -0000	1.2.2.15
+++ GdbProxyVL.java	20 Oct 2006 05:34:17 -0000	1.2.2.16
@@ -128,7 +128,8 @@
     }
     
     long startTimeLocals = 0; //DEBUG
-    private Map saveCallStackMap = null;
+    private String saveCallStack = null;
+    private String saveFullName = null;
     /**
      * Reports that program is stopped
      *
@@ -137,7 +138,6 @@
     public void reportProgramStopped(String message) {
         // Code to measure performance
         startTimeLocals = System.currentTimeMillis(); // DEBUG
-        saveCallStackMap = createMapFromString(message);
         if (gdbProxy.gdbProxyCL.programStatus != gdbProxy.gdbProxyCL.EXITED) {
             // Send request to get local variables
             gdbProxy.gdbProxyCL.stack_list_locals(ALL_VALUES);
@@ -149,12 +149,13 @@
                 // Usually it happens if old gdb versions are used (6.2 or older)
                 // Send request to get source file name and report when reply
is ready
                 gdbProxy.gdbProxyCL.file_list_exec_source_file();
+                saveCallStack = message;
                 return;
             }
         }
         // Tell upper level that program is stopped
         if (gdbProxy.gdbSupport != null) {
-            gdbProxy.gdbSupport.stopped(saveCallStackMap);
+            gdbProxy.gdbSupport.stopped(createMapFromString(message));
         }
     }
     /**
@@ -174,14 +175,22 @@
         if (i > 0) {
             int j = message.indexOf(pattern2);
             if (j > i) {
-                fullname = message.substring(i + pattern1.length(), j);
+                fullname = message.substring(i + 2, j + 1);
+                saveFullName = fullname;
+            }
+        }
+        // Add fullname to the saved Call Stack string
+        String s = saveCallStack;
+        if (s != null) {
+            String pattern3 = ",file=\""; // NOI18N
+            i = s.indexOf(pattern3);
+            if (i > 0) {
+                s = s.substring(0, i + 1) + fullname + s.substring(i);
             }
         }
-        String key = "fullname"; // NOI18N
-        saveCallStackMap.put(key, fullname);
         // Tell upper level that program is stopped
         if (gdbProxy.gdbSupport != null) {
-            gdbProxy.gdbSupport.stopped(saveCallStackMap);
+            gdbProxy.gdbSupport.stopped(createMapFromString(s));
         }
     }
     
@@ -209,17 +218,15 @@
     public void reportStackUpdate(String info) {
         if (gdbProxy.gdbSupport != null) {
             // Check if fullname is reported
-            String fullname = null;
-            String key = "fullname"; // NOI18N
-            int i = info.indexOf("\"," + key + "=\""); // NOI18N
+            int i = info.indexOf(",fullname="); // NOI18N
             if (i < 0) {
                 // Simulate "correct" gdb output.
-                if (saveCallStackMap != null) {
-                    fullname = (String) saveCallStackMap.get(key);
+                if (saveFullName != null) {
+                    i = info.indexOf(",file="); // NOI18N
+                    if (i > 0) {
+                        info = info.substring(0, i + 1) + saveFullName +
info.substring(i);
+                    }
                 }
-                String s1 = info.substring(0, info.length() -2);
-                String s2 = info.substring(info.length() -2);
-                info = s1 + "\"," + key + "=\"" + fullname +s2; // NOI18N
             }
             List CallStackList =  createListFromString(info);
             gdbProxy.gdbSupport.stackUpdate(CallStackList);
@@ -257,6 +264,9 @@
      *  Parse the input string for key=value pairs. The keys are not unique 
      *  and the order is very important. Each value is extracted and stored
      *  in an ArrayList as a 3-Strings entry for each variable (name, type, value)
+     *  Input formats:
+     *   {name="A",type="int",value="1"},{name="A",type="int",value="1"},...
+     *   {name="a",value="{fa = 1}"},{name="b",value="{fs1 = {fa = 2}}"},...
      *
      *  @param info A string of key=value pairs. Format
{name="A",type="int",value="1"},...
      *

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