Improve error handling [ci patch inc]#13
Conversation
|
I'm getting to work. See my steps and track my cost here.
|
There was a problem hiding this comment.
I've reviewed the PR that improves error handling by replacing std::exit and HyperCPU::unreachable with std::abort in debug builds. This is a good change that will make debugging easier while maintaining the original behavior in release builds.
Key Changes
-
Created a new
Exit.hppheader with preprocessor macros:UNREACHABLE()- Usesstd::abort()in debug builds,__builtin_unreachable()in release buildsEXIT(code)- Usesstd::abort()in debug builds,std::exit(code)in release buildsABORT()- Always usesstd::abort()
-
Added
-D__HCPU_DEBUGflag for debug builds to control this behavior -
Modified the
CPUconstructor to take a logger reference instead of creating one internally- This is a good design improvement for flexibility and testability
-
Updated test files to accommodate the new behavior:
- Created
HCPU_ASSERT_EXITmacro to use different assertions based on build type
- Created
-
Reorganized includes in several files for better clarity
Analysis
The changes look well-implemented and consistent throughout the codebase. Using std::abort() in debug builds is a good practice as it preserves the stack and can trigger a debugger, making it easier to diagnose issues.
In release builds, the behavior remains the same, so there shouldn't be any performance impact or behavior change in production.
The PR appears ready to merge and will improve the development experience when debugging.
|
|
||
| - name: Setup git user | ||
| uses: fregante/setup-git-user@v1 | ||
|
|
Check warning
Code scanning / CodeQL
Unpinned tag for a non-immutable Action in workflow Medium
| uses: fregante/setup-git-user@v1 | ||
|
|
||
| - name: Increment version | ||
| run: | |
Check warning
Code scanning / CodeQL
Unpinned tag for a non-immutable Action in workflow Medium
a658778 to
a919eaf
Compare
31905b9 to
66f0326
Compare
…tch inc] (#13) * Working on libunwind * Add libbacktrace dependency, implement basic backtrace controller * Updated submodules * Updated CMake, basic stacktrace printing * Logic implemented, messages fixed * Enable signal handler, make CMake switch * Fix workflow bug
Now std::exit and std::unreachable (HyperCPU::unreachable) are replaced by std::abort in debug build, to simplify debugging.