X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=debug%2Fb43-fwdump;h=a24c61466d83195c590e3ca0ad74b72da0697ee0;hb=1907804cab2799ae52ee09adffb64ec37fef7372;hp=0e94a3026ee383965bae73190f7a5d9e47195232;hpb=89a6bd4b6f180a6b3f9185628e0aab7498168f04;p=b43-tools.git diff --git a/debug/b43-fwdump b/debug/b43-fwdump index 0e94a30..a24c614 100755 --- a/debug/b43-fwdump +++ b/debug/b43-fwdump @@ -2,7 +2,7 @@ """ # b43 firmware state dumper # -# Copyright (C) 2008 Michael Buesch +# Copyright (C) 2008 Michael Buesch # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3 @@ -21,18 +21,20 @@ import getopt from libb43 import * from sys import stdout from tempfile import * +import re def usage(): print "b43 firmware state dumper" print "" - print "Copyright (C) 2008 Michael Buesch " + print "Copyright (C) 2008 Michael Buesch " print "Licensed under the GNU/GPL version 3" print "" print "Usage: b43-fwdump [OPTIONS]" print "" print "-h|--help Print this help text" - print "-p|--phy PHY The PHY to use. For example phy0" + print "-p|--phy WIPHY The WIPHY to use. For example phy0." + print " Can be omitted, if there is only one device in the system." print "-b|--binary BIN The firmware binary. This is required for" print " an instruction dump." print "-d|--dasmopt OPT Additional options to the disassembler." @@ -90,31 +92,28 @@ def dump_regs(prefix, regs): stdout.write("\n") return -def disassembleText(text): - input = NamedTemporaryFile() - output = NamedTemporaryFile() - - input.write(text) - input.flush() - os.system("b43-dasm %s %s %s --paddr" % (input.name, dasmopt, output.name)) - - return output.read() +def dasmLineIsPC(line, pc): + m = re.match(r'.*/\*\s+([0-9a-fA-F]+)\s+\*/.*', line, re.DOTALL) + if not m: + return False + linePC = int(m.group(1), 16) + return pc == linePC def makeShortDump(dasm, pc): dasm = dasm.splitlines() i = 0 for line in dasm: - if "/* %03X */" % pc in line: + if dasmLineIsPC(line, pc): break i += 1 - if i >= len(dasm): + else: return "" ret = "" pos = max(i - 8, 0) end = min(i + 8, len(dasm) - 1) while pos != end: ret += dasm[pos] - if "/* %03X */" % pc in dasm[pos]: + if dasmLineIsPC(dasm[pos], pc): ret += "\t\t<<<<<<<<<<<" ret += "\n" pos += 1 @@ -162,7 +161,7 @@ def main(): except IOError, e: print "Could not read binary file %s: %s" % (binary, e.strerror) sys.exit(1) - dasm = disassembleText(bintext) + dasm = Disassembler(bintext, dasmopt + "--paddr").getAsm() print makeShortDump(dasm, dbg.getPc()) else: print ""