Author Topic: A problem when running valgrind in codeblocks  (Read 247 times)

Offline wanggaoteng

  • Multiple posting newcomer
  • *
  • Posts: 22
A problem when running valgrind in codeblocks
« on: March 15, 2019, 01:37:16 pm »
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?
« Last Edit: March 15, 2019, 01:39:06 pm by wanggaoteng »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11714
    • Travis build status
Re: A problem when running valgrind in codeblocks
« Reply #1 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.
(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!]

Offline wanggaoteng

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: A problem when running valgrind in codeblocks
« Reply #2 on: March 17, 2019, 09:10:54 am »
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.