]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Two fixes in dwarf-mode.el
authorTom Tromey <tromey@adacore.com>
Wed, 12 Aug 2020 14:41:03 +0000 (08:41 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 12 Aug 2020 14:41:06 +0000 (08:41 -0600)
This fixes a couple of small problems in dwarf-mode.el.

First, I noticed that for an attribute like:

 <2><136c>: Abbrev Number: 11 (DW_TAG_member)
    <136d>   DW_AT_name        : t

... the "t" would not be font-locked using the function name face.
The problem here is that the regexp assumed the indirect string
format, like:

    <12ac>   DW_AT_name        : (indirect string, offset: 0x1b40): whatever

Here the fix is to adjust the regexp to match both formats.

Second, when following a DIE reference, point could end up on an
attribute instead.  This happens when there is a zero-length attribute
with the same "offset" as the following DIE, like:

    <12c5>   DW_AT_GNU_all_call_sites: 1
 <2><12c5>: Abbrev Number: 5 (DW_TAG_formal_parameter)

Here the fix is to search for the DIE by looking for the depth ("<2>"
in the example) as well.

I've bumped the internal version number to make it simpler to install
this using the Emacs package facility.

binutils/ChangeLog
2020-08-12  Tom Tromey  <tromey@adacore.com>

* dwarf-mode.el (Version): Now 1.6.
(dwarf-die-button-action): Tighten DIE reference regexp.
(dwarf-font-lock-keywords): Update name regexp.

binutils/ChangeLog
binutils/dwarf-mode.el

index 162159f5cf887c96f2d7db992f6d07afc89f396b..5037d91e0dd62534f18f4e2e8c9de899a4f45453 100644 (file)
@@ -1,3 +1,9 @@
+2020-08-12  Tom Tromey  <tromey@adacore.com>
+
+       * dwarf-mode.el (Version): Now 1.6.
+       (dwarf-die-button-action): Tighten DIE reference regexp.
+       (dwarf-font-lock-keywords): Update name regexp.
+
 2020-08-12  Nick Clifton  <nickc@redhat.com>
 
        PR binutils/26331
index a1b2fdb75eb8526a22078333aa92b3957c0cf4ec..4d35c4a1fd22101b91f688d79cd2d875199cef6a 100644 (file)
@@ -1,6 +1,6 @@
 ;;; dwarf-mode.el --- Browser for DWARF information. -*-lexical-binding:t-*-
 
-;; Version: 1.5
+;; Version: 1.6
 
 ;; Copyright (C) 2012-2020 Free Software Foundation, Inc.
 
@@ -27,7 +27,7 @@
 (defconst dwarf-font-lock-keywords
   '(
     ;; Name and linkage name.
-    ("DW_AT_[a-z_]*name\\s *: .*:\\(.*\\)\\s *$"
+    ("DW_AT_[a-zA-Z_]*name\\s *:\\(?:\\s *(.*):\\)?\\s *\\(.*\\)\\s *$"
      (1 font-lock-function-name-face))
 
     ("Compilation Unit @ offset 0x[0-9a-f]+"
@@ -120,9 +120,11 @@ A prefix argument means expand all children."
 ;; Either follows a DIE reference, or expands a "...".
 (defun dwarf-die-button-action (button)
   (let* ((die (button-get button 'die))
-        ;; Note that the first number can only be decimal.
-        (die-rx (concat "^\\s *\\(<[0-9]+>\\)?<"
-                        die ">[^<]"))
+        ;; Note that the first number can only be decimal.  It is
+        ;; included in this search because otherwise following a ref
+        ;; might lead to a zero-length boolean attribute in the
+        ;; previous DIE.
+        (die-rx (concat "^\\s *<[0-9]+><" die ">:"))
         (old (point))
         (is-ref (button-get button 'die-ref)))
     (if is-ref