Changeset a35b458 in mainline for kernel/tools/genmap.py


Ignore:
Timestamp:
2018-03-02T20:10:49Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/tools/genmap.py

    r3061bc1 ra35b458  
    4747def read_obdump(inp):
    4848        "Parse input"
    49        
     49
    5050        funcs = {}
    5151        data = {}
    5252        bss = {}
    5353        fname = ''
    54        
     54
    5555        for line in inp:
    5656                line = line.strip()
     
    5959                        funcs.setdefault(fname, []).append((int(res.group(1), 16), res.group(3)))
    6060                        continue
    61                
     61
    6262                res = bssline.match(line)
    6363                if (res):
     
    6666                        if (end):
    6767                                bss.setdefault(fname, []).append((start, res.group(3)))
    68                
     68
    6969                res = dataline.match(line)
    7070                if (res):
     
    7373                        if (end):
    7474                                data.setdefault(fname, []).append((start, res.group(3)))
    75                
     75
    7676                res = fileexp.match(line)
    7777                if (res):
    7878                        fname = res.group(1)
    7979                        continue
    80        
     80
    8181        return {'text' : funcs, 'bss' : bss, 'data' : data}
    8282
    8383def generate(kmapf, obmapf, out):
    8484        "Generate output file"
    85        
     85
    8686        obdump = read_obdump(obmapf)
    87        
     87
    8888        def key_sorter(x):
    8989                return x[0]
    90        
     90
    9191        for line in kmapf:
    9292                line = line.strip()
    9393                res = startfile.match(line)
    94                
     94
    9595                if ((res) and (res.group(3) in obdump[res.group(1)])):
    9696                        offset = int(res.group(2), 16)
     
    103103                                data = struct.pack(symtabfmt, addr + offset, value_bytes[:MAXSTRING])
    104104                                out.write(data)
    105                        
     105
    106106        out.write(struct.pack(symtabfmt, 0, b''))
    107107
     
    110110                print("Usage: %s <kernel.map> <nm dump> <output.bin>" % sys.argv[0])
    111111                return 1
    112        
     112
    113113        kmapf = open(sys.argv[1], 'r')
    114114        obmapf = open(sys.argv[2], 'r')
    115115        out = open(sys.argv[3], 'wb')
    116        
     116
    117117        generate(kmapf, obmapf, out)
    118        
     118
    119119        kmapf.close()
    120120        obmapf.close()
Note: See TracChangeset for help on using the changeset viewer.