|
|
1.1 root 1: //
2: // nono
1.1.1.2 root 3: // Copyright (C) 2022 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // メモリダンプ/逆アセンブル
1.1 root 9: //
10:
11: #pragma once
12:
1.1.1.5 root 13: #include "object.h"
1.1.1.2 root 14: #include "debugger_memory.h"
1.1 root 15:
1.1.1.2 root 16: class DisasmLine;
1.1 root 17:
1.1.1.2 root 18: // メモリダンプ/逆アセンブルをする人。
19: class Memdump : public Object
1.1 root 20: {
1.1.1.2 root 21: using inherited = Object;
1.1 root 22:
1.1.1.2 root 23: public:
24: // フォーマット
25: enum Format {
26: Byte,
27: Word,
28: Long,
29:
30: M68030PageShort,
31: M68030PageLong,
1.1.1.5 root 32: M68040TableDesc,
33: M68040PageDesc,
1.1.1.2 root 34: M88200Page,
35:
1.1.1.5 root 36: M680x0Disasm,
1.1.1.2 root 37: M88100Disasm,
38: HD64180Disasm,
39: };
40:
41: protected:
42: // 継承クラスから呼ばれるほう。bus, md は後から指定するので不要。
1.1.1.4 root 43: explicit Memdump(uint objid_);
1.1.1.2 root 44: public:
45: // メモリダンプ用にデバッガから呼ばれるほう
1.1.1.4 root 46: explicit Memdump(DebuggerMD *md_);
1.1.1.2 root 47: // 逆アセンブル用にデバッガから呼ばれるほう
48: Memdump(DebuggerMD *md_, CPUArch asm_arch);
49:
50: ~Memdump() override;
51:
52: void InitMD(DebuggerMD *md_);
53:
1.1.1.3 root 54: busaddr GetAddr() const { return saddr; }
1.1.1.2 root 55:
1.1.1.3 root 56: // busaddr を代入
57: void SetAddr(busaddr saddr_);
58: // アドレスを設定
1.1.1.2 root 59: void SetAddr(uint32 laddr_);
60:
61: // アドレスをバイト単位で加算(減算)
62: void Offset(int bytes);
63: // アドレスを行単位で加算(減算)
64: void OffsetLine(int lines);
65:
66: // 表示形式
67: Format GetFormat() const { return fmt; }
68: void SetFormat(Format fmt_);
69:
70: // 1行の表示バイト数を返す
71: int GetStride() const { return fixed ?: inst_bytes; }
72:
73: // メモリの内容を(越権的に)読み出す。ここでは長さは bytes で指定。
74: uint64 Peek(uint32 paddr_, int bytes) const;
75: // メモリの内容を(越権的に)書き換える。ここでは長さは bytes で指定。
1.1.1.3 root 76: bool Poke(uint32 paddr_, uint32 data, int bytes);
1.1.1.2 root 77: // このアドレスが Poke 可能かどうかを返す。
78: bool CanPoke(uint32 paddr_) const;
79:
80: // コンソールに出力。
81: void Print(FILE *cons, int row);
82:
83: protected:
1.1.1.3 root 84: void MaskAddr();
85:
1.1.1.2 root 86: std::vector<int> Read(DebuggerMemoryStream&, int bytes);
87: std::string DumpChar(const std::vector<int>&);
88: std::string DumpHex(const std::vector<int>&);
89: std::string Dump68030PageShort(const std::vector<int>&);
90: std::string Dump88200Page(const std::vector<int>&);
91:
92: // アドレス等
1.1.1.3 root 93: busaddr saddr {};
1.1.1.2 root 94:
95: // 表示形式
96: Format fmt {};
97:
98: std::unique_ptr<DisasmLine> line /*{}*/;
99:
100: // 1行のバイト数。
101: // 固定長なら fixed にバイト数、可変長なら fixed は 0。
102: // 逆アセンブルなら inst_bytes に最短バイト数。
103: // (m88k 逆アセンブルはどちらも満たす)
104: int fixed {};
105: int inst_bytes {};
1.1 root 106:
1.1.1.2 root 107: DebuggerMD *md {};
1.1.1.3 root 108: IODevice *bus {};
1.1 root 109:
1.1.1.2 root 110: static const char * const dtname[4];
1.1.1.5 root 111: static const char * const udtname[4];
112: static const char * const pdtname[4];
1.1 root 113: };
114:
1.1.1.2 root 115: // メモリダンプ/逆アセンブルモニタ
116: class MemdumpMonitor : public Memdump
1.1 root 117: {
1.1.1.2 root 118: using inherited = Memdump;
1.1 root 119: public:
1.1.1.4 root 120: MemdumpMonitor(uint objid_, int monid_);
1.1.1.2 root 121: ~MemdumpMonitor() override;
1.1 root 122:
1.1.1.2 root 123: int GetLineOffset(int n) const;
124: int GetPageOffset(int n) const;
1.1 root 125:
126: private:
1.1.1.6 ! root 127: DECLARE_MONITOR_SCREEN(MonitorScreen);
1.1.1.2 root 128:
1.1.1.6 ! root 129: void MonitorScreenMemdump(TextScreen&, DebuggerMemoryStream&);
! 130: void MonitorScreenDisasm(TextScreen&, DebuggerMemoryStream&);
1.1.1.2 root 131: void Update68030PageShort(TextScreen&, int, int, const std::vector<int>&);
1.1.1.5 root 132: void Update68040TableDesc(TextScreen&, int, int, const std::vector<int>&);
133: void Update68040PageDesc(TextScreen&, int, int, const std::vector<int>&);
1.1.1.2 root 134: void Update88200Page(TextScreen&, int, int, const std::vector<int>&);
135:
1.1.1.3 root 136: // 命令開始アドレス。
137: // [0] が1行目のアドレス、
138: // [1] が2行目のアドレス、
1.1.1.2 root 139: // :
1.1.1.3 root 140: // [row - 1] が表示されてる最下行のアドレス、
141: // [row] が最下行の次のアドレス、
1.1.1.2 root 142: // を指している。
143: std::vector<uint32> nextaddr {};
144:
1.1.1.5 root 145: Monitor *monitor {};
1.1 root 146: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.