Skip to content

Improve error handling [ci patch inc]#13

Merged
HyperWinX merged 5 commits intomasterfrom
improve-error-handling
Apr 13, 2025
Merged

Improve error handling [ci patch inc]#13
HyperWinX merged 5 commits intomasterfrom
improve-error-handling

Conversation

@HyperWinX
Copy link
Member

Now std::exit and std::unreachable (HyperCPU::unreachable) are replaced by std::abort in debug build, to simplify debugging.

@mentatbot
Copy link

mentatbot bot commented Apr 12, 2025

I'm getting to work. See my steps and track my cost here.

  • Wake on any new activity.
    I always see new activity while actively working. When paused, I'll only respond when tagged unless this box is checked.

Copy link

@mentatbot mentatbot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Created a new Exit.hpp header with preprocessor macros:

    • UNREACHABLE() - Uses std::abort() in debug builds, __builtin_unreachable() in release builds
    • EXIT(code) - Uses std::abort() in debug builds, std::exit(code) in release builds
    • ABORT() - Always uses std::abort()
  2. Added -D__HCPU_DEBUG flag for debug builds to control this behavior

  3. Modified the CPU constructor to take a logger reference instead of creating one internally

    • This is a good design improvement for flexibility and testability
  4. Updated test files to accommodate the new behavior:

    • Created HCPU_ASSERT_EXIT macro to use different assertions based on build type
  5. 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

Unpinned 3rd party Action 'HyperCPU CI/CD Pipeline (version incrementing)' step
Uses Step
uses 'fregante/setup-git-user' with ref 'v1', not a pinned commit hash
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

Unpinned 3rd party Action 'HyperCPU CI/CD Pipeline (version incrementing)' step
Uses Step
uses 'fregante/setup-git-user' with ref 'v1', not a pinned commit hash
@HyperWinX HyperWinX force-pushed the improve-error-handling branch from a658778 to a919eaf Compare April 12, 2025 13:39
@HyperWinX HyperWinX force-pushed the improve-error-handling branch from 31905b9 to 66f0326 Compare April 12, 2025 14:03
@HyperWinX HyperWinX merged commit bb58db9 into master Apr 13, 2025
12 checks passed
@HyperWinX HyperWinX deleted the improve-error-handling branch April 13, 2025 18:55
HyperWinX added a commit that referenced this pull request Apr 21, 2025
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments