This is the mail archive of the gdb-patches@sources.redhat.com 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]

Re: [RFA] remote.c: adjust Z packet addr using BREAKPOINT_FROM_PC


>>>>> "Nicholas" == Nicholas Duffek <nsd@redhat.com> writes:
Nicholas> This patch adjusts breakpoint addresses using
Nicholas> BREAKPOINT_FROM_PC before rather than after storing them in
Nicholas> Z packets.
Nicholas>
Nicholas> Elsewhere in GDB, BREAKPOINT_FROM_PC gets called before the
Nicholas> address is passed to the target, so I think this patch is
Nicholas> correct.  I haven't tested it with a target that uses both Z
Nicholas> packets and BREAKPOINT_FROM_PC, however.

I'm a bit bothered by the fact BREAKPOINT_FROM_PC() is being used in
the first place.  The intent was for the debug agent to have freedom
to implement software breakpoints using any mechanism, not requiring
the agent to replace memory contents with the same byte sequence that
GDB would have inserted if the Z/z command packets were not supported.

The GDB internals manual indicates that BREAKPOINT_FROM_PC() may
adjust the address.  I don't know under what circumstances it does so,
but it would seem that the debug agent could then install the break in
the wrong location.

I think the reason that BREAKPOINT_FROM_PC() is called is to get the
size of the breakpoint.  This feature was not in my original proposal.
It was later added to handle those architectures that have both 16 and
32 bit modes with different breakpoint instructions depending on what
mode the code is.  I'm not fond of this --- there must be a better way.
In a target where the debug agent is incorporated into the system, the
agent could be made to "know" where the 16 and 32 bit .text sections 
are and insert the appropriate trap insn; but some people use the remote
protocol as a low level ROM monitor to load and debug their code.  In 
that case the agent wouldn't have enough information.

As long as BREAKPOINT_FROM_PC() is able to change the breakpoint address,
I don't think this patch is appropriate.  In fact, if there was a better
way for GDB to tell the agent what memory regions were 16 bit code and 
what were 32 bit codes, I'd remove it from this code completely.

        --jtc

-- 
J.T. Conklin
RedBack Networks

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