logoalt Hacker News

Show HN: Unbug – Rust macros for programmatically invoking breakpoints

86 pointsby BrainBaconyesterday at 1:33 PM37 commentsview on HN

This project is inspired by some of the asserts in Unreal engine.

Due to reliance on core_intrinsics it is necessary to develop using nightly Rust, but there are stubs in place so a production build will not require nightly.

I recently released version 0.2 which includes no_std support and adds optional log message arguments to the ensure macro.


Comments

JoshTriplettyesterday at 2:10 PM

You could potentially build on stable Rust by emitting the breakpoint instructions yourself, at least on popular platforms. For instance, `core::arch::asm!("int3")` on x86, or `core::arch::asm!("brk #1")` on ARM.

Also, this is providing motivation to want to stabilize a breakpoint mechanism, perhaps `core::arch::breakpoint()`. I'm going to propose an API Change Proposal (ACP) to the libs-api team to see if we can provide that in stable Rust.

show 3 replies
merksoftworksyesterday at 5:53 PM

Rusts current pretty printers in lldb and gdb are just not good enough for a fluid step debugging experience. I've had luck with intellij IDE's but it's very sad that the best we can do in a language with such good devex tooling is print debugging.

Theoretically you could generate debug scripts with a macro and embed them with

  #![debugger_visualizer(gdb_script_file = "../foo.py")]
but I haven't seen anyone go through the trouble.
show 1 reply
xobsyesterday at 2:57 PM

I find myself using debug_here (https://github.com/ethanpailes/debug-here) which does similar things but for desktop-class debugging. It hasn't been updated in a while, but it still works for me on Windows at least.

nathanwhyesterday at 10:04 PM

Neat project! Maybe this decision is copied over from unreal engine, but instead of `ensure` and `ensure_always`, having names like `ensure_once` and `ensure` would have been more clear to me.

show 1 reply
thrampyesterday at 2:38 PM

Oh, that’s super clever integration with tracing. Feel free to send us a PR; we’ll link to this as a related project in the docs!

show 2 replies
dborehamyesterday at 5:07 PM

We used to divide by zero but then someone decided that was ok.

ewuhicyesterday at 8:21 PM

Is there a good newby tutorial on how to use debugger with Rust (and debugger in general?) No videos please.

show 1 reply
revskillyesterday at 1:49 PM

What does nightly mean ? I hate that you could not know a specific version of a nightly.

show 3 replies