Subversion Repositories HelenOS-historic

Rev

Rev 268 | Rev 288 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 268 Rev 270
Line 3... Line 3...
3
import sys
3
import sys
4
import struct
4
import struct
5
import re
5
import re
6
 
6
 
7
symline = re.compile(r'(0x[a-f0-9]+)\s+([^\s]+)$')
7
symline = re.compile(r'(0x[a-f0-9]+)\s+([^\s]+)$')
8
symtabfmt = "<Q32s"
8
fileline = re.compile(r'[^\s]+\s+0x[a-f0-9]+\s+0x[a-f0-9]+\s+([^\s]+\.o)$')
-
 
9
 
9
MAXSTRING=31
10
MAXSTRING=63
-
 
11
symtabfmt = "<Q%ds" % (MAXSTRING+1)
10
 
12
 
11
def read_symbols(inp):
13
def read_symbols(inp):
12
    while 1:
14
    while 1:
13
        line = inp.readline()
15
        line = inp.readline()
14
        if not line:
16
        if not line:
15
            return
17
            return
16
        if 'memory map' in line:
18
        if 'memory map' in line:
17
            break        
19
            break        
18
 
20
 
19
    symtable = {}
21
    symtable = {}
-
 
22
    filename = ''
20
    while 1:
23
    while 1:
21
        line = inp.readline()
24
        line = inp.readline()
22
        if not line.strip():
25
        if not line.strip():
23
            continue
26
            continue
24
        if line[0] not in (' ','.'):
27
        if line[0] not in (' ','.'):
25
            break
28
            break
26
        line = line.strip()
29
        line = line.strip()
-
 
30
        # Search for file name
-
 
31
        res = fileline.match(line)
-
 
32
        if res:
-
 
33
            filename = res.group(1)
27
        # Search only for symbols
34
        # Search for symbols
28
        res = symline.match(line)
35
        res = symline.match(line)
29
        if res:
36
        if res:
30
            symtable[int(res.group(1),16)] = res.group(2)
37
            symtable[int(res.group(1),16)] = filename + ':' + res.group(2)
31
    return symtable
38
    return symtable
32
   
39
   
33
def generate(inp, out):
40
def generate(inp, out):
34
    symtab = read_symbols(inp)
41
    symtab = read_symbols(inp)
35
    if not symtab:
42
    if not symtab: