News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

A problem when running valgrind in codeblocks

Started by wanggaoteng, March 15, 2019, 01:37:16 PM

Previous topic - Next topic

wanggaoteng

Hi, My codeblocks has been installed in lubuntu 16.04, so there is a "Valgrind" menu in the toolbar, as picture 1 illustrated.
When my code has not contains the user input, namely, no scanf() function, the "Valgrind/Run MemCheck" works very well.
But if the code contains the user input (i.e., scanf), when clicking "Valgrind/Run MemCheck", it makes codeblocks running forever, nothing to give back and not stop, and it seems that the valgrind waits for the user input, but I can't find the way to enter user input for valgrind in codeblocks.
Is there any way to fix this problem?

oBFusCATed

Not sure. Probably the valgrind plugin should be modified to do something similar to the debugger plugin, but I'm not even sure that valgrind supports redirecting stdin/out to something else then the current console.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

wanggaoteng

Quote from: oBFusCATed on March 15, 2019, 02:40:03 PM
Not sure. Probably the valgrind plugin should be modified to do something similar to the debugger plugin, but I'm not even sure that valgrind supports redirecting stdin/out to something else then the current console.
Hi, oBFusCATed, thanks for replying.
Finally, after search many webs, I find that there is a way to use valgrind in the terminal:
1. gcc -g test.c
2. valgrind --tool=memcheck --leak-check=yes --show-reachable=yes ./a.out
Then the code (test.c) runs, so I can enter the user input. After completes the user input, then valgrind feedback the result in the comsole.