Files
ppsspp/Core/CmdLine.h
Henrik RydgårdandClaude Sonnet 5 29a38af37e Per-module symbol save/load, module identity via crc, GetModuleIndex fix
SymbolMap:
- Fix GetModuleIndex(): it only checked the end of an active module's range
  (via activeModuleEnds.upper_bound), never the start, so an address sitting
  in the gap before a module was silently misattributed to it. Added
  GetModuleIndexByName() as a companion lookup.
- AddModule() gains an optional crc param, stored per ModuleEntry. Reactivating
  a module by name now also requires the crc to agree when both sides know it,
  so two unrelated binaries that happen to share a name no longer get merged
  into one symbol table (addresses the old TODO at the top of SymbolMap.h).
- AddLabel()/AddFunction() gain an updateName param (default false, preserving
  existing "first writer wins" behavior) so a trusted source - like a loaded
  symbol file - can be allowed to overwrite a name that a lower-confidence
  automatic pass already assigned.
- New SaveModuleSymbols()/LoadModuleSymbols()/GetModuleSymbolsPath(): save or
  restore one module's functions/data/labels to/from a small human-editable
  text file, addressed relative to the module (so the file stays valid however
  the module ends up positioned on a later run). Keyed by
  PSP/SYSTEM/SYMBOLS/<moduleName>_<crc>.ppsym - deliberately by module+crc
  rather than by game, so it's shared by every game/homebrew that loads the
  exact same module. A "# game <id> <title>" comment records who last saved
  it, informational only.

WebSocket debugger: hle.module.saveSymbols/loadSymbols expose the above.

sceKernelModule.cpp: auto-load a module's saved symbols right after it's
registered with the symbol map (both the real ELF-load path and the
savestate-load path), and auto-save on unload (before UnloadModule(), while
its symbols are still active) - gated behind the new bAutoSaveLoadSymbols
config setting (default off), with a matching Developer Tools checkbox and
a --auto-save-load-symbols command-line override for headless use.

Includes some in-progress cleanup already staged: DescribeAddress now calls
g_symbolMap->GetDescription() directly instead of through the now-removed
MIPSDebugInterface::getDescription() wrapper.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-17 16:01:23 +02:00

124 lines
4.2 KiB
C++

#pragma once
#include <optional>
#include "Common/Log.h"
#include "Core/ConfigValues.h"
enum class CommandLineParseResult {
Continue,
Exit,
Error,
};
enum class CmdLineMode {
Both,
Application,
Headless,
};
// We collect command line options in this struct, then we apply it to the config after it's been loaded.
// This parser is shared between regular PPSSPP and headless, so there are some options that are only useful
// in one of them.
// When adding new options, don't forget to update g_autoParams in CmdLine.cpp (or write manual parsing).
struct CommandLineOptions {
// If returns CommandLineParseResult::Exit or ::Error, the program should exit immediately (with an error return code if Error).
CommandLineParseResult Parse(int argc, const char *argv[], CmdLineMode mode = CmdLineMode::Application);
void ApplyToConfig() const;
int PrintUsage(const char *progname, const char *situationText) const;
CmdLineMode mode;
std::optional<bool> fullscreen;
std::optional<GPUBackend> gpuBackend;
std::optional<bool> softwareRendering;
std::optional<bool> enableLogging;
std::optional<LogLevel> logLevel; // Override log level with this.
std::optional<std::string> log;
std::vector<std::string> bootFilenames;
std::optional<CPUCore> cpuCore;
std::optional<std::string> startScreen;
std::optional<bool> escapeExit;
std::optional<bool> pauseMenuExit;
// Enables the WebSocket debugger on startup, on this port (0 = pick automatically).
// Also breaks the CPU at start in the headless build. See docs/WebSocketDebugger.md.
std::optional<int> debuggerPort;
// Overrides g_Config.bAutoSaveLoadSymbols for this run only (see SymbolMap::SaveModuleSymbols/
// LoadModuleSymbols and Core/HLE/sceKernelModule.cpp) - handy for headless runs that want
// symbol names without persisting the setting via Settings > Developer Tools.
std::optional<bool> autoSaveLoadSymbols;
// Attempts to boot the vsh, which will only work if the correct files are present in the flash
// and once we've fixed all the bugs. This is just here to allow testing.
std::optional<bool> bootVSH;
std::optional<std::string> appendConfig;
std::optional<std::string> root; // mount root, needs more explanation
std::optional<std::string> stateToLoad;
std::optional<int> memReadAction;
std::optional<int> memWriteAction;
std::optional<int> breakAction;
// Log a native stack trace (Windows only) on an otherwise-unhandled access violation.
std::optional<bool> logNativeCrashes;
// SDL only: Option to force a specific OpenGL version (42="4.2",
// etc.; -1 means "try them all").
// Implemented as a workaround for https://github.com/hrydgard/ppsspp/issues/20687
// NOTE: this is currently not persistent (doesn't
// go to config), even though --graphics=openglX.Y
// also sets the GPU backend which does persist.
int force_gl_version = -1;
#ifndef _DEBUG
bool showLogWindow = false;
#else
bool showLogWindow = true;
#endif
std::string configFilename = "";
std::string controlsConfigFilename = "";
bool optionS = false; // a legacy option
std::optional<bool> oldAtrac;
// Headless options that may also be mildly useful in application mode
std::optional<int> resolutionScale;
// Headless options
std::optional<bool> compare;
std::optional<bool> bench;
std::optional<bool> verbose;
std::optional<double> timeout;
std::optional<bool> printEqualLines;
std::optional<std::string> screenshotFilename;
std::optional<std::string> screenshotFilenameSave;
std::optional<std::string> screenshotFilenameDiff;
// Headless: preserve the alpha channel when saving PNG screenshots.
std::optional<bool> screenshotSaveKeepAlpha;
// Headless: mount an ISO/CSO on umd1:.
std::optional<std::string> mountIso;
// Headless: also log through OutputDebugString (Windows).
std::optional<bool> odsLog;
// Headless: maximum allowed MSE error for screenshot comparison.
std::optional<double> maxScreenshotError;
// Headless: test names to skip. May be specified more than once.
std::vector<std::string> ignoredTests;
// Headless: generate C++ interpreter dispatch code to stdout and exit.
std::optional<bool> generateInterpreterDispatch;
// SDL only.
std::optional<int> xres;
std::optional<int> yres;
std::optional<double> dpi;
std::optional<double> scale;
};