I ran into some problem that I want to solve efficiently and maybe some of you will learn from this too.
I made a mistake, because I debbuged my application using printf( or in my case probably std::cout) debbuging.
It went well and I removed my bug and got to other problems.
Now I am at a stage where I want my debugging output to vanish but I can not find it anymore.
Searching the text did not bring it up and is hopeless because of many non-debug prints.
Further I did not print more than a variables value so I don’t know it’s name nor can I search for this specific value as it is not in the source code.
I remember of some neat linux command that logs all syscalls in the application it wraps.
Is it possible to use this tool to find the lines where the debugging print takes place?
(I would use this because 90% of my output is this debugging print so i think i should find it quickly)
Of course if you know about a better way to solve this you are welcome to post your solution.
Thanks
EDIT
To not comment on each one who advices me to use version control: I already use SVN.
Unfortunately I do not know when I entered the debugging message.
Worst case could be that my initial commit already contains it.
The grep guys: That is not much better than the text search as it will give me each
line containing a print/std::cout and that without context, so I cant even decide if
it is a debugging line between all these others.
To all of you who tell me/think I am stupid doing these things: Well that one I noticed just as I typed in this post 😉
But let me state that I all this comes down to my laziness in former times so let this be an example for all of you how laziness leads to even more work later on.
I just needed one single debug print there so I decided to code it in the dirty way. If it had been more I probably would have used a better one.
Solved
Finally I found it, with some luck.
It was a std::cout that had hidden somewhere deeper in code(one of the base classes that had only few includes that all were system-libraries).
I tried the grep method with one -F1 to see any comments and had luck with the line in question being on the screen when grep was through.
If it’s a
printf– do a macro that will callprintfadding to it the file name and line number (these are__FILE__and__LINE__). Just name the macroprintfand call::printffor the original function.If it’s
cout– a bit trickier, but you can try to put breakpoint there and see where it’s called from, you’ll find it in the end.For the next time – always use dedicated debug printing functions or wrapper macros that could be easily separated from the rest of the code by a single compiler switch.