Summary:
We output the pretty backtrace as JSON, but demangling of symbol names only happens when a symbol is debug printed, which therefore doesn't apply to the JSON.
Instead, demangle pretty backtraces by default so this demangling applies to the output JSON
Reviewed By: jasonwhite
Differential Revision: D41687077
fbshipit-source-id: ee5919597a37664dfb8a66c4fdeda86379d024a9
Summary: This is useful for knowing if we're able to intercept CPUID or not.
Reviewed By: rrnewton
Differential Revision: D41599743
fbshipit-source-id: 56b1ca16f028ad070ecdf4e8489b6e318e386e65
Summary:
Currently the hermit analyze report json has:
1. Header, a string containing some text
2. A formatted stack trace as string for both events
Change this to a structured JSON report, with data only, so non-human consumers can decide how to render it.
Reviewed By: rrnewton
Differential Revision: D41523428
fbshipit-source-id: af689bfb04885775ed7cb60e103a3103da875849
Summary: `sendfile` is available on aarch64, so this was a mistake.
Differential Revision: D41590782
fbshipit-source-id: 6e704bc0c3358c232768a5382c7b5435445c3976
Summary:
Fixes the following errors:
```
---- src/lib.rs - (line 55) stdout ----
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `apt`
--> src/lib.rs:56:6
|
3 | sudo apt install pkg-config libunwind-devel
| ^^^ expected one of 8 possible tokens
error: aborting due to previous error
Couldn't compile the test.
---- src/lib.rs - (line 61) stdout ----
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `test`
--> src/lib.rs:62:7
|
3 | cargo test -- --test-threads=1
| ^^^^ expected one of 8 possible tokens
error: aborting due to previous error
Couldn't compile the test.
---- src/lib.rs - (line 66) stdout ----
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `reverie`
--> src/lib.rs:67:4
|
4 | cd reverie-examples
| ^^^^^^^ expected one of 8 possible tokens
error: aborting due to previous error
```
Reviewed By: rrnewton
Differential Revision: D41588323
fbshipit-source-id: 46d55e81f741ac3b36a25e21291b00849600b7f1
Summary: It doesn't look like the never type is going to be stabilized anytime soon, so lets just use the `never-say-never` crate instead.
Reviewed By: dtolnay
Differential Revision: D41459064
fbshipit-source-id: 6bc82377242b31171251b2393a534f76c7f3d97a
Summary: Missed these in a previous diff.
Reviewed By: rrnewton
Differential Revision: D41567346
fbshipit-source-id: eba0b738a66da1823312803ed91fdc5eeaf90c57
Summary: Our early injected syscalls could get interrupted by a signal (like `SIGWINCH`), so we should always be sure to retry them.
Reviewed By: rrnewton
Differential Revision: D41568242
fbshipit-source-id: e3026bd162619795e776198b7bf05d3e33753c05
Summary: We inject a call to `arch_prctl(ARCH_SET_CPUID, 0)` to enable faulting on CPUID. This isn't supported on virtual machines, so we should gracefully handle any errors.
Reviewed By: rrnewton
Differential Revision: D41567919
fbshipit-source-id: 9623f2852d9b2e8cad0de447214c798c5b9dcb0b
Summary:
On Ubuntu 22.04, this is the disassembly of `gettimeofday` and `clock_gettime`:
```
0000000000000bd0 <__vdso_gettimeofday@LINUX_2.6>:
bd0: e9 4b fe ff ff jmp a20 <LINUX_2.6@LINUX_2.6+0xa20>
bd5: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
bdc: 00 00 00 00
0000000000000c10 <__vdso_clock_gettime@LINUX_2.6>:
c10: e9 9b fb ff ff jmp 7b0 <LINUX_2.6@LINUX_2.6+0x7b0>
c15: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
c1c: 00 00 00 00
```
These implementations just `jmp` to another internal function. The dynamic symbol table reports that these functions are 5 bytes in size, but we can see that they are aligned up to 16 bytes and they are still safe to patch. Thus, our patcher should take this padding and alignment into account.
Fixes https://github.com/facebookexperimental/hermit/issues/16.
Differential Revision: D41565913
fbshipit-source-id: 164aca876abf92642e7ebf4ce96d0860b276647b
Summary: This size optimization relies on a nightly feature that will likely never be stabilized. All it did was make `Option<Fd>` equal to 4 bytes instead of 8 bytes.
Reviewed By: rrnewton
Differential Revision: D41506685
fbshipit-source-id: 15aa75b01200ff7f179373b07e14f542590aa24d
Summary: The `getcpu` VDSO was just returning 0 unconditionally. This was an old hack to determinize the getcpu syscall, but we don't need this anymore because we just intercept it and determinize it instead. Reducing the size of this vdso function will make it more compatible with various VDSO implementations.
Reviewed By: wkhughes
Differential Revision: D41506684
fbshipit-source-id: 3dacad93971ecc7969d725f8b7e984a189a0ebb4
Summary: If the VDSO replacements are too large, they will overwrite too much memory if the real VDSO functions are smaller than the replacement. This fixes https://github.com/facebookexperimental/hermit/issues/16.
Reviewed By: wkhughes
Differential Revision: D41506686
fbshipit-source-id: 7c33e68ae9cccb440b820245e4d37184e156d03b
Summary:
`trace_start_init` relies on the deprecated/removed symbol `initForTraceStart`,
and it's not critical, so this diff removes it.
Reviewed By: jasonwhite
Differential Revision: D41447262
fbshipit-source-id: a291b822d7e6c620f15182374d8923bc18ad2ec8
Summary: `std::io::set_output_capture()` is only available in nightly. In order to publish this crate, we can't use unstable features.
Reviewed By: rrnewton
Differential Revision: D41394375
fbshipit-source-id: d4b6e9310cd6d6925aa9d7b0cd5c4558d6ef7d4c
Summary: Refactors `do_exec` a little bit so that it no longer needs the `never_type` feature. This doesn't affect correctness at all.
Reviewed By: rrnewton
Differential Revision: D41394377
fbshipit-source-id: 30e8793557d12d9aef1c5641eb782b170f86512b
Summary: The usage of `rustc_attrs` is completely optional and only serves as a size optimization for the `Fd` type.
Reviewed By: rrnewton
Differential Revision: D41394376
fbshipit-source-id: 2f4898b872dc32c517df99e0b5f4a82fad5bda77
Summary:
This adds the "nightly" crate feature to `reverie-process` so that it can use nightly features if they are enabled.
This *should* let it still get uploaded to crates.io, but some fancy optional nightly features will be hidden behind this feature flag. Then, we can still use these features internally.
Reviewed By: rrnewton
Differential Revision: D41394572
fbshipit-source-id: 6f5eaccd070f85c839089d3d5e5994471948afd4
Summary: The OSS CI build is currently failing because of this.
Reviewed By: rrnewton
Differential Revision: D41414284
fbshipit-source-id: ba9cb5b46f552e76d7a8ebd5ff94d949105339b6
Summary: Removes the `associated_type_defaults` unstable feature. This brings us one step closer to removing all usage of unstable nightly features, which will allow publishing the crate on https://crates.io.
Reviewed By: rrnewton
Differential Revision: D41389496
fbshipit-source-id: f80d9dd960196ce4fb61c886796836a79e12962b
Summary: Removes usage of the `associated_type_defaults` unstable feature, but does not actually disable the feature yet. This brings us one step closer to removing all usage of unstable nightly features, which will allow publishing a crate on https://crates.io.
Reviewed By: rrnewton
Differential Revision: D41388745
fbshipit-source-id: f347a577857a713fe3088a556cbf37ffe92e5553
Summary: Removes usage of the `bench_black_box` unstable feature. This brings us one step closer to removing all usage of unstable nightly features, which will allow publishing a crate on https://crates.io.
Reviewed By: rrnewton
Differential Revision: D41387686
fbshipit-source-id: 98bfcf053cd320137dbf62f4ef24beb835e1f0df
Summary: Removes usage of the `map_first_last` unstable feature. This brings us one step closer to removing all usage of unstable nightly features, which will allow publishing a crate on https://crates.io.
Reviewed By: rrnewton
Differential Revision: D41387687
fbshipit-source-id: 05184220a6d6cd5ec03339845741b46e9557ca83
Summary: Removes usage of the `async_closure` unstable feature. This brings us one step closer to removing all usage of unstable nightly features, which will allow publishing a crate on https://crates.io.
Reviewed By: rrnewton
Differential Revision: D41387688
fbshipit-source-id: 136c5c8d19876e732d18dca195e87e3bc2ab7661
Summary:
This contains a couple of big fixes for stack traces:
1. Fixes missing symbols for executables.
2. Fixes missing file and line numbers for libraries that use the `gnu_debuglink` feature (where the actual debug information is in a separate file).
Reviewed By: wkhughes
Differential Revision: D41366208
fbshipit-source-id: dd9bb8099ecdab4668846acc67c3b56a04cc96cf
Summary: We want to allow precise timers with an instruction offset. While single stepping we have target and current value of the counter and once we match branches we only increment instructions
Reviewed By: jasonwhite
Differential Revision: D41269879
fbshipit-source-id: 46b3307249663de10607513dc59d8436ca907f78
Summary: These previous launch_* functions can be simplified by using RunOpts to contain all the relevant information about a run, plus everything needed to print a reproducer command.
Reviewed By: VladimirMakaev
Differential Revision: D41329114
fbshipit-source-id: 5bab08dfbf28e1cee7fd244178e03ba2cdc1ba34
Summary: `libunwind` isn't able to resolve symbols from the symbol table. There seems to be a regression preventing this from working. This partially fixes symbol lookup for stack frames by using the `object` crate for looking up symbols in the symbol table. This is a partial fix because symbol lookup does not seem to work yet for executables (only shared libraries).
Reviewed By: VladimirMakaev
Differential Revision: D41290099
fbshipit-source-id: 5d4ad1173f6ab1ca6c2995369c2dedb4a9f30e86
Summary: Adds `ReadFamily` to make it easier to handle all `read` syscall variants.
Reviewed By: igorsugak
Differential Revision: D41239542
fbshipit-source-id: 2c847e421b38281aa5243d8dfc00a8d1de0c075a
Summary: These operations are misleading and should never be called. Since the address could be a remote address, dereferencing it like this is wildly wrong. Not quite sure how they got there in the first place.
Reviewed By: igorsugak
Differential Revision: D41193389
fbshipit-source-id: 143c491df81125b319f7d5d88049021a81981795
Summary:
This adds an ability to decode an instruction on top of the safeptrace::Stopped task and enables debug! tracing when single-stepping.
Note that performance overhead should not be present when higher tracing level is requested
Reviewed By: jasonwhite
Differential Revision: D40895393
fbshipit-source-id: 867f237a0517304314f4ac43313c1f26cee3f646
Summary:
Implementing Displayable can be quite annoying (see D40877692)
This macro provides a boilerplate implementation for a custom struct wrapper for AddrMut<T>
Additional customization can be achieved by implementing Displayable for T
Reviewed By: jasonwhite
Differential Revision: D40946491
fbshipit-source-id: daff74b2c0c23c6d970f920c7d43ab2c381a1dcb
Summary: While investigating a test failure I've narrowed down a divergence to a gettimeofday syscall having different result in trace-replay use case in certain conditions. In this diff I'm enhacing the syscalls DETLOGS with "output buffers" derefed. Currently barelly any of the parameters are supported but hopefully we'll handle Displayable in a more general purpose way in a future
Reviewed By: jasonwhite
Differential Revision: D40877692
fbshipit-source-id: 47c3d310713e400fb2ab18dc736b84999e8c7b99
Summary: this adds more compact and reusable way to display libc::user_regs_struct
Reviewed By: jasonwhite
Differential Revision: D40895319
fbshipit-source-id: fde83d834cc4179bfc6a6aa8d77a4de5f6598e1b
Summary: Now that `Tool` doesn't require `Serialize` and `Deserialize`, we can remove these unnecessary derives. Hopefully this will have a slight improvement to compile-times.
Reviewed By: wkhughes
Differential Revision: D40958697
fbshipit-source-id: 88aa1f4ee2b953ba287d749c88d200c2887ccd46
Summary: Nothing relies on this requirement nor do I think anything ever will rely on this requirement. If I recall correctly, the reason this was originally added is because a hypothetical in-guest Reverie backend might need to copy the process-level state after a fork/clone/execve. However, after getting far enough into the implementation of an in-guest backend, I don't think this is something we'll ever need to do. For fork/clone, the address space is just forked, so we already have the process-level state. If, for some reason, we need to re-copy some process-level state into a new process post-execve, we can just leave that up to the tool to implement (by doing RPC calls).
Reviewed By: wkhughes
Differential Revision: D40958698
fbshipit-source-id: a41244102ca20fdfd28ab34180d098a13273949a