public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* RE: (hardware) watchpoints and actions
@ 2015-11-12 16:14 duane
  2015-11-12 20:45 ` taylor, david
  0 siblings, 1 reply; 8+ messages in thread
From: duane @ 2015-11-12 16:14 UTC (permalink / raw)
  To: taylor,  david, gdb

david> Consider a remote target that you are communicating with via the
remote protocol.
david> If the target's GDB stub does not support breakpoint commands or
you wish to run
david> a command that is not convertible to a string of agent expression
opcodes, then to
david> run the command there is a lot of back and forth between GDB and
the target.

david> Further, GDB must remain connected to the target.

david> By contrast, when a tracepoint is hit, there is NO back and forth
with GDB.
david> GDB might not even be connected to the target. The target
executes a series of
david> commands that were expressed as strings of agent expression
opcodes and arguments.
david> A command might be to collect registers, or collect a particular
variable or collect
david> some stack. After the commands execute the program continues --
there is no
david> explicit 'continue' command.

Two problems you need to address:

a) Most "gdb-server" type things are rather "dumb" they do not know what
symbols are.
    GDB's protocol speaks "address" as an integer like value, not
symbolic.
    GDB's protocol has no idea what base+offset might be.
    GDB's protocol has no concept of "stack" or "register" based
variables.
    The STUB or GDB-SERVER has no access to the dwarf (or whatever)
debug information

Example: A linked list, you want to trace some data element, i.e.: 
trace( listPtr->Data )

At the breakpoint:

The variable: "listPtr" might be on the stack or a register
The Element "DATA" is at some base + offset

Thus you can only trace global variables
Secondary problem:  Has the compiler optimization updated the global? Or
is it still in the register?

How do you plan to solve this? I am also ignoring ENDIAN issues here.

b) Something in the target must 'interpret' the series of commands to
execute when the watch point hits.

Your options are: Install a small script interpreter into he
gdb-stub/gdb-server 
This might work for a GDB-SERVER on linux... you have a rich
environment.
Again - same problems as  above (access to debug information)
It does not work well for JTAG type GDB-Servers.

The other option something like GDB-STUBS (rom-monitor based) solution,
when the breakpoint/watchpoint exception occurs
For example - you could do sometime of JIT compilation, and download
code to the target that executes when the exception occurs.

A simple example might be you insert a "JSR my_bp_handler" at the
breakpoint location. 
That JSR/CALL does something special.

Questions (only a few)
  Where do you locate the code it jumps to?
  Can you modify the code? (is it in FLASH memory, or ReadOnly memory?)
  Can you modify the memory region attributes (i.e.: MMU bits) that
allow execution in that area?

------

Don't get me wrong, I am very aware of the problem you want to solve,
and the challenges
A good example might be a PID loop motor control, 100 times a second the
CPU calculates 
new motor control variables and must re-write hardware registers
otherwise the motor suddenly stops.

Other examples might be a network protocol with data flowing... you have
overrun and lost packets if you do not respond in time

What actually works better is a hardware based trace scheme, and that is
*VERY* chip/silicon/vendor specific.  One example is the ARM STM (system
trace macrocell)

But the code that supports this type of stuff often works better if it
is compiled into the actual application, which to some degree violates
the "do not ship debug code in production code" rule.

-Duane.







^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: (hardware) watchpoints and actions
@ 2015-11-12 22:34 duane
  0 siblings, 0 replies; 8+ messages in thread
From: duane @ 2015-11-12 22:34 UTC (permalink / raw)
  To: taylor,  david, gdb

duane> a) Most "gdb-server" type things are rather "dumb" they do not
know what symbols are.

david> [snip; see] maint agent [snip]

david> Our stubs (both old and new) contain substantial tracepoint
support. 

Hmm, you learn something every day. 

I am very familiar with several gdbserver JTAG type debug environments
(mostly bare metal), where this feature is *NOT* supported. I have spent
very little time in the linux based gdb-server, hence my ignorance of
this feature.

david> The code *IS* compiled into the application. The GDB stub is
always compiled in. 

Yes, that is quite a different environment then my background. 

Paul @ Dell - brings up another point - security/access control to the
GDB stub feature. 

In your case "compiled-in-gdb-stub" is a product requirement, and/or
product feature. 

In the space constrained world (ie: micro controller, and/or bare-metal)

(1) you often don't have code/ram space for items like this, 
(2) for performance reasons, this code must be removed
(3) There is no support for this in the underling operating system (if
there is one)
(4) Or the GDB server exists external to the target (ie: JTAG)

Each of us come from different backgrounds.

-Duane.

^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: (hardware) watchpoints and actions
@ 2015-11-11 22:02 duane
  2015-11-12 15:43 ` taylor, david
  0 siblings, 1 reply; 8+ messages in thread
From: duane @ 2015-11-11 22:02 UTC (permalink / raw)
  To: taylor,  david, gdb

>> The goal is to run at full speed until a watched location is 
>> accessed in some prescribed manner. At that time, like a 
>> tracepoint, execute some actions to collect information 
>> and then continue at full speed.

This sounds like a macro to execute on a (data|code) breakpoint.

    https://sourceware.org/gdb/onlinedocs/gdb/Break-Commands.html

Doesn't this already exist? If not, what part of this existing feature
needs to be fixed?

Or are you saying that the watchpoints do not support macros like as
described above?

If so, it seems the UI solution if needed would be the same as the
existing breakpoint-commands.

-Duane.


^ permalink raw reply	[flat|nested] 8+ messages in thread
* (hardware) watchpoints and actions
@ 2015-11-11 18:01 taylor, david
  2015-11-13 14:55 ` Yao Qi
  0 siblings, 1 reply; 8+ messages in thread
From: taylor, david @ 2015-11-11 18:01 UTC (permalink / raw)
  To: gdb

For instructions, GDB has breakpoints and tracepoints.  For data, GDB has
watchpoints.  It would be nice if there was a data equivalent of tracepoints.
There is processor support for a limited number of small locations to be watched.
The goal is to run at full speed until a watched location is accessed in some
prescribed manner.  At that time, like a tracepoint, execute some actions to
collect information and then continue at full speed.

It's sort of like a hardware watchpoint with actions attached.  For lack of a better
name, we call them 'data tracepoints'.

The current implementation is somewhat of a kludge and done without any GDB
modifications.  The GUI checks whether the address given for the tracepoint is a
code address or a data address.  For instructions, it does what it has always done,
for data, it does some kludges to avoid getting an error from GDB and also 'overloads'
some tracepoint fields.

I'd like for it to be a part of GDB and also to avoid the kludges.

Two questions immediately come to mind:

. what should the GDB user interface be?

. what should the remote protocol messages be?

Opinions?  Thoughts?

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-11-13 14:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 16:14 (hardware) watchpoints and actions duane
2015-11-12 20:45 ` taylor, david
2015-11-12 20:50   ` Paul_Koning
  -- strict thread matches above, loose matches on Subject: below --
2015-11-12 22:34 duane
2015-11-11 22:02 duane
2015-11-12 15:43 ` taylor, david
2015-11-11 18:01 taylor, david
2015-11-13 14:55 ` Yao Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).