Chromium `debugger` equivalent, on `gdb` for Cygwin?

白昼怎懂夜的黑 提交于 2020-05-28 06:37:09

问题


How do people trigger a breakpoint on gdb (for Cygwin, specifically) from the very source code?

Like when a JS script has the debugger word in it and Chromium dev tools trigger stop for debugging?


回答1:


Here's how SDL2 implements this feature:

#if defined(_MSC_VER)
/* Don't include intrin.h here because it contains C++ code */
    extern void __cdecl __debugbreak(void);
    #define SDL_TriggerBreakpoint() __debugbreak()
#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) )
    #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
#elif defined(__386__) && defined(__WATCOMC__)
    #define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
    #include <signal.h>
    #define SDL_TriggerBreakpoint() raise(SIGTRAP)
#else
    /* How do we trigger breakpoints on this platform? */
    #define SDL_TriggerBreakpoint()
#endif

The conditionals should probably resolve to __asm__ __volatile__ ( "int $3\n\t" ) on Cygwin.



来源:https://stackoverflow.com/questions/61803664/chromium-debugger-equivalent-on-gdb-for-cygwin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!