Re:NanoLog – a nanosecond scale logging system for C++
by Const-me on Sunday September 01, 2019 @03:46PM
(#20854358)
Recently built similar stuff. Even using same __rdtsc() for time.
I didn't require any preprocessing. Instead, I require the strings come from readonly section of a module, and logging pointer values. Also logging into circular buffer in shared memory instead of file, as I was only interested in knowing what the app did immediately before a rare crash which takes hours to reproduce.
[ Parent
| on HN ]
Re:NanoLog – a nanosecond scale logging system for C++
by rafa1981 on Sunday September 01, 2019 @03:57PM
(#20854454)
I did exactly the same on my two loggers, as a C literal is always read only and unique, passing a printf-like string is passing a pointer.
The it's just a matter of adding validation and passing the arguments in a compact way.
Re:NanoLog – a nanosecond scale logging system for C++
by bonzini on Sunday September 01, 2019 @04:18PM
(#20854599)
How do you deal with ASLR (logging from shared libraries or from position-independent executables)?
Re:NanoLog – a nanosecond scale logging system for C++
by Const-me on Sunday September 01, 2019 @07:42PM
(#20855693)
In that particular case I’ve cheated. I’m writing out of band file which maps pointer addresses into strings. In runtime it’s CAtlMap<const char*, int> really fast because the keys are just addresses. I only have ~200 unique messages (ignoring format arguments) so the file is only written for the first few milliseconds.
I did that because it was the simplest thing to do. I could use debug symbols + crash dumps, they can resolve these pointers regardless of ASLR, just it was way more complex to implement.
BTW, the only reason I was doing that, the main executable is gta5.exe, it’s encrypted, it resists debugging, and I don’t have debug symbols. If it was my own app, I would probably do something much simpler instead.