retrowin32 icon indicating copy to clipboard operation
retrowin32 copied to clipboard

Add function name to trace context

Open encounter opened this issue 1 year ago • 2 comments

Allows enabling/disabling individual functions with --win32-trace.

encounter avatar Jul 23 '24 23:07 encounter

Thinking about this more, I wonder if each function should just stash a tracing_enabled local unsafe static rather than this hash map, because each function will have its own separate tracing state (?).

Also I think this means we end up embedding the ddraw/SomeFunctionName strings in the binary for each function.

Together those make me wonder if there's some other way to set this up, hrmm.

evmar avatar Jul 24 '24 06:07 evmar

This ends up adding an entry per function in

https://github.com/evmar/retrowin32/blob/692764792fe7a76d218cab751ec16cc85fde9c7f/win32/src/trace.rs#L65

. I'm trying to decide if it really matters though. It feels kind of wrong?

I think it's fine, personally. If performance ends up causing an issue there, we'd want to switch away from std::collections::HashMap and rethink the approach anyway.

I wonder if each function should just stash a tracing_enabled local unsafe static rather than this hash map, because each function will have its own separate tracing state (?).

I like the idea of having it local to the function, but I also think it's teetering on premature optimization...

encounter avatar Jul 24 '24 20:07 encounter