feat(debugtools): fold pfDebug in as /profiler

pfDebug was a separate addon that profiled through ClassicAPI's own
APIs: GetAddOnMemoryUsage and GetAddOnCPUUsage, GetFrameCPUUsage,
GetFunctionCPUUsage, GetEventCPUUsage, and the intrinsic precall and
postcall script hooks. Its code now lives in ClassicAPI_DebugTools
under Profiler/, with its MIT notice (Copyright (c) 2018 Shagu). The
analyzer tabs (Addons, Frames, Events, Globals) and the widget are
pfDebug's, with the frame and template names renamed to
ClassicAPIProfiler*.

/profiler and /prof load DebugTools on demand through the same stub as
/dump, then toggle the analyzer. The subcommands widget, reset and
profile on|off are pfDebug's.

What changed in the move:

- The sampler starts only when the widget or the analyzer first opens,
  so a load for /dump costs nothing. It first takes every counter as it
  is, so the first CPU/s and KB/s cover one second, not the session.
- Whether profiling runs is probed, not read from the cvar: a function
  is called once and GetFunctionCPUUsage must count that call. The
  scriptProfile cvar can already hold the next session's value.
- A frame record starts at the frame's current CPU time and call count,
  and opening the analyzer takes every frame and event counter again,
  because the frame totals and the deep hooks keep counting while it is
  closed. pfDebug started records at 0, so the first scan and each
  reopen showed a frame's whole session as one second.
- The /fstack lines (owner, OnUpdate and OnEvent owner and CPU, all
  scripts, deep allocations) are added at the end of
  FrameStackTooltip_OnTooltipSetFrameStack, not by hooking
  OnTooltipSetFrameStack.
- No pfUI skin and no SavedVariables. The plain backdrop is pfDebug's
  own fallback. The widget no longer opens at login, because that would
  load DebugTools at login.

README's Debug tools table gains /profiler and the new /fstack lines.
This commit is contained in:
Brues
2026-10-31 23:16:01 -05:00
parent 4509da0966
commit f19f13d44c
14 changed files with 1762 additions and 2 deletions
@@ -26,9 +26,12 @@
-- the time column without re-anchoring frames.
--
-- The table inspector (/tinspect, Ctrl in /fstack) is retail's
-- Blizzard_TableInspector; see TableInspector.lua.
-- Blizzard_TableInspector; see TableInspector.lua. The profiler (/profiler)
-- is in Profiler/, and adds its owner and CPU lines to /fstack.
------------------------------------------------------------------------------
local _, ns = ...;
EVENT_TRACE_EVENT_HEIGHT = 16;
EVENT_TRACE_MAX_ENTRIES = 1000;
-- Toolbar above the event list (Pause + Args/Time toggles + Search) eats
@@ -1184,6 +1187,8 @@ function FrameStackTooltip_OnTooltipSetFrameStack(self, highlightFrame)
if (fsobj) then
self:AddLine(string.format("\nfsobj = %s", fsobj:GetDebugName()));
end
ns.AddFrameStackLines(self, self.highlightFrame);
end
function FrameStackTooltip_Show(self, showHidden, showRegions)