This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Debugging classes.


Hello people.

I'm getting the following error message in places I wouldn't expect it. 
I don't know if this is a gdb bug (I've seen some messages about similar
problems), or a programming error of mine:

Cannot access memory at address 0xb7

Gdb version is 7.1, distro is Slackware 13.1 (updated).

This is the sequence of events leading to the error:

1) in a main program, I declared an instance of class SingleStep:

  SingleStep stepper;

2) I set a breakpoint inside method ::step, start the program, and
get to the breakpoint:

Breakpoint 1, SingleStep::step (this=0x6067e0, mem=0x607030,
pc=0x7fffffffdcdc) at step.cpp:670 670	  switch (opcode[opc_line].operation) {

(gdb) p this
$1 = (SingleStep * const) 0x6067e0

(All as expected)

3) After a few loops ('this' is still the same), I enter into a call from the 
same class:

689	    case OP_JGE:	do_jump_if(mem, pc, opc, !(get_SR_bit(SR_N) ^ get_SR_bit(SR_V))); break;
(gdb) s
SingleStep::get_SR_bit (this=0x6067e0, mem=0x607030, pc=0x7fffffffdcdc) at step.cpp:716
716	  return (r[REG_SR] & (1 << bit)) != 0;
(gdb) p this
$2 = (SingleStep * const) 0xf

Why is SingleStep suddenly 0xf? Of course, I can't access internal variables
with this value:

(gdb) p r
Cannot access memory at address 0x67
(gdb) p this->r
Cannot access memory at address 0x67

I'd appreciate suggestions here!

John

BTW: the get_SR_bit method called is:

int
SingleStep::get_SR_bit(int bit)
{
  return (r[REG_SR] & (1 << bit)) != 0;
}

It is declared as a private method of SingleStep.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]