Code in can_use_hardware_watchpoint()

J.T. Conklin jtc@redback.com
Fri Aug 13 16:49:00 GMT 1999


I believe the enclosed code from can_use_hardware_watchpoint() has a
problem, but I'm unsure of the proper fix.  

The problem is that a expression containing a register variable will
not cause this function to fail (return 0).  This seems to result in
GDB forging ahead and placing a hardware watchpoint at a random
address for the register variable.  An example of this is something
like 'watch mem[reg] != 0'.

  /* Make sure all the intermediate values are in memory.  Also make sure
     we found at least one memory expression.  Guards against watch 0x12345,
     which is meaningless, but could cause errors if one tries to insert a 
     hardware watchpoint for the constant expression.  */
  for (; v; v = v->next)
    {
      if (v->lval == lval_memory)
	{
	  if (TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT (TYPE_LENGTH (VALUE_TYPE (v))))
	    found_memory_cnt++;
	}
      else if (v->lval != not_lval && v->modifiable == 0)
	return 0;
    }

One solution is to add an:

      else if (v->lval == lval_register)
        return 0;

But I'm wondering if instead the v->modifiable == 0 should be == 1
instead.

        --jtc

-- 
J.T. Conklin
RedBack Networks


More information about the Gdb mailing list