Coverage for MC6809/components/cpu6809_html_debug.py: 100%

1 statements  

« prev     ^ index     » next       coverage.py v7.2.1, created at 2023-03-06 19:50 +0100

1#!/usr/bin/env python 

2 

3""" 

4 MC6809 - 6809 CPU emulator in Python 

5 ======================================= 

6 

7 TODO: 

8 Need update to new API and unittests! 

9 

10 :copyleft: 2014-2015 by the MC6809 team, see AUTHORS for more details. 

11 :license: GNU GPL v3 or above, see LICENSE for more details. 

12""" 

13 

14 

15# import atexit 

16# import datetime 

17# import os 

18# 

19# from MC6809.components.cpu_utils.instruction_call import PrepagedInstructions 

20# 

21# 

22# # 

23# DEBUG_FILENAME = os.path.abspath(os.path.join( 

24# os.path.dirname(__file__), 

25# "../dragonpy_debug_%s.html" % datetime.datetime.today().strftime("%Y%m%d%H%M%S") 

26# )) 

27# 

28# 

29# HTML_OUT = open(DEBUG_FILENAME, "w") 

30# HTML_OUT.write("""<!DOCTYPE html> 

31# <html><head> 

32# <style> 

33# body { 

34# font-family:"Lucida Console", Monaco, monospace; 

35# white-space:nowrap; 

36# } 

37# table, th, td{border-collapse:collapse;border:1px solid black;} 

38# th, td {padding:5px;} 

39# </style> 

40# </head><body><h1>DragonPy Debug:</h1> 

41# <p>created: %s</p> 

42# <table>""" % datetime.datetime.today().isoformat()) 

43# print("Create debug file: %s" % DEBUG_FILENAME) 

44# 

45# 

46# @atexit.register 

47# def close_html_debug(): 

48# HTML_OUT.write("\n</table>\n") 

49# HTML_OUT.write( 

50# "<addr>This file was generated by <strong>%s</strong></addr>\n" % ( 

51# os.path.split(__file__)[1] 

52# ) 

53# ) 

54# HTML_OUT.write("</body></html>") 

55# HTML_OUT.close() 

56# print("*** Debug file created:", DEBUG_FILENAME) 

57# 

58# 

59# CALL_NO = 0 

60# class InstructionHTMLdebug(PrepagedInstructions): 

61# 

62# def __init__(self, *args, **kwargs): 

63# super(InstructionHTMLdebug, self).__init__(*args, **kwargs) 

64# 

65# def call_instr_func(self, *args, **kwargs): 

66# super(InstructionHTMLdebug, self).call_instr_func(*args, **kwargs) 

67# 

68# global CALL_NO 

69# CALL_NO += 1 

70# HTML_OUT.write("<tr>\n") 

71# HTML_OUT.write("<td>%i</td>" % CALL_NO) 

72# HTML_OUT.write("<td>%x</td>" % self.cpu.last_op_address) 

73# HTML_OUT.write("<td>%x</td>" % self.opcode) 

74# HTML_OUT.write("<td>%s</td>" % self.data["mnemonic"]) 

75# HTML_OUT.write("<td>%s</td>" % hex_repr(self.op_kwargs)) 

76# HTML_OUT.write("<td>%s</td>" % self.cpu.get_info) 

77# HTML_OUT.write("<td>%s</td>" % self.cpu.get_cc_info()) 

78# HTML_OUT.write("<td>%s</td>" % self.cpu.cfg.mem_info.get_shortest(self.cpu.last_op_address)) 

79# HTML_OUT.write("</tr>")