Annotation of nono/debugger/memdump.h, revision 1.1.1.3

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.2   root       13: #include "monitor.h"
                     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,
                     32:                M88200Page,
                     33: 
                     34:                M68030Disasm,
                     35:                M88100Disasm,
                     36:                HD64180Disasm,
                     37:        };
                     38: 
                     39:  protected:
                     40:        // 継承クラスから呼ばれるほう。bus, md は後から指定するので不要。
                     41:        Memdump(int objid_);
                     42:  public:
                     43:        // メモリダンプ用にデバッガから呼ばれるほう
                     44:        Memdump(DebuggerMD *md_);
                     45:        // 逆アセンブル用にデバッガから呼ばれるほう
                     46:        Memdump(DebuggerMD *md_, CPUArch asm_arch);
                     47: 
                     48:        ~Memdump() override;
                     49: 
                     50:        void InitMD(DebuggerMD *md_);
                     51: 
1.1.1.3 ! root       52:        busaddr GetAddr() const { return saddr; }
1.1.1.2   root       53: 
1.1.1.3 ! root       54:        // busaddr を代入
        !            55:        void SetAddr(busaddr saddr_);
        !            56:        // アドレスを設定
1.1.1.2   root       57:        void SetAddr(uint32 laddr_);
                     58: 
                     59:        // アドレスをバイト単位で加算(減算)
                     60:        void Offset(int bytes);
                     61:        // アドレスを行単位で加算(減算)
                     62:        void OffsetLine(int lines);
                     63: 
                     64:        // 表示形式
                     65:        Format GetFormat() const { return fmt; }
                     66:        void SetFormat(Format fmt_);
                     67: 
                     68:        // 1行の表示バイト数を返す
                     69:        int GetStride() const { return fixed ?: inst_bytes; }
                     70: 
                     71:        // メモリの内容を(越権的に)読み出す。ここでは長さは bytes で指定。
                     72:        uint64 Peek(uint32 paddr_, int bytes) const;
                     73:        // メモリの内容を(越権的に)書き換える。ここでは長さは bytes で指定。
1.1.1.3 ! root       74:        bool Poke(uint32 paddr_, uint32 data, int bytes);
1.1.1.2   root       75:        // このアドレスが Poke 可能かどうかを返す。
                     76:        bool CanPoke(uint32 paddr_) const;
                     77: 
                     78:        // コンソールに出力。
                     79:        void Print(FILE *cons, int row);
                     80: 
                     81:  protected:
1.1.1.3 ! root       82:        void MaskAddr();
        !            83: 
1.1.1.2   root       84:        std::vector<int> Read(DebuggerMemoryStream&, int bytes);
                     85:        std::string DumpChar(const std::vector<int>&);
                     86:        std::string DumpHex(const std::vector<int>&);
                     87:        std::string Dump68030PageShort(const std::vector<int>&);
                     88:        std::string Dump88200Page(const std::vector<int>&);
                     89: 
                     90:        // アドレス等
1.1.1.3 ! root       91:        busaddr saddr {};
1.1.1.2   root       92: 
                     93:        // 表示形式
                     94:        Format fmt {};
                     95: 
                     96:        std::unique_ptr<DisasmLine> line /*{}*/;
                     97: 
                     98:        // 1行のバイト数。
                     99:        // 固定長なら fixed にバイト数、可変長なら fixed は 0。
                    100:        // 逆アセンブルなら inst_bytes に最短バイト数。
                    101:        // (m88k 逆アセンブルはどちらも満たす)
                    102:        int fixed {};
                    103:        int inst_bytes {};
1.1       root      104: 
1.1.1.2   root      105:        DebuggerMD *md {};
1.1.1.3 ! root      106:        IODevice *bus {};
1.1       root      107: 
1.1.1.2   root      108:        static const char * const dtname[4];
1.1       root      109: };
                    110: 
1.1.1.2   root      111: // メモリダンプ/逆アセンブルモニタ
                    112: class MemdumpMonitor : public Memdump
1.1       root      113: {
1.1.1.2   root      114:        using inherited = Memdump;
1.1       root      115:  public:
1.1.1.2   root      116:        MemdumpMonitor(int objid_, int monid_);
                    117:        ~MemdumpMonitor() override;
1.1       root      118: 
1.1.1.2   root      119:        int GetLineOffset(int n) const;
                    120:        int GetPageOffset(int n) const;
1.1       root      121: 
                    122:  private:
1.1.1.2   root      123:        DECLARE_MONITOR_CALLBACK(MonitorUpdate);
                    124: 
                    125:        void MonitorUpdateMemdump(TextScreen&, DebuggerMemoryStream&);
                    126:        void MonitorUpdateDisasm(TextScreen&, DebuggerMemoryStream&);
                    127:        void Update68030PageShort(TextScreen&, int, int, const std::vector<int>&);
                    128:        void Update88200Page(TextScreen&, int, int, const std::vector<int>&);
                    129: 
1.1.1.3 ! root      130:        // 命令開始アドレス。
        !           131:        // [0] が1行目のアドレス、
        !           132:        // [1] が2行目のアドレス、
1.1.1.2   root      133:        // :
1.1.1.3 ! root      134:        // [row - 1] が表示されてる最下行のアドレス、
        !           135:        // [row] が最下行の次のアドレス、
1.1.1.2   root      136:        // を指している。
                    137:        std::vector<uint32> nextaddr {};
                    138: 
                    139:        Monitor monitor { this };
1.1       root      140: };

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.