Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: Peng Fan <van.freenix@gmail.com>
Cc: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: GDB Remote debug: Why several "$Z0,address,length" msg when only set one breakpoint?
Date: Wed, 27 Aug 2014 00:36:00 -0000	[thread overview]
Message-ID: <87mwaqixh2.fsf@codesourcery.com> (raw)
In-Reply-To: <53FC2FC1.9080600@gmail.com> (Peng Fan's message of "Tue, 26 Aug	2014 14:57:05 +0800")

Peng Fan <van.freenix@gmail.com> writes:

It is a typical step-over-breakpoint process in GDB,

> Sending packet: $m87809580,4#7a...Ack
> Packet received: f0452de9
> Sending packet: $m87809580,4#7a...Ack
> Packet received: f0452de9

Looks like the program hits the breakpoint on 0x87809580, and 'c'
command is being executed.  Before GDB resume the inferior, it will
execute the instruction in a single-step fashion on the address
where the breakpoint is set, because it isn't executed yet.

GDB read the instruction on address 0x87809580, decode it and know what
is the address of next instruction,

> Sending packet: $Z0,87809584,4#c7...Ack
> Packet received: OK

and insert the breakpoint on next instruction for software single step,

> Sending packet: $Hc0#db...Ack
> Packet received: 
> Sending packet: $c#63...Ack
> Packet received: T050f:84958087;0d:a41355bf;
> Sending packet: $z0,87809584,4#e7...Ack
> Packet received: OK
> Sending packet: $qTStatus#49...Ack

resume the program, and it hits the breakpoint on 0x87809584.  Then,
instruction on 0x8780950 is executed.

> Packet received: 
> Sending packet: $Z0,87800000,4#ad...Ack
> Packet received: OK
> Sending packet: $Z0,87809580,4#c3...Ack
> Packet received: OK

Restore the breakpoint on 0x87809580.

> Sending packet: $Hc0#db...Ack
> Packet received: 
> Sending packet: $c#63...Ack

Resume the inferior and keep waiting.

>
> Actually the breakpoint is at 0x87809580, but why first set breakpoint
> at 0x87809584 then remove it then set breakpoint at 0x87809580?
>

My comments above answer your question.

> Also the first time set a breakpoint then continue.
> (gdb) c
> Continuing.
> Sending packet: $qTStatus#49...Ack
> Packet received: 
> Sending packet: $Z0,87800000,4#ad...Ack
> Packet received: OK
> Packet Z0 (software-breakpoint) is supported
> Sending packet: $Z0,87809580,4#c3...Ack
> Packet received: OK
> Sending packet: $vCont?#49...Ack
> Packet received: 
> Packet vCont (verbose-resume) is NOT supported
> Sending packet: $Hc0#db...Ack
> Packet received: 
> Sending packet: $c#63...Ack
>
> why two Z0 here? I only set break at 0x87809580, but gdb send a break
> set at 0x87800000 which is the beginning of the elf entry.

What is the symbol on 0x87800000? GDB inserts some internal breakpoints
for some purpose, collecting interesting events, for example.

-- 
Yao (齐尧)


  parent reply	other threads:[~2014-08-27  0:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-26  6:57 Peng Fan
2014-08-26 13:18 ` Luis Machado
2014-08-27  0:36 ` Yao Qi [this message]
2014-08-27  7:50   ` Peng Fan
2014-08-27 12:15     ` Yao Qi
2014-08-27 21:58       ` Pedro Alves
2014-08-28  1:21         ` Peng Fan

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=87mwaqixh2.fsf@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb@sourceware.org \
    --cc=van.freenix@gmail.com \
    /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