Subversion Repositories HelenOS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 266 → Rev 268

/SPARTAN/trunk/src/debug/symtab.c
0,0 → 1,47
/*
* Copyright (C) 2005 Ondrej Palkovsky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
 
#include <symtab.h>
#include <typedefs.h>
 
/** Return entry that seems most likely to correspond to the @addr
*
*/
char * get_symtab_entry(__native addr)
{
count_t i;
 
for (i=1;symbol_table[i].address;++i) {
if (addr < symbol_table[i].address)
break;
}
if (addr >= symbol_table[i-1].address)
return symbol_table[i-1].symbol_name;
return NULL;
}
/SPARTAN/trunk/src/debug/genmap.py
0,0 → 1,60
#!/usr/bin/env python
 
import sys
import struct
import re
 
symline = re.compile(r'(0x[a-f0-9]+)\s+([^\s]+)$')
symtabfmt = "<Q32s"
MAXSTRING=31
 
def read_symbols(inp):
while 1:
line = inp.readline()
if not line:
return
if 'memory map' in line:
break
 
symtable = {}
while 1:
line = inp.readline()
if not line.strip():
continue
if line[0] not in (' ','.'):
break
line = line.strip()
# Search only for symbols
res = symline.match(line)
if res:
symtable[int(res.group(1),16)] = res.group(2)
return symtable
def generate(inp, out):
symtab = read_symbols(inp)
if not symtab:
print "Bad kernel.map format, empty."
sys.exit(1)
addrs = symtab.keys()
addrs.sort()
for addr in addrs:
# Do not write address 0, it indicates end of data
if addr == 0:
continue
data = struct.pack(symtabfmt,addr,symtab[addr][:MAXSTRING])
out.write(data)
out.write(struct.pack(symtabfmt,0,''))
 
def main():
if len(sys.argv) != 3:
print "Usage: %s <kernel.map> <output.bin>" % sys.argv[0]
sys.exit(1)
 
inp = open(sys.argv[1],'r')
out = open(sys.argv[2],'w')
generate(inp,out)
inp.close()
out.close()
 
if __name__ == '__main__':
main()
Property changes:
Added: svn:executable
+*
\ No newline at end of property