-2

I have a big project and I realized that there is a variable that is changed without writing any value directly in it. I mean, I think that there is a pointer changing this value... I want to know if there is any software to detect this kind of faults.

I am using Valgrind but it does not give enough information to fix it.

Any help would be very appreciate.

6
  • 4
    you can use the debug mode "data" debug. You introduce a pointer to the variable and the program stops when that variable updates. Let me know if it works. Thanks.
    – Cabrra
    Jun 27, 2016 at 14:06
  • Try printing the address of it.
    – Shravan40
    Jun 27, 2016 at 14:06
  • Do you have custom memory manager in your code? or its direct malloc/free?
    – Ritesh
    Jun 27, 2016 at 14:25
  • It'is direct malloc/free. The problem is that there are a lot of pointers and the project was started by another guy, so It is not easy to find the pointer to me. Jun 27, 2016 at 14:27
  • Does the explantion provided here doesn't work? Jun 27, 2016 at 14:31

2 Answers 2

0

In embedded systems, there are several methods to be notified when a variable changes:

  1. Poll -- have some background code that monitors the variable and executes an associated function (via pointer) when the variable changes.
  2. RTOS Mechanism -- Associate the variable with a semaphore, mutex or message queue.
  3. Interrupt -- Maybe your variable is an interrupt register of some hardware device or you will get interrupted when a hardware registers is modified.

For polling, your best solution is to assign a pointer to the memory address and set the pointer to point to a volatile item. You may want to use a sleep function call so as not to hog all the processor time.

-1

Visual C++ IDE can be used in debug mode to check the value of Variables. Any change in the variable will be dynamically updated in debug mode.

5
  • I am using eclipse and I am programming an embedded system that runs in linux. Jun 27, 2016 at 14:29
  • How Visual C++ IDE will help to debug in Linux??
    – osgx
    Jun 27, 2016 at 15:06
  • 1
    I tried to do something similar in GDB/GCC years ago, and never found a way to do this. Just one more thing where Windows is ahead of Linux :-)
    – Neil
    Jun 27, 2016 at 15:13
  • @osgx I have said debugging in Visual C++ IDE, since the question was not precise of the OS used (Windows/Linux/MacOS). Also, Visual C++ IDEs for Linux and Mac OS are also present. Please check out link Jun 28, 2016 at 6:55
  • @JulenUranga Please refer to my previous comment to debug using visual c++ in linux. Alternatively, you can use Eclipse IDE as well to debug in Linux. Please follow this link Jun 28, 2016 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.