Re: [PATCH 0/2] Support the new PPC476 processor

Eli Zaretskii
2009-12-18T10:19:55Z

> From: SÃ©rgio_Durigan_JÃºnior <sergiodj@linux.vnet.ibm.com>
> Date: Wed, 16 Dec 2009 18:47:16 -0200
> Cc: Thiago Jung Bauermann <bauerman@br.ibm.com>, Luis Machado <luisgpm@linux.vnet.ibm.com>, Matt Tyrlik <tyrlik@us.ibm.com>
>
> This series of patches implement the support for the new PowerPC 476 IBM
> processor. This is an embedded processor with some nice debugging
> capabilities, and I believe you will like to see the new types of
> breakpoints/watchpoints implemented on GDB.

Thanks!

I have a few preliminary comments and questions about the proposed UI:

> * Simple Hardware Watchpoints: Monitors accesses to a single data address.
> For the PPC476, 2 of them are available provided that no Range/Mask
> watchpoints are being used. There is also the possibility of using conditions
> when monitoring the values. In this case, GDB will place the condition inside
> a register, and the evaluation will be hardware-accelerated, which will speed-
> up significantly the debugging process. The PPC476 processor has two
> registers that can be used to hardware-accelerate the condition evaluation.
>
> - Available GDB commands: [r|a]watch <variable> (rwatch/awatch/watch) or
> [r|a]watch <variable> if <variable> == <4-bytes unsigned constant>
>
> - Usage example: awatch i / rwatch *0xbffff8e8 / watch i if i == 28

Will GDB decide automatically whether to use hardware-accelerated
conditions or the current implementation, whereby an unconditional
hardware watchpoint is set, and when it breaks, GDB itself evaluates
the condition? I think this should be done automatically.

> * Range Hardware Watchpoints: Monitors accesses to an interval of data
> addresses. For the 476, a single Range Hardware Watchpoint can be used
> provided that no Simple/Mask watchpoints are being used.
>
> - Available GDB commands: [r|a]watch-range <address1>:<address2 | +<uint
> length>>, where <address1> <= <address2> (rwatch-range/awatch-range/watch-
> range)
>
> - Usage example: watch-range &i,&k / awatch-range 0xbffff8e8,0xbffff8f8 /
> rwatch-range 0xbffff8e8,+8

Why is there a need for a separate GDB command? What are the
use-cases where the user would want to watch a region that is spanned
by more than one (albeit large) variable? If such use-cases are
infrequent enough or obscure, then we could simply use the normal
watch commands, and support any corner use-cases with something like

watch *0xbffff8e8@8

using what is a normal GDB semantics for artificial arrays. IOW, no
need for either the comma-separated list of 2 addresses or a separate
command.

> * Mask Hardware Watchpoints: Monitors accesses to data addresses that match
> a specific pattern. For the 476, a single Mask Hardware Watchpoint can be
> used provided that no Simple/Range watchpoints are being used. Due to the
> processor's design, the precise data address of the watchpoint trigger is not
> available, so the user must check the instruction that caused the trigger
> (usually at PC - 4) to obtain such data address. With such data address in
> hand, it's possible to tell if its contents have changed.
>
> - Available GDB commands: [r|a]watch <variable | address> mask
> <mask_value>
>
> - Usage example: watch i mask 0xffffff00 / awatch *0xbffff8e8 mask
> 0xffffff00

I'm not sure about the semantics of this: what exactly does the mask
do? how does it modify the unmasked command for the same address?

> * Range Hardware Breakpoint: Monitors an interval of instruction addresses.
>
> - Available GDB commands: hbreak-range <address1>:<address2 | +<unsigned
> int length>> where <address1> <= <address2> / hbreak-range <line number
> start>:<line number end>
>
> - Usage example: hbreak-range 0x10000658,0x10000660 / hbreak-range
> 0x10000658,+8 / hbreak-range 20,30

Again, what are the use-cases where such breakpoints would be useful?