[Patch] Add mips-linux hardware watchpoint support.

David Daney ddaney@avtrex.com
Thu Sep 11 00:05:00 GMT 2008


This patch adds support for mips watch registers for the
mips{,el,64,64el}-linux target.  In order to take advantage of the mips
watch registers you need to use a kernel with the corresponding support.
 I will be posting the kernel patches to linux-mips@linux-mips.org
shortly ()http://www.linux-mips.org/archives/linux-mips/).

Previous versions of this patch had very limited functionality.  This
version adds most of the missing support and I hope is very close to
being ready to merge/commit.

This patch depends on two other patches that have not been committed yet:
http://sourceware.org/ml/gdb-patches/2008-09/msg00203.html
http://sourceware.org/ml/gdb-patches/2008-09/msg00222.html

Things I have tested with the patch:

* Single watch of length 1.  Since the minimum size region covered by a
mips watch register is 8, gdb handles spurious traps when memory in the
region is touched, but the watch location is not modified.

* Two watchs of length 1 in the same 8 byte region.  Only one hardware
register is required to cover both watches.

* Single watch of length 32.  A single watch register is used with the
appropriate mask to cover the watch region.

* Mutiple watches with disjoint regions.  Multiple watch registers are used.

* Single watch of length 32 aligned such that two watch registers are
needed to cover the region.

* A watch triggered in a thread started after the watch was added.

* Too many watches.  If the hardware watch resources are exhausted, gdb
will complain and not proceed until some of the watches are
deleted/disabled.

There are a couple of things that could be added to the patch, but I
would like to get the basic functionality committed before proceeding
with them:

* Gdbserver support is missing.

* Watches added before the inferior is started are always software
watches.  It would be nice to re-evaluate them and convert them to
hardware watches if possible.

As I aim to commit some version of this patch, any comments are welcome
and desired.

Of particular interest are any opinions about the kernel interface.
Previously (on IRC) Daniel indicated that the kernel interface seemed
OK, but any confirmation of this would be welcome.

I have been testing on:
mipsel-linux -- 4 sets of watch registers.
mipsel-linux -- 1 set of watch registers.
mipsel-linux -- No watch registers.
mips64-linux -- No watch registers.



2008-09-10  David Daney  <ddaney@avtrex.com>

	* mips-linux-nat.c (command.h, gdbcmd.h, gdb_assert.h): New
	includes.
	(maint_show_dr, super_close, watch_readback_valid,
	watch_readback, current_watches, watch_mirror): New variables.
	(PTRACE_GET_WATCH_REGS, PTRACE_SET_WATCH_REGS, W_BIT, R_BIT,
	I_BIT, W_MASK, R_MASK, I_MASK, IRW_MASK, MAX_DEBUG_REGISTER): New
	macros.
	(enum pt_watch_style, struct mips32_watch_regs,
	struct mips64_watch_regs, struct pt_watch_regs,
	struct mips_watchpoint): New type definitions.
	(get_irw_mask, get_reg_mask, get_num_valid, get_watchlo,
	set_watchlo, get_watchhi, set_watchhi, mips_show_dr,
	mips_linux_read_watch_registers, mips_linux_can_use_hw_breakpoint,
	mips_linux_stopped_by_watchpoint, mips_linux_stopped_data_address,
	type_to_irw, fill_mask, try_one_watch,
	mips_linux_region_ok_for_hw_watchpoint, write_watchpoint_regs,
	mips_linux_new_thread, populate_regs_from_watches,
	mips_linux_insert_watchpoint, mips_linux_remove_watchpoint,
	mips_linux_close): New functions.
	(_initialize_mips_linux_nat): Add hardware watchpoint functions
	to target vector.  Register new thread function and
	show-debug-regs maintenance command.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mln.patch
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20080911/83050fea/attachment.ksh>


More information about the Gdb-patches mailing list