Annotation of nono/debugger/test_debugger_memory.cpp, revision 1.1

1.1     ! root        1: //
        !             2: // nono
        !             3: // Copyright (C) 2022 nono project
        !             4: // Licensed under nono-license.txt
        !             5: //
        !             6: 
        !             7: // テスト用の DebuggerMemoryStream の簡易でっち上げ版。
        !             8: // 実物をリンクすると芋づる式に必要なものが増えるので。
        !             9: // アドレスは paddr のみ使うことにする。
        !            10: //
        !            11: // testdis.cpp 等から ram[] の宣言以降に直接 include して使う。
        !            12: 
        !            13: static inline uint64
        !            14: vm_phys_peek_8(uint32 addr)
        !            15: {
        !            16:        assertmsg(addr < sizeof(ram), "addr=0x%x", addr);
        !            17: 
        !            18:        // XXX endian
        !            19:        return ram[addr ^ 1];
        !            20: }
        !            21: 
        !            22: // コンストラクタ
        !            23: DebuggerMemoryStream::DebuggerMemoryStream(const DebuggerMD *md_,
        !            24:        const saddr_t& laddr_, MemoryMode access_mode, MMULookupMode lookup_mode)
        !            25: {
        !            26:        md = md_;
        !            27:        laddr = laddr_;
        !            28:        paddr = laddr.GetAddr();
        !            29: }
        !            30: 
        !            31: uint64
        !            32: DebuggerMemoryStream::Peek(int bytes)
        !            33: {
        !            34:        uint64 data;
        !            35: 
        !            36:        data = 0;
        !            37:        for (int i = 0; i < bytes; i++) {
        !            38:                data <<= 8;
        !            39:                data |= vm_phys_peek_8(paddr + i);
        !            40:        }
        !            41:        return data;
        !            42: }
        !            43: 
        !            44: uint64
        !            45: DebuggerMemoryStream::Read(int bytes)
        !            46: {
        !            47:        uint64 data;
        !            48: 
        !            49:        data = Peek(bytes);
        !            50:        laddr += bytes;
        !            51:        paddr += bytes;
        !            52:        return data;
        !            53: }

unix.superglobalmegacorp.com

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