0

I have an array of pointers which holds the interface details. For example

tIfInfoStruct      *gapIfTable[16];

memory has been allocated for the pointer while interface creation. For example

gapIfTable[14] = 0x39cc345.

After some sequence of operations , the value of gapIfTable[14] becomes NULL(0x0). I want to watch, which part of the program was releasing the memory. Whether I could be able to track gapIfTable[14] using

gdb> watch *0x39cc345

I want my program to be stopped on gdb when the above memory address becomes NULL, so that I can get the back trace in Gdb to find the culprit. I am running a multi threaded program.

Please correct If my understanding is wrong. If am wrong , please help me out with some solutions.

kumar_m_kiran
  • 3,982
  • 4
  • 47
  • 72
  • watch should work - gdb will use a debug register is possible, and this will do what you need. You can also try running Valgrind, which will detect writes that exceed the size of an allocated buffer. – mkfs Mar 08 '13 at 18:20

1 Answers1

0

gdb> watch *0x39cc345

This watches memory at location 0x39cc345, and not the memory at location &gapIfTable[14] that becomes NULL.

So you probably want to use watch *(gapIfTable+14) instead.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362