diasurgical / devilutionX

Diablo build for modern operating systems
Other
8.01k stars 786 forks source link

Add a `StaticVector` pretty-printer for LLDB #7344

Closed glebm closed 1 month ago

glebm commented 1 month ago

7335 added a pretty-printer for GDB, this one adds it for LLDB.

Example session:

$ lldb build/devilutionx
(lldb) target create "build/devilutionx"
Current executable set to '/home/gleb/devilutionX/build/devilutionx' (x86_64).
(lldb) b Source/engine/load_file.hpp:126
* thread #1, name = 'devilutionx', stop reason = breakpoint 1.1
    frame #0: 0x0000555558a8145d devilutionx`devilution::MultiFileLoader<6>::operator(this=0x00007ffff1cd0430, numFiles=5, pathFn=0x00007ffff1cd0540, outOffsets=0x00007ffff1cd01c8, filterFn=(unnamed struct) @ 0x00007ffff1e1b080)<devilution::FileNameWithCharAffixGenerator, devilution::(anonymous namespace)::LoadMonsterSpritesData(const devilution::MonsterData&)::<lambda(size_t)> >(size_t, devilution::FileNameWithCharAffixGenerator &&, uint32_t *, (unnamed struct)) const at load_file.hpp:126:28
   123              totalSize += size;
   124              ++j;
   125          }
-> 126          outOffsets[files.size()] = static_cast<uint32_t>(totalSize);
   127          std::unique_ptr<std::byte[]> buf { new std::byte[totalSize] };
   128          for (size_t i = 0, j = 0; i < numFiles; ++i) {
   129              if (!filterFn(i))
(lldb) run
(lldb) p files
(devilution::StaticVector<devilution::AssetRef, 6>) {
  [0] = {
    archive = 0x000055555c8d8940
    fileNumber = 1420
    filename = (_M_len = 27, _M_str = "monsters\\zombie\\zombien.cl2")
    directHandle = nullptr
  }
  [1] = {
    archive = 0x000055555c8d8940
    fileNumber = 1421
    filename = (_M_len = 27, _M_str = "monsters\\zombie\\zombiew.cl2")
    directHandle = nullptr
  }
  [2] = {
    archive = 0x000055555c8d8940
    fileNumber = 1422
    filename = (_M_len = 27, _M_str = "monsters\\zombie\\zombiea.cl2")
    directHandle = nullptr
  }
  [3] = {
    archive = 0x000055555c8d8940
    fileNumber = 1423
    filename = (_M_len = 27, _M_str = "monsters\\zombie\\zombieh.cl2")
    directHandle = nullptr
  }
  [4] = {
    archive = 0x000055555c8d8940
    fileNumber = 1424
    filename = (_M_len = 27, _M_str = "monsters\\zombie\\zombied.cl2")
    directHandle = nullptr
  }
}