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

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

unix.superglobalmegacorp.com

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