Home » Language IDEs » C / C++ IDE (CDT) » Debugger issues with input functions
Debugger issues with input functions [message #234840] |
Sat, 13 June 2009 17:03 |
John Dell'Oso Messages: 8 Registered: July 2009 |
Junior Member |
|
|
Hello,
I'm experiencing issues with the debugger when debugging code that
contains input functions such as scanf() or gets().
Here's a sample of the code that I'm running through the debugger:
#include <stdio.h>
int main() {
char *name;
setvbuf(stdout, NULL, _IONBF, 0);
printf("What's your name? ");
gets(name);
printf("Hello %s!", name);
return 0;
}
I step through this code snippet and when I reach the gets() line the
following line appears in the Console View:
What's your name?
776*stopped,reason="end-stepping-range",reason="breakpoint-hit ",bkptno="3",thread-id="1",frame={addr="0x0040134e",func= "main",args=[],file="../src/getname.c",fullname="D:/eclipse/workspace/misc-c/Debug/../src/getname.c ",line="17"}
The same result occurs if I use a scanf() call in place of the gets() call.
From here, the debugger just seems to hang. However, I can enter input
into the console view - when I do this - an error dialog appears -->
"Execution is suspended because of error". My only recourse is to kill
the debug session and on the very rare occasion, Eclipse itself goes into
"la la" land and I have to kill Eclipse and restart.
From the research I have done, the output that appears in the console view
is output one would expect when running gdb with the MI protocol.
Has anyone experienced this behaviour with the debugger? Any suggestions
as to what the issue is and how to rectify it would be gratefully accepted.
Cheers
JD
|
|
| |
Re: Debugger issues with input functions [message #235660 is a reply to message #234840] |
Sat, 11 July 2009 04:34 |
John Dell'Oso Messages: 8 Registered: July 2009 |
Junior Member |
|
|
Well it's now been 28 days since my original post and still no response as
to why this issue regarding the debugger and input functions occurs.
Since my last post (response) I have installed Eclipse Galileo and the CDT
(version 6.0) and the problem still exists.
So here's the dinky little code snippet I'm having problems using the
debugger with:
int main(void) {
char name[30];
setvbuf(stdout, NULL, _IONBF, 0);
printf("What's your name? ");
fgets(name, 30, stdin);
printf("Hello %s", name);
return 0;
}
As stated in my original post, as soon as the debugger hits the first
printf line, I get the output stipulated in my original post in the
Console view - from there nothing works at all in the debugger and I have
to abort the debug session.
Would someone please mind trying the above code snippet out with the
debugger out to see if they get the same results as me?
Regards,
JD
|
|
| | |
Re: Debugger issues with input functions [message #235724 is a reply to message #235695] |
Mon, 13 July 2009 13:25 |
John Dell'Oso Messages: 8 Registered: July 2009 |
Junior Member |
|
|
Marc Khouzam wrote:
> I just figured it out.
> In the launch configuration's main tab, you have to select the option at
> the bottom that says "Connect process input_output to a terminal"
> I can reproduce your problem when I don't have that option checked.
> Once you try this, make sure you see the correct console by using the
> drop-down arrow in the console view. You want to use the console created
> for your application to type your input.
> Marc
> P.S. You can also try the new DSF-GDB debugger. The 'console' option has
> been removed from that debugger integration, and you always get your
> processes output to a console.
Marc,
Thank you for your response.
In my Main tab on the Debug Configurations dialog, the "Connect process
input output to a terminal" option is checked by default and grayed out.
I'm using the MinGW tool chain with my setup and I have four options for
choosing the debugger under the Debugger tab:
- gdb Debugger
- gdb/mi
- gdbserver Debugger
- MinGW gdb Debugger
I've now tried all debugger options and the only one I can get to work is
gdb/mi with "GDB command set" set to "Standard". When I debug with this
configuration, a terminal window runs and my console application runs in
this window during the debug session. There is a Console view in Eclipse
for my application but it remains empty during the debug session. Other
configurations produce the same results as stated in my previous posts.
I've tried The DSF and unfortunately I observe the same behaviour as
outlined in my original post.
Perhaps someone can test on a Windows machine.
Anyway, thanks again for your help Marc, I'm in a better position than I
was a few days ago.
Cheers,
JD
|
|
| |
Re: Debugger issues with input functions [message #235771 is a reply to message #235764] |
Tue, 14 July 2009 11:37 |
John Dell'Oso Messages: 8 Registered: July 2009 |
Junior Member |
|
|
Marc,
Thanks again for your interest in my issue. Here's the output from the
gdb traces console when launching with DSF (towards the end you'll see
that I had to abort the session):
369,500 1source .gdbinit
369,515 &"source .gdbinit\n"
369,515 &".gdbinit: No such file or directory.\n"
369,515 1^error,msg=".gdbinit: No such file or directory."
369,515 (gdb)
369,515 2-file-exec-and-symbols
D:/eclipse/eclipse/workspace/misc-c/Debug/misc.exe
369,546 2^done
369,546 3-environment-cd D:/eclipse/eclipse/workspace/misc-c
369,546 (gdb)
369,562 3^done
369,562 (gdb)
369,562 4-gdb-set auto-solib-add on
369,578 4^done
369,578 (gdb)
369,625 5-environment-directory D:/eclipse/eclipse/workspace/misc-c
D:/eclipse/eclipse/workspace/mis\
c-c/Debug D:/eclipse/eclipse/workspace/misc-c/Debug/src
D:/eclipse/eclipse/workspace/misc-c/src
369,625
5^done,source-path=" D:/eclipse/eclipse/workspace/misc-c;D:/eclipse/eclipse/works pace/misc-c/\
Debug;D:/eclipse/eclipse/workspace/misc-c/Debug/src;D:/eclip se/eclipse/workspace/misc-c/src;$cdir;$c\
wd"
369,640 (gdb)
369,640 6-break-insert getname.c:19
369,640 7-break-insert getname.c:14
369,640 8-break-insert getname.c:16
369,640 9-break-insert getname.c:18
369,640 10-break-insert getname.c:17
369,656
6^done,bkpt={number="1",type="breakpoint",disp="keep",enabled= "y",addr="0x0040137d",func="ma\
in",file="../src/getname.c",fullname="D:/eclipse/eclipse/workspace/misc-c/Debug/../src/getname.c ",li\
ne="19",times="0"}
369,671 (gdb)
369,671
7^done,bkpt={number="2",type="breakpoint",disp="keep",enabled= "y",addr="0x0040131a",func="ma\
in",file="../src/getname.c",fullname="D:/eclipse/eclipse/workspace/misc-c/Debug/../src/getname.c ",li\
ne="14",times="0"}
369,687 (gdb)
369,703
8^done,bkpt={number="3",type="breakpoint",disp="keep",enabled= "y",addr="0x00401342",func="ma\
in",file="../src/getname.c",fullname="D:/eclipse/eclipse/workspace/misc-c/Debug/../src/getname.c ",li\
ne="16",times="0"}
369,718 (gdb)
369,765
9^done,bkpt={number="4",type="breakpoint",disp="keep",enabled= "y",addr="0x0040136a",func="ma\
in",file="../src/getname.c",fullname="D:/eclipse/eclipse/workspace/misc-c/Debug/../src/getname.c ",li\
ne="18",times="0"}
369,765 (gdb)
369,781
10^done,bkpt={number="5",type="breakpoint",disp="keep",enabled= "y",addr="0x0040134e",func="m\
ain",file="../src/getname.c",fullname="D:/eclipse/eclipse/workspace/misc-c/Debug/../src/getname.c ",l\
ine="17",times="0"}
369,781 (gdb)
369,781 11-break-insert -t main
369,796
11^done,bkpt={number="6",type="breakpoint",disp="del",enabled= "y",addr="0x00401315",func="ma\
in",file="../src/getname.c",fullname="D:/eclipse/eclipse/workspace/misc-c/Debug/../src/getname.c ",li\
ne="10",times="0"}
369,812 (gdb)
369,812 12-exec-run
369,812 12^running
369,812 (gdb)
369,968 ~"[New thread 568.0xb8]\n"
372,234
12*stopped,thread-id="1",frame={addr="0x00401315",func="main ",args=[],file="../src/getname.c\
",fullname="D:/eclipse/eclipse/workspace/misc-c/Debug/../src/getname.c ",line="10"}
372,234 (gdb)
372,500 13-thread-list-ids
372,515 13^done,thread-ids={thread-id="1"},number-of-threads="1"
372,515 (gdb)
372,531 14-thread-select 1
372,531 15-stack-info-depth 11
372,546
14^done,new-thread-id="1",frame={level="0",addr="0x00401315 ",func="main",args=[],file="../sr\
c/getname.c",fullname="D:/eclipse/eclipse/workspace/misc-c/Debug/../src/getname.c ",line="10"}
372,546 (gdb)
372,546 15^done,depth="1"
372,546 (gdb)
372,890 16info threads
372,890 &"info threads\n"
372,906 ~"* 1 thread 568.0xb8 main () at ../src/getname.c:10\n"
372,906 16^done
372,906 (gdb)
372,906 17-stack-select-frame 0
372,906 18-stack-list-locals 1
372,906 17^done
372,906 (gdb)
372,906
18^done,locals=[{name="name",value="\"\\224\\\\\\303wP(\\301w\\377\\377\\377\\377)N\\303wBN\\
\303w\\220\\023@\\000x\\377\\\"\\000\\366\\023\""}]
372,906 (gdb)
372,921 19-var-create - * name
372,937 19^done,name="var1",numchild="30",value="[30]",type="char [30]"
372,937 (gdb)
372,937 20-var-create - * &(name)
372,953 20^done,name="var2",numchild="1",value="0x22ff50",type= "char
(*)[30]"
372,953 (gdb)
377,015 21-exec-next 1
377,031 21^running
377,031 (gdb)
377,125
21*stopped,reason="end-stepping-range",reason="breakpoint-hit ",bkptno="2",thread-id="1",fram\
e={addr="0x0040131a",func="main",args=[],file="../src/getname.c ",fullname="D:/eclipse/eclipse/worksp\
ace/misc-c/Debug/../src/getname.c",line="14"}
377,125 (gdb)
377,125 22-thread-select 1
377,125 23-stack-select-frame 0
377,125 24-stack-list-locals 1
377,156
22^done,new-thread-id="1",frame={level="0",addr="0x0040131a ",func="main",args=[],file="../sr\
c/getname.c",fullname="D:/eclipse/eclipse/workspace/misc-c/Debug/../src/getname.c ",line="14"}
377,156 25-stack-info-depth 11
377,156 (gdb)
377,156 23^done
377,156 (gdb)
377,156
24^done,locals=[{name="name",value="\"\\224\\\\\\303wP(\\301w\\377\\377\\377\\377)N\\303wBN\\
\303w\\220\\023@\\000x\\377\\\"\\000\\366\\023\""}]
377,156 (gdb)
377,171 25^done,depth="1"
377,171 (gdb)
377,171 26-stack-info-depth
377,171 26^done,depth="1"
377,171 (gdb)
377,171 27-var-update 1 var1
377,187 27^done,changelist=[]
377,187 (gdb)
377,187 28-var-update 1 var2
377,203 28^done,changelist=[]
377,203 (gdb)
380,000 29-exec-next 1
380,015 29^running
380,015 (gdb)
380,093
29*stopped,reason="end-stepping-range",reason="breakpoint-hit ",bkptno="3",thread-id="1",fram\
e={addr="0x00401342",func="main",args=[],file="../src/getname.c ",fullname="D:/eclipse/eclipse/worksp\
ace/misc-c/Debug/../src/getname.c",line="16"}
380,093 (gdb)
380,125 30-thread-select 1
380,125 31-stack-select-frame 0
380,125 32-stack-list-locals 1
380,140
30^done,new-thread-id="1",frame={level="0",addr="0x00401342 ",func="main",args=[],file="../sr\
c/getname.c",fullname="D:/eclipse/eclipse/workspace/misc-c/Debug/../src/getname.c ",line="16"}
380,140 (gdb)
380,156 33-stack-info-depth 11
380,156 31^done
380,156 (gdb)
380,156
32^done,locals=[{name="name",value="\"\\224\\\\\\303wP(\\301w\\377\\377\\377\\377)N\\303wBN\\
\303w\\220\\023@\\000x\\377\\\"\\000\\366\\023\""}]
380,156 (gdb)
380,156 33^done,depth="1"
380,156 (gdb)
380,156 34-stack-info-depth
380,187 34^done,depth="1"
380,187 (gdb)
380,187 35-var-update 1 var1
380,203 35^done,changelist=[]
380,203 (gdb)
380,203 36-var-update 1 var2
380,203 36^done,changelist=[]
380,203 (gdb)
381,625 37-exec-next 1
381,640 37^running
381,640 (gdb)
381,718 What's your name?
37*stopped,reason="end-stepping-range",reason="breakpoint-hit ",bkptno="5",\
thread-id="1",frame={addr="0x0040134e",func="main",args=[],file= "../src/getname.c",fullname="D:/ecli\
pse/eclipse/workspace/misc-c/Debug/../src/getname.c",line="17 "}
381,718 (gdb)
384,953 &"John\n"
384,953 &"Undefined command: \"John\". Try \"help\".\n"
384,953 ^error,msg="Undefined command: \"John\". Try \"help\"."
384,953 (gdb)
388,593 38kill
388,625 &"Quit (expect signal SIGINT when the program is resumed)\n"
388,625 &"kill\n"
388,625 ~"Kill the program being debugged? (y or n) [answered Y; input not
from terminal]\n"
388,625 38^done
388,625 (gdb)
388,625 39-gdb-exit
388,625 40-data-evaluate-expression $_exitcode
388,640 39^exit
Cheers,
JD
|
|
| | | |
Re: Debugger issues with input functions [message #236326 is a reply to message #236296] |
Wed, 22 July 2009 18:25 |
FStanley Messages: 14 Registered: July 2009 |
Junior Member |
|
|
John Dell'Oso wrote:
Looking at your gdb output below:
> Yes, I am in looking in the correct console - the one associated with the
> application and the output is as I stated in my very original post.
> At the moment the only debugger option that works for me is gdb/mi and
> that opens a standalone console (i.e. DOS box) - all I/O is directed via
> this console during the debug session.
> All other debugger selections (including DSF) exhibit the behaviour I have
> outlined in my previous postings.
381,640 (gdb) 381,718 What's your name?
37*stopped,reason="end-stepping-range",reason="breakpoint-hit ",bkptno="5",\
thread-id="1",frame={addr="0x0040134e",func="main",args=[],file= "../src/getname.c",fullname="D:/ecli\
pse/eclipse/workspace/misc-c/Debug/../src/getname.c",line="17 "}
381,718 (gdb) 384,953 &"John\n"
384,953 &"Undefined command: \"John\". Try \"help\".\n"
384,953 ^error,msg="Undefined command: \"John\". Try \"help\"."
384,953 (gdb) 388,593 38kill
388,625 &"Quit (expect signal SIGINT when the program is resumed)\n"
388,625 &"kill\n"
388,625 ~"Kill the program being debugged? (y or n) [answered Y; input not
from terminal]\n"
388,625 38^done
388,625 (gdb) 388,625 39-gdb-exit
GDB is accepting your input "John" as a GDB mi command. This is the root
of your error. This should not be going to the GDB console window, it
should be going to stdin. I can only think that this would happen if you
are typing into the GDB console.
----
Forrest Stanley
Project Engineer
NetBurner - Build a network enabled embedded device in one day with an
Eclipse interface!
http://www.netburner.com
|
|
|
Re: Debugger issues with input functions [message #236381 is a reply to message #236326] |
Thu, 23 July 2009 16:38 |
Marc Khouzam Messages: 357 Registered: July 2009 |
Senior Member |
|
|
FStanley wrote:
> John Dell'Oso wrote:
> Looking at your gdb output below:
>> Yes, I am in looking in the correct console - the one associated with the
>> application and the output is as I stated in my very original post.
>> At the moment the only debugger option that works for me is gdb/mi and
>> that opens a standalone console (i.e. DOS box) - all I/O is directed via
>> this console during the debug session.
>> All other debugger selections (including DSF) exhibit the behaviour I have
>> outlined in my previous postings.
> 381,640 (gdb) 381,718 What's your name?
> 37*stopped,reason="end-stepping-range",reason="breakpoint-hit ",bkptno="5",
>
thread-id="1",frame={addr="0x0040134e",func="main",args=[],file= "../src/getname.c",fullname="D:/ecli
> pse/eclipse/workspace/misc-c/Debug/../src/getname.c",line="17 "}
> 381,718 (gdb) 384,953 &"Johnn"
> 384,953 &"Undefined command: "John". Try "help".n"
> 384,953 ^error,msg="Undefined command: "John". Try "help"."
> 384,953 (gdb) 388,593 38kill
> 388,625 &"Quit (expect signal SIGINT when the program is resumed)n"
> 388,625 &"killn"
> 388,625 ~"Kill the program being debugged? (y or n) [answered Y; input not
> from terminal]n"
> 388,625 38^done
> 388,625 (gdb) 388,625 39-gdb-exit
> GDB is accepting your input "John" as a GDB mi command. This is the root
> of your error. This should not be going to the GDB console window, it
> should be going to stdin. I can only think that this would happen if you
> are typing into the GDB console.
These traces are from DSF-GDB and I just remembered this bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=231883
which basically says we are not handling process output/input properly on
Windows. So, that explains why DSF-GDB won't work in this case. The bug
also mentions that the CDI debugger opens up a new DOS window to deal with
the input/output. Seems to be the case that works for you. So, my guess
is that there is way on Windows to use the Eclipse console for
input/output, you have to use the extra DOS window.
Marc
|
|
|
Re: Debugger issues with input functions [message #1023429 is a reply to message #236381] |
Sun, 24 March 2013 07:10 |
Gerard Grundy Messages: 2 Registered: February 2013 |
Junior Member |
|
|
Hi,
Eclipse was hanging for me when pressing CNTL + D when running a program that used EOF.
Go to Run-> Run configurations uncheck Connect process input & output to a terminal.
After posting this I found that if there is a print statement it won't print any of them till you press CNTRL + D...?
This sort of helps though not entirely.
Yours Sincerely,
Gerard Grundy
[Updated on: Sun, 24 March 2013 07:22] Report message to a moderator
|
|
| |
Goto Forum:
Current Time: Fri Oct 11 16:12:40 GMT 2024
Powered by FUDForum. Page generated in 0.05233 seconds
|