]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Update developer customizations
authorPaul Smith <psmith@gnu.org>
Sun, 19 May 2019 15:25:06 +0000 (11:25 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 19 May 2019 19:27:26 +0000 (15:27 -0400)
* .ccls: Remove -std=c99: it disables __attribute__ causing warnings.
* .dir-locals.el: Force the C coding style to "gnu".
* make-gdb.py: Add GDB macros for pretty-printing GNU make structs.
* scripts/copyright-update: Use GNULIB_SRCDIR to find update-copyright.

.ccls
.dir-locals.el
.gitignore
make-gdb.py [new file with mode: 0644]
scripts/copyright-update

diff --git a/.ccls b/.ccls
index 0f31f5ea4b6cc3db0fb5fda2a12bf0a528ce0ea5..d6d6cd7902a09b00a015c0a432f8aee031c95c1f 100644 (file)
--- a/.ccls
+++ b/.ccls
@@ -1,5 +1,4 @@
 clang
-%c -std=c99
 %h --include=makeint.h
 -DHAVE_CONFIG_H
 -Isrc
index f71d12d41e51893b9d1020f8d81ac563cff3a741..30736ec23f5037678496be46fd20e5f6af01dc2c 100644 (file)
@@ -14,4 +14,5 @@
                                     "/tests/work$"
                                     "/make-[0-9]"))
          ))
+ (c-mode . ((c-file-style . "gnu")))
 )
index 429e27901f89da5b92a80ccce2953e7d4ae6f748..2f5023e7945e499d2c49242cf99dfd6b8293e184 100644 (file)
@@ -36,6 +36,7 @@ stamp-h1
 gmk-default.h
 loadavg
 make
+*.i
 *.o
 *.a
 *.exe
