I've been trying to add GDB pretty-printing support for svn_mergeinfo_t and 
svn_mergeinfo_catalog_t.  The framework I'm extending is in 
tools/dev/gdb-py/svndbg/printers.py, created by Hyrum in January, with 
instructions for use in tools/dev/gdb-py/README.

Two problems so far in adding mergeinfo support:

1. I am telling GDB that svn_mergeinfo_catalog_t is a 'map' whose children are 
svn_mergeinfo_t, but it is printing the children using the pretty-printer for 
plain apr_hash_t (which doesn't know that their values are rangelists, and so 
can't display the rangelists).

(gdb) p unmerged_to_source_mergeinfo_catalog 
$1 = mergeinfo_catalog[2 paths] = {[A_COPY/mu] = hash of 1 items = {[/A/mu] = 
...}, [A_COPY/D] = hash of 1 items = {[/A/D] = ...}}

This must be a problem with the way GDB interacts with user-supplied 
regex-matching code when pretty printers are looked up, (see 'class 
TypedefRegexCollectionPrettyPrinter' at the top of 'printers.py').  I'm not 
sure whether it's fixable.

2. Mergeinfo contains range lists, but these are declared as 
apr_array_header_t.  If we define an 'svn_rangelist_t' type, then the 
svn_mergeinfo_t pretty-printer can be defines as a 'map' whose children are 
svn_rangelist_t, and leave GDB to print each child.

I could easily but clumsily work around both of these issues by formatting the 
whole mergeinfo or mergeinfo-catalog as a string and returning that instead of 
a 'map' type.  If I could find out how to convert a gdb.Value object to a 
string representation, that would also be useful in a work-around.  (I've 
searched the Net and read about gdb.execute() and gdb.parse_and_eval(), but not 
found a way.)

Any insights into this?

The attached patch is for exploration; it has the limitation described under 
(1) above and assumes an svn_rangelist_t type is defined in the object code.  
If I get no better ideas, I'll probably commit a version that uses string 
representations throughout as a work-around.

Log message for the attached patch:

[[[
Add GDB pretty-printing support for svn mergeinfo data types:
svn_merge_range_t, svn_mergeinfo_t.

### Relies on adding a typedef 'svn_rangelist_t' to the C code.

### The recursive printing of mergeinfo_catalog_t doesn't work properly: its
values are printed as plain apr_hash_t (that is, having unknown value type)
rather than as svn_mergeinfo_t.

* tools/dev/gdb-py/svndbg/printers.py
  (children_of_apr_array): New function.
  (SvnMergeRangePrinter, SvnRangelistPrinter, SvnMergeinfoPrinter): New
    pretty-printers.
  (SvnMergeinfoCatalogPrinter): Minor tweaks.
  (build_libsvn_printers): Add the new pretty-printers.
]]]

- Julian

--
Certified & Supported Apache Subversion Downloads: 
http://www.wandisco.com/subversion/download 

Attachment: gdb-mergeinfo-2.patch
Description: Binary data

Reply via email to