Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.95k stars 554 forks source link

implement C_BP macro for throwing a C debugger breakpoint WIP #22670

Open bulk88 opened 1 week ago

bulk88 commented 1 week ago

My fingers hurt typing DebugBreak() all these years. Time for an API. Commit is a WIP since there is some dead code from 1st impl, but I decided the "speed" of memcpy, isn't worth the extra 0x30 bytes of machine code, and '\0' padding to 8 byte alignment boundaries done by MSVC of 4 separate c strings in RO data section vs 1 c string (snprintf fmt str). Just call snprintf() the slow way. Runtime speed is irrelevant here. This code will never run except for an XS dev or p5p dev writing a new module or bug fixing.

If there aren't suggested changes, I'll clean it up into a final version in a day or 2. The code could also be added to ppport.h to mk life easier for all XS devs on all PL releases.


-short macro name, less to type -cross platform -makes it easier to work on Perl core or XS CPAN -emits debug info to console for CI/smoke/unattended machine -writes to STDOUT and STDERR, incase one of the 2 FDs are redirected to a disk file or piped to another process, or that disk file is temp flagged, and OS instantly deletes it -breaking TAP testing is good -C_BP; is less to type vs DebugBreak(); or __debugbreak(); on Win32


bulk88 commented 1 week ago

repushed __debugbreak_int3 prototype was wrong

bulk88 commented 4 days ago

Prefer GCC calller's address API first even on Win32, use official MS API 2nd on Win32. Improve last resort fallback for all OSes. Add test that the macro works and prints to the screen.

bulk88 commented 4 days ago

repushed, forgot to stage func prototype retval fix which was causing GCC warnings

bulk88 commented 4 days ago

repushed fix for __FUNCTION___ is a linker symbol on GCC not a string literal

Leont commented 1 day ago

-short macro name, less to type

I do not see that as an advantage, it looks more like obfuscation to me