Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: John Coppens <john@jcoppens.com>
To: gdb@sourceware.org
Subject: Debugging classes.
Date: Fri, 01 Oct 2010 18:07:00 -0000	[thread overview]
Message-ID: <20101001150705.ab95907e.john@jcoppens.com> (raw)

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.


             reply	other threads:[~2010-10-01 18:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-01 18:07 John Coppens [this message]
2010-10-01 19:28 ` John Coppens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101001150705.ab95907e.john@jcoppens.com \
    --to=john@jcoppens.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox