PCSX2 / pcsx2

PCSX2 - The Playstation 2 Emulator
https://pcsx2.net
Other
10.65k stars 1.55k forks source link

[BUG] False positive function listings in debug window hiding correct symbols #4024

Open escape209 opened 3 years ago

escape209 commented 3 years ago

Describe the bug In the Functions tab of the Debug Window, there are/may be several incorrect function symbols added, all with the naming scheme z_un_[memory address]. These false positives cause correct symbols to not be listed as they are considered to be a part of the incorrectly detected, non-existent function. image

In the above case, the symbol GetCrashWind__13CB4StageLogic13ERaceCarIndex comes after the incorrect symbol z_un_004339f0, which causes the latter to be listed in the Functions list instead of the former.

To Reproduce

  1. Boot up a game with debug symbols (in this case, Burnout Revenge Alpha 7 build, CRC 815B946C.
  2. Click Window -> Show Debug to open the Debug Window.
  3. Allow the game to progress past the initial loading stages.
  4. Click Break and wait for the Functions list to be populated.
  5. Scroll to the very bottom and there should be a lot of listings in the format z_un_[memory address].

Expected behavior

Expected the correct function listings to appear in the list instead of the incorrect ones. Because of this issue, hundreds of correct symbols do not appear in the list as they should.

A temporary workaround is to simply right click the incorrect function and click "Remove Function", then right click the correct one and click "Add Function Here." For such a huge number of these functions, though, this is clearly infeasible.

GS Settings

N/A

Emulation Settings

N/A

GS Window Screenshots

N/A

System Info (please complete the following information):

Logs and Dumps

B4EXTERN.MAP.txt

The game's .map file.

Mrlinkwii commented 1 year ago

Can this be checked on latest nightly? :)

escape209 commented 10 months ago

Checked on latest nightly, still appears to be an issue. The symbols are interpreted fine in Ghidra using the ghidra-emotionengine-reloaded extension.

TheTechnician27 commented 5 months ago

https://github.com/PCSX2/pcsx2/blob/3e225d78fafe9ef04717b94e1c68c14356468e4a/pcsx2/DebugTools/MIPSAnalyst.cpp#L121 Looks like this is the default function name in the MIPS analysis tool. It's only called once, and that's in the ScanForFunctions function.

TheTechnician27 commented 5 months ago

nop function

Looking at this further, I 100% agree there are addresses which are falsely detected as functions and then given the default name (in this case, this was taken in ATV: Offroad Fury).

F0bes commented 2 months ago

I don't see any reason why the function analyzer should be creating functions there. Which leads me to suspect that the game is either dynamically swapping code in and out, or the "main" game is actually a different ELF than the SLUS/SLES/etc that is first loaded. This is related to #2065, which I tried to fix when adding the refresh option to the function listing. Can someone see if the issue persists with #10224?