diff --git a/make-gdb.py b/make-gdb.py
new file mode 100644 (file)
index 0000000..d5a5285
--- /dev/null
@@ -0,0 +1,175 @@
+import re
+
+import gdb #pylint: disable=import-error
+import gdb.printing #pylint: disable=import-error
+
+# Memoize types we commonly use
+_TYPES = {}
+def getType(tname):
+    global _TYPES
+    if tname not in _TYPES:
+        tn = tname.rstrip('*')
+        if tn not in _TYPES:
+            _TYPES[tn] = gdb.lookup_type(tn)
+        while tn != tname:
+            # Want a pointer type
+            t = tn
+            tn += '*'
+            _TYPES[tn] = _TYPES[t].pointer()
+    return _TYPES[tname]
+
+class ShowArgv(gdb.Function):
+    """Return the pretty-print of a null-terminated array of strings
+
+    Argument:
+        A char** where the last one is NULL (e.g., argv)
+    """
+
+    def __init__(self):
+        gdb.Function.__init__(self, "showargv")
+
+    def invoke(self, argv):
+        str = '['
+        i = 0
+        while argv[i] != 0:
+            if i > 0:
+                str += ', '
+            str += argv[i].string()
+            i += 1
+        str += ']'
+        return str
+
+ShowArgv()
+
+
+class FileLocation(object):
+    """Print a file location"""
+
+    def __init__(self, val):
+        self.val = val
+
+    def to_string(self):
+        if long(self.val['filenm']):
+            return "%s:%d" % (str(self.val['filenm']), self.val['lineno'])
+        return ''
+
+class VariablePrinter(object):
+    """Print a struct variable"""
+
+    def __init__(self, val):
+        self.val = val
+
+    def to_string(self):
+        if self.val['append']:
+            a = '+='
+        elif self.val['conditional']:
+            a = '?='
+        else:
+            a = '='
+        flags = []
+        s = str(self.val['flavor'])
+        if s != 'f_bogus':
+            flags.append(s)
+        s = str(self.val['origin'])
+        if s != 'o_default':
+            flags.append(s)
+        s = str(self.val['export'])
+        if s != 'v_default':
+            flags.append(s)
+        return '%s[%s]: "%s" %s "%s"' % (
+            self.val['fileinfo'], ','.join(flags),
+            self.val['name'].string(), a, self.val['value'].string())
+
+class HashTablePrinter(object):
+    """Manage a hash table."""
+
+    DELITEM = None
+
+    def __init__(self, val):
+        self.val = val
+
+    def to_string(self):
+        return "size=%d, capacity=%d, empty=%d, collisions=%d, rehashes=%d" % (
+            self.val['ht_size'], self.val['ht_capacity'],
+            self.val['ht_empty_slots'], self.val['ht_collisions'],
+            self.val['ht_rehashes'])
+
+    def children(self):
+        for (i, v) in self.iterator():
+            nm = '[%d] ' % i
+            yield (nm, i)
+            yield (nm, v)
+
+    def iterator(self):
+        if HashTablePrinter.DELITEM is None:
+            HashTablePrinter.DELITEM = gdb.lookup_global_symbol('hash_deleted_item').value()
+        lst = self.val['ht_vec']
+        for i in xrange(0, self.val['ht_size']):
+            v = lst[i]
+            if long(v) != 0 and v != HashTablePrinter.DELITEM:
+                yield (i, v)
+
+    def display_hint(self):
+        return 'map'
+
+class VariableSetPrinter(object):
+    """Print a variable_set"""
+
+    def __init__(self, val):
+        self.tbl = HashTablePrinter(val['table'])
+
+    def to_string(self):
+        return self.tbl.to_string()
+
+    def children(self):
+        for (i, v) in self.tbl.iterator():
+            ptr = v.cast(getType('struct variable*'))
+            nm = '[%d] ' % (i)
+            yield (nm, ptr)
+            yield (nm, str(ptr.dereference()))
+
+    def display_hint(self):
+        return 'map'
+
+class VariableSetListPrinter(object):
+    """Print a variable_set_list"""
+
+    GLOBALSET = None
+
+    def __init__(self, val):
+        self.val = val
+
+    def to_string(self):
+        return str(self.val.address)
+
+    def children(self):
+        if VariableSetListPrinter.GLOBALSET is None:
+            block = gdb.lookup_global_symbol('init_hash_global_variable_set').symtab.static_block()
+            VariableSetListPrinter.GLOBALSET = gdb.lookup_symbol('global_variable_set', block)[0].value().address
+        ptr = self.val.address
+        i = 0
+        while long(ptr) != 0:
+            nm = '[%d] ' % (i)
+            yield (nm, ptr['set'])
+            if long(ptr['set']) == long(VariableSetListPrinter.GLOBALSET):
+                yield (nm, "global_variable_set")
+            else:
+                yield (nm, str(ptr['set'].dereference()))
+            i += 1
+            ptr = ptr['next']
+
+    def display_hint(self):
+        return 'map'
+
+def build_pretty_printer():
+    pp = gdb.printing.RegexpCollectionPrettyPrinter("gnumake")
+    pp.add_printer('floc', r'^floc$', FileLocation)
+    pp.add_printer('variable', r'^variable$', VariablePrinter)
+    pp.add_printer('hashtable', r'^hash_table$', HashTablePrinter)
+    pp.add_printer('variableset', r'^variable_set$', VariableSetPrinter)
+    pp.add_printer('variablesetlist', r'^variable_set_list$', VariableSetListPrinter)
+    return pp
+
+# Use replace=True so we can re-source this file
+gdb.printing.register_pretty_printer(gdb.current_objfile(),
+                                     build_pretty_printer(), replace=True)
index a31cf0a9cb372d6fc56260639da36ab6f3b081d3..2e7c598b394670da14022a57338529b837125dff 100755 (executable)
@@ -5,11 +5,14 @@
 #
 # Update GNU make copyrights using gnulib update-copyright
 
-update=${UPDATE_COPYRIGHT:-../../gnulib/build-aux/update-copyright}
+update=${UPDATE_COPYRIGHT:-${GNULIB_SRCDIR:-../../gnulib}/build-aux/update-copyright}
 
 die () { echo "$*"; exit 1; }
 
 run () {
+    cmd=$(command -v "$update") || die "Cannot locate update-copyright ($update)"
+    [ -x "$cmd" ] || die "Cannot locate update-copyright ($update)"
+
     EXCLUDE='^\(.*/\.[a-z].*\|.*COPYING\|glob/.*\|src/hash\.[ch]\|ChangeLog\.[0-9]*\|.*/ChangeLog\.[0-9]*\|INSTALL\|doc/make\.texi\)$'
 
     force=false
@@ -29,12 +32,10 @@ run () {
         die "Run in a clean workspace (git clean -fdX)"
     fi
 
-    [ -x "$update" ] || die "Cannot locate update-copyright ($update)"
-
     # We use intervals
     export UPDATE_COPYRIGHT_USE_INTERVALS=1
 
-    "$update" $(find * -type f | grep -v "$EXCLUDE")
+    "$cmd" $(find * -type f | grep -v "$EXCLUDE")
 
     echo "*** Update doc/make.texi copyright by hand!"
     echo "*** Update src/main.c:print_version() copyright by hand!"