-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove all panicking code from
gdbstub
!!
this is something I've been meaning to do for a _long_ time now, and after many failed attempts and false-starts, I've finally done it! if you inspect the asm output of `example_no_std`, you'll find that there is absolutely _zero_ panic handling machinery in the final binary! This has also resulted in a _substantial_ drop in binary size, as those bounds checks and panicking machinery were taking up a lot of space! removing panicking code ended up requiring 3 different approaches: 1. Rewriting array-indexing operations to use simpler indexing, which the compiler is able to optimize better. e.g: see the code used to index into the `target.xml` buffer in `base.rs` 2. Adding a sprinkle of unsafe code to certain array-indexing operations that the compiler is unsable to prove are safe. This was only done in two places: `decode_hex_buf` and `PacketBuf`. 3. Manually re-implementing the standard library's `slice::split_mut` and `slice::splitn_mut` methods to elide a bounds check. - Tracked upstream via rust-lang/rust#86313 Introducing unsafe code isn't something I take lightly, and while I've done my best to audit and validate the unsafe code I've written, I did end up including an optional `paranoid_unsafe` feature which gives end-users the option to opt-out of `gdbstub`'s no-panic guarantee in exchange for some additional peace of mind.
- Loading branch information
1 parent
62e7646
commit ecbbaf7
Showing
14 changed files
with
307 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ panic = "abort" | |
opt-level = 's' # Optimize for size. | ||
lto = true | ||
codegen-units = 1 | ||
debug = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.