Commit Graph
32 Commits
Author SHA1 Message Date
Henrik Rydgård 029066a977 DisassemblyManager: fix zero-size-symbol crash, OOB read, and other bugs
- DisassemblyFunction/DisassemblyData::getLineAddress() indexed
  lineAddresses[0] unconditionally; a zero-size symbol (reachable via
  the WebSocket debugger's hle.func.add/hle.data.add with an
  attacker-controlled size, a crafted ELF symtab entry with
  st_size==0, or the debugger UI's "set function size") leaves that
  vector empty, making findDisassemblyEntry's getLineAddress(0) call
  undefined behavior. Fall back to the symbol's own base address when
  out of range instead.
- DisassemblyData::createLines() detected an invalid address range and
  logged it, but fell through anyway into a loop reading through that
  whole range with the Unchecked memory accessors, which on
  non-masked builds do a raw pointer dereference with no bounds check
  at all. Added the missing return.
- DisassemblyLineInfo::ToString()'s snprintf calls all used
  sizeof(text) where text is a char* parameter (pointer size, not
  buffer size), silently truncating all output to a few characters
  instead of using the real bufSize parameter that was passed in but
  never used.
- analyze()'s misaligned-tail-data case stored the DisassemblyData
  entry under key alignedNext, but constructed it with the earlier
  (possibly much earlier) `address` as its own base address instead of
  alignedNext, misattributing those bytes to the wrong location.
2026-08-12 09:43:23 +02:00
Henrik Rydgård 4f8859d0ec Centralize a disassembly utility function between the debuggers 2026-08-11 09:08:52 +02:00
Henrik RydgårdandClaude Sonnet 5 b1f0112cef Debugger: Remove opcode-fusion display and fix cpu step size units
DisassemblyManager used to fuse lui+addiu/load/store into single pseudo-
instructions ("li", fused loads/stores) for display. This only applied to a
handful of opcodes, complicated DisassemblyManager, and was the root cause of
a stepping bug: Core_PerformCPUStep's Into/Over cases treated stepSize as a
byte count, while the WebSocket cpu.stepInto handler computed it as an
instruction count (needed to step over a whole fused macro in one go) - so a
plain, non-fused stepInto silently executed zero instructions.

Removed the fusion logic entirely (DisassemblyMacro, DISTYPE_MACRO) - every
disassembly line is now exactly one 4-byte instruction. With that,
"how many instructions does this line span" is always 1, so the
getInstructionSizeAt() byte-size queries in the legacy Windows and ImGui
debuggers are gone too; step requests just pass 1. Core_RequestCPUStep's
stepSize is now consistently in instructions everywhere.

Also fixes the PPSSPPHeadless build, broken since 0ed1f3e added
OpenWebDebugger() (which calls System_LaunchUrl) without a headless stub.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hqm11k99viLfbJm2MkH4BH
2026-08-08 11:16:36 +02:00
Henrik Rydgård ff37cbe184 Minor memory safety fixes 2025-05-14 09:39:09 +02:00
Henrik Rydgård acad90a041 More work on the lua console 2025-03-27 14:26:48 +01:00
Henrik Rydgård 23954f5403 Implement the disassembly mode too 2025-01-09 13:35:29 +01:00
Henrik Rydgård 597be1c9bc Stop pretending that DisassemblyManager isn't a singleton - it currently is. 2024-12-12 19:25:04 +01:00
Henrik Rydgård 20a17a0e8d Reorganize DebugInterface etc a bit.
KernelThreadDebugInterface no longer has a useless copy of a MIPSDebugInterface.
2024-12-12 18:54:46 +01:00
Henrik Rydgård 39ffe92e0a LR->RA rename, fixes 2024-12-12 17:47:37 +01:00
Herman Semenov af41281761 [Core/Dialog/ELF/FileSystems/HLE/HW/Util] Added const reference for function params 2023-12-14 14:22:24 +03:00
Unknown W. Brackets f44852bb18 Global: Cleanup virtual/override specifiers.
Also missing virtual destructors, hidden non-overrides, etc.
2022-12-10 21:13:36 -08:00
Unknown W. Brackets 012d47bcbf Debugger: Show string in status bar for li, etc.
This is helpful when stepping through the debugger.  Only shows likely
UTF-8 or similar formatted text, but often names or error messages are.
2021-04-21 23:50:59 -07:00
Unknown W. Brackets 4178f09e57 Build: More consistently avoid _M_ defines.
We use PPSSPP_ARCH in several places already, this makes it more complete.
2021-03-02 21:49:21 -08:00
Unknown W. Brackets 5670fc03ae Debugger: Add debug interfaces for threads.
This way we can switch context.
2018-06-08 06:59:18 -07:00
Unknown W. Brackets 0b8359fd77 Debugger: Add mutexing to disassembly manager.
It was crashing when accessing from another thread.

If in the future we go down to only the remote debugger, we could
potentially remove this.
2018-06-06 05:58:49 -07:00
Unknown W. Brackets 7613fd97aa Windows: Fix minor leak in disassembly UI. 2017-04-27 20:02:49 -07:00
Lioncash b1901fbad2 Core: Remove unimplemented class function declarations 2015-10-18 10:55:11 -04:00
Lioncash cac632424c Core: Add missing override specifiers 2014-12-08 15:20:31 -05:00
Unknown W. Brackets 2b16b5b79b Use XXH64 on 64-bit systems.
I'm not able to reproduce any real performance difference, but I know
there are some games which do more hashing and it may help there.
2014-10-26 17:49:24 -07:00
Henrik Rydgård 00c32ddadb Mostly get rid of including "Globals.h" 2013-12-30 10:17:11 +01:00
Unknown W. Brackets db77dcd149 Fix some includes on Windows/etc. 2013-12-29 15:59:36 -08:00
Kingcom 85abd37ed1 Small debugger fixes and enhancements 2013-11-29 17:21:48 +01:00
Kingcom 561379f5c2 Create data directives in disassembler 2013-11-28 00:33:21 +01:00
Kingcom 33da416a82 Reduce disassembler memory usage 2013-11-26 22:20:12 +01:00
Kingcom b71bfe5a62 -Get branch lines for opcodes outside of a function
-fix labels causing analyzing issues
2013-11-25 21:53:01 +01:00
Kingcom 9a29e8b0bf More efficient "loose" opcode detection, clear entries when symbols were loaded 2013-11-25 16:18:29 +01:00
Kingcom 60987d9217 Minor optimization 2013-11-25 14:19:45 +01:00
Kingcom 42c5fe0164 Massive speed optimizations 2013-11-25 13:56:43 +01:00
Kingcom aab6f588f1 Fix branch lines 2013-11-24 14:46:53 +01:00
Kingcom 0672458a33 Fix follow branch, display symbols 2013-11-24 13:53:50 +01:00
Kingcom 63e2f34beb Correctly identify the start of a line when changing the address 2013-11-24 13:53:50 +01:00
Kingcom a928c62ad1 Basic implementation and integration of DisassemblyManager 2013-11-24 13:53:50 +01:00