Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,16 @@ Fill the reusable DXIL cache ahead of a run with the read-only package wrapper.
not prove that the driver immediately reclaimed the allocation or video memory.
- `XCL_THREAD_DUMP_AT=s1,s2,…`: at each of those seconds after the start, the state of every
thread of the title goes into `xcl.log`, for a title that stalls.
- `XCL_THREAD_SAMPLE=<from s>,<period ms>,<count>`: from `<from>` seconds of log time, every
`<period>` ms (`<count>` times), the CPU time each thread used since the last sample and, when
it ran, its instruction pointer and up to 7 callers, without a debugger, ETW or administrator
rights – where the CPU time goes when a title runs slowly. Each thread is stopped only to read
its registers and copy the top of its stack. Written to a binary file
(`XCL_THREAD_SAMPLE_FILE=<path>`, else `xcl-thread-sample.bin` in the temp folder); `xcl.log`
gets a line when it starts and one with its totals (stops, their mean and longest time) at
the end. `python scripts/thread_sample.py <file> [--log xcl.log]` reads it: CPU per thread,
user code against system calls and waits, the top functions (xcl.exe by its PDB, DLLs by
their exports, the title's own images only as offsets).
- `XCL_TRACE_FAULTS=1` (any value): the first 32 access violations are logged as they are raised
(read, write or execute, the address, some registers and the callers on the stack), before the
title's own handlers see them – for a title whose crash filter ends the process without a trace.
Expand Down
2 changes: 1 addition & 1 deletion crates/xcl/src/eh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ extern "system" {
}

/// A thread's description (SetThreadDescription – engines name their threads).
unsafe fn thread_name(h: *mut std::ffi::c_void) -> String {
pub(crate) unsafe fn thread_name(h: *mut std::ffi::c_void) -> String {
let mut p: *mut u16 = std::ptr::null_mut();
if GetThreadDescription(h, &mut p) < 0 || p.is_null() {
return String::new();
Expand Down
2 changes: 2 additions & 0 deletions crates/xcl/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ pub fn host_main(boot_path: &Path) -> i32 {
}
});
}
// `XCL_THREAD_SAMPLE=<from s>,<period ms>,<count>`: every thread's CPU time and stacks, to a file (`thread_sample`)
crate::thread_sample::start_from_env();
crate::stubs::init_db(&boot.config.stub_returns);
crate::hle::init(&boot.config);
crate::hle::kernelx::fine_timer();
Expand Down
1 change: 1 addition & 0 deletions crates/xcl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ mod source_hash;
pub mod stall;
pub mod state;
pub mod stubs;
pub mod thread_sample;
pub mod tls;
pub mod util;
pub mod vfs;
Expand Down
Loading
Loading