debugbreak | break into the debugger | Code Inspection library

 by   scottt Python Version: v1.0 License: BSD-2-Clause

kandi X-RAY | debugbreak Summary

kandi X-RAY | debugbreak Summary

debugbreak is a Python library typically used in Code Quality, Code Inspection applications. debugbreak has no bugs, it has no vulnerabilities, it has a Permissive License and it has high support. However debugbreak build file is not available. You can download it from GitHub.

[debugbreak.h] allows you to put breakpoints in your C/C++ code with a call to debug_break():. License: the very permissive [2-Clause BSD] Known Problem: if continuing execution after a debugbreak breakpoint hit doesn’t work (e.g. on ARM or POWER), see [HOW-TO-USE-DEBUGBREAK-GDB-PY.md] HOW-TO-USE-DEBUGBREAK-GDB-PY.md) for a workaround.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              debugbreak has a highly active ecosystem.
              It has 554 star(s) with 72 fork(s). There are 32 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 6 open issues and 11 have been closed. On average issues are closed in 356 days. There are 2 open pull requests and 0 closed requests.
              OutlinedDot
              It has a negative sentiment in the developer community.
              The latest version of debugbreak is v1.0

            kandi-Quality Quality

              debugbreak has 0 bugs and 0 code smells.

            kandi-Security Security

              debugbreak has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              debugbreak code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              debugbreak is licensed under the BSD-2-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              debugbreak releases are available to install and integrate.
              debugbreak has no build file. You will be need to create the build yourself to build the component from source.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed debugbreak and discovered the below as its top functions. This is intended to give you an instant insight into debugbreak implemented functionality, and help decide if they suit your requirements.
            • Invoke debugger
            • Parse GDB show version string
            • Return the jump length of a breakpoint instruction
            • Debug breakpoint
            • Return the name of the target
            • Invoke the debugger
            • Continue the debugger
            Get all kandi verified functions for this library.

            debugbreak Key Features

            No Key Features are available at this moment for debugbreak.

            debugbreak Examples and Code Snippets

            No Code Snippets are available at this moment for debugbreak.

            Community Discussions

            QUESTION

            Is it guaranteed that x86 instruction fetch is atomic, so that rewriting an instruction with a short jump is safe for concurrent thread execution?
            Asked 2021-Dec-05 at 00:12

            I thought hot-patching assumed that overwriting any instruction that is 2 or more bytes long with a 2 byte jump is safe for concurrent execution of the same code.

            So instruction fetch is assumed to be atomic.

            Is it indeed atomic, taking into account that with prefixes it is possible to have more than 8 bytes instruction, and it can cross any aligned boundary? (Or does hot-patching rely on 16-byte alignment of function start? If so, what's with size over 8 bytes, anyway?)

            The context: LLVM has interception of API functions in https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/interception/interception_win.cpp. This is used at least for Address Sanitizer, maybe for something else too. It implements HotPatch as 3rd method (line 61):

            ...

            ANSWER

            Answered 2021-Dec-05 at 00:12

            Instruction fetch is not architecturally guaranteed to be atomic. Although, in practice, an instruction cache fill transaction is, by definition atomic, meaning that the line being filled in the cache cannot change before the transaction completes (which happens when the whole line is stored in the IFU, but not necessarily in the instruction cache itself). The instruction bytes are also delivered to the input buffer of the instruction predecode unit at some atomic granularity. On modern Intel processors, the instruction cache line size is 64 bytes and the input width of the predcode unit is 16 bytes with an address aligned on a 16-byte boundary. (Note that the 16 bytes input can be delivered to the predecode unit before the entire transaction of fetching the cache line containing these 16 bytes completes.) Therefore, an instruction aligned on a 16-byte boundary is guaranteed to be fetched atomically, together with at least one byte of the following contiguous instruction, depending on the size of the instruction. But this is a microarchitectural guarantee, not architectural.

            It seems to me that by instruction fetch atomicity you're referring to atomicity at the granularity of individual instructions, rather than some fixed number of bytes. Either way, instruction fetch atomicity is not required for hotpatching to work correctly. It's actually impractical because instruction boundaries are not known at the time of fetch.

            If instruction fetch is atomic, it may still be possible to fetch, execute, and retire the instruction being modified with only one of the two bytes being written (or none of the bytes or both of the bytes). The allowed orders in which writes reach GO depend on the effective memory types of the target memory locations. So hotpatching would still not be safe.

            Intel specifies in Section 8.1.3 of the SDM V3 how self-modifying code (SMC) and cross-modifying code (XMC) should work to guarantee correctness on all Intel processors. Regarding SMC, it says the following:

            To write self-modifying code and ensure that it is compliant with current and future versions of the IA-32 architectures, use one of the following coding options:

            (* OPTION 1 *)
            Store modified code (as data) into code segment;
            Jump to new code or an intermediate location;
            Execute new code;

            (* OPTION 2 *)
            Store modified code (as data) into code segment;
            Execute a serializing instruction; (* For example, CPUID instruction *)
            Execute new code;

            The use of one of these options is not required for programs intended to run on the Pentium or Intel486 processors, but are recommended to ensure compatibility with the P6 and more recent processor families.

            Note that the last statement is incorrect. The writer probably intended to say instead: "The use of one of these options is not required for programs intended to run on the Pentium or later processors, but are recommended to ensure compatibility with the Intel486 processors." This is explained in Section 11.6, from which I want to quote an important statement:

            A write to a memory location in a code segment that is currently cached in the processor causes the associated cache line (or lines) to be invalidated. This check is based on the physical address of the instruction. In addition, the P6 family and Pentium processors check whether a write to a code segment may modify an instruction that has been prefetched for execution. If the write affects a prefetched instruction, the prefetch queue is invalidated. This latter check is based on the linear address of the instruction

            Briefly, prefetch buffers are used to maintain instruction fetch requests and their results. Starting with the P6, they were replaced with streaming buffers, which have a different design. The manual still uses the term "prefetch buffers" for all processors. The important point here is that, with respect to what is guaranteed architecturally, the check in the prefetch buffers is done using linear addresses, not physical addresses. That said, probably all Intel processors do these checks using physical addresses, which can be proved experimentally. Otherwise, this can break the fundamental sequential program order guarantee. Consider the following sequence of operations being executed on the same processor:

            Source https://stackoverflow.com/questions/70161514

            QUESTION

            Event Tracing for Windows: OpenTrace/ProcessTrace not returning any events - callback not being called
            Asked 2021-Nov-01 at 19:14
            Short Version

            I'm trying to use OpenTrace and ProcessTrace to read the events of a .etl file.

            • the call to OpenTrace successfully returns a TRACEHANDLE
            • the call to ProcessTrace returns ERROR_SUCCESS
            • but ProcessTrace never calls my EVENT_CALLBACK callback function

            I know it's a valid .etl file, because i can open it in:

            Long Version

            Microsoft provides sample code on reading the events of a .etl file. The basic gist is:

            1. Initialize an EVENT_TRACE_LOGFILE structure with the filename we want to open, and the address of our callback function. The callback function is called once for every event in the file:

              ...

            ANSWER

            Answered 2021-Nov-01 at 19:14

            The answer is exactly what I knew it would be.

            • i started with headers translated by Franck Soranio
            • where some definitions were packed records
            • when that didn't work, I tried adding $ALIGN 8 - the ABI required by Windows
            • when that didn't work, I tried adding packed to all records

            When that didn't work, i asked Stackoverflow.

            In the meantime, i spun up Visual Studio C++, and compared the sizeof of the original structures, and the Delphi translations.

            They didn't match.

            The problem was the packed records.

            • sizeof(EVENT_TRACE_LOGFILEW): 416 bytes (was 404)
              • sizeof(EVENT_TRACE): 88 bytes (was 80)
                • sizeof(EVENT_TRACE_HEADER): 44 bytes (was 40)
              • sizeof(TRACE_LOGFILE_HEADER): 272 bytes

            Removing the record packing fixed it.

            Source https://stackoverflow.com/questions/69780730

            QUESTION

            What's the purpose of xchg ax,ax prior to the break instruction int 3 in DebugBreak()?
            Asked 2021-Oct-27 at 14:58

            In MASM, I've always inserted a standalone break instruction

            ...

            ANSWER

            Answered 2021-Oct-27 at 14:58

            MSVC generates 2 byte nop before any single-byte instruction at the beginning of a function (except ret in empty functions). I've tried __halt, _enable, _disable intrinsics and seen the same effect.

            Apparently it is for patching. /hotpatch option gives the same change for x86, and /hotpatch option is not recognized on x64. According to the /hotpatch documentation, it is expected behavior (emphasis mine):

            Because instructions are always two bytes or larger on the ARM architecture, and because x64 compilation is always treated as if /hotpatch has been specified, you don't have to specify /hotpatch when you compile for these targets;

            So hotpatching support is unconditional for x64, and its result is seen in DebugBreak implementation.

            See here: https://godbolt.org/z/1G737cErf

            See this post on why it is needed for hotpatching: Why do Windows functions all begin with a pointless MOV EDI, EDI instruction?. Looks like that currently hotpatching is smart enough to use any two bytes or more instruction, not just MOV EDI, EDI, still it cannot use single-byte instruction, as two-byte backward jump may be written at exact moment when the instruction pointer points at the second instruction.

            Source https://stackoverflow.com/questions/69663300

            QUESTION

            A version of DebugBreak that breaks the debugger without crashing the app
            Asked 2021-Aug-05 at 22:31

            Is there a way to do something like DebugBreak() where when that function is hit the debugger breaks, but continue running when no debugger is attached?

            I have a lua error handler that presents a user-friendly error message when something goes wrong, but if I'm debugging I want to stop execution as soon as I've detected something wrong.

            I don't want to set a breakpoint in the debugger UI. I want a line of code that causes the debugger to break so I can share this breakpoint with co-workers.

            ...

            ANSWER

            Answered 2021-Aug-05 at 22:31

            You can use IsDebuggerPresent to check for an attached debugger, and then conditionally invoke DebugBreak:

            Source https://stackoverflow.com/questions/68673796

            QUESTION

            Setting Breakpoint via bp kernelbase!RegOpenKeyExW Doesn't Work in WinDbg
            Asked 2020-May-01 at 19:25

            Using WinDbg Preview or WinDbg from Windows 10 SDK, when launching 32-bit process on Windows 10 1909 (build 18363.815) setting a breakpoint on kernelbase!RegOpenKeyExW by name doesn't work.

            Example:

            1. Launch C:\windows\syswow64\notepad.exe under WinDbg
            2. .symfix C:\symbols
            3. .reload
            4. bp ntdll!NtOpenKeyEx
            5. g
            6. k
            ...

            ANSWER

            Answered 2020-May-01 at 19:25

            well one is CLRTYPE private symbol I don't know how it crept in but iirc there are few more symbols like this

            use .symopt+4000 to load only public symbols then your breakpoint will be set correctly

            Source https://stackoverflow.com/questions/61493870

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install debugbreak

            You can download it from GitHub.
            You can use debugbreak like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/scottt/debugbreak.git

          • CLI

            gh repo clone scottt/debugbreak

          • sshUrl

            git@github.com:scottt/debugbreak.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Code Inspection Libraries

            Try Top Libraries by scottt

            openssl-android

            by scotttC

            scottt-bin

            by scotttPython

            scottt-gdb

            by scotttPython

            python-vmci

            by scotttC