Skip to content

Commit 9700a37

Browse files
authored
Merge pull request #490 from kaleidawave/add-ignore-exit-code
Add ignore exit code flag
2 parents f308fa0 + 82205de commit 9700a37

File tree

6 files changed

+16
-3
lines changed

6 files changed

+16
-3
lines changed

samply/src/linux/profiler.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub fn start_recording(
7171
command_name,
7272
args,
7373
iteration_count,
74+
ignore_exit_code,
7475
} = process_launch_props;
7576

7677
if profile_creation_props.coreclr.any_enabled() {
@@ -191,7 +192,7 @@ pub fn start_recording(
191192
WaitStatus::Exited(_pid, exit_code) => ExitStatus::from_raw(*exit_code).success(),
192193
_ => false,
193194
};
194-
if !previous_run_exited_with_success {
195+
if !ignore_exit_code && !previous_run_exited_with_success {
195196
eprintln!(
196197
"Skipping remaining iterations due to non-success exit status: {wait_status:?}"
197198
);

samply/src/mac/process_launcher.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub struct TaskLauncher {
2828
args: Vec<OsString>,
2929
child_env: Vec<(OsString, OsString)>,
3030
iteration_count: u32,
31+
ignore_exit_code: bool,
3132
}
3233

3334
impl RootTaskRunner for TaskLauncher {
@@ -41,7 +42,7 @@ impl RootTaskRunner for TaskLauncher {
4142
let mut exit_status = root_child.wait().expect("couldn't wait for child");
4243

4344
for i in 2..=self.iteration_count {
44-
if !exit_status.success() {
45+
if !self.ignore_exit_code && !exit_status.success() {
4546
eprintln!(
4647
"Skipping remaining iterations due to non-success exit status: \"{}\"",
4748
exit_status
@@ -65,6 +66,7 @@ impl TaskLauncher {
6566
program: S,
6667
args: I,
6768
iteration_count: u32,
69+
ignore_exit_code: bool,
6870
env_vars: &[(OsString, OsString)],
6971
extra_env_vars: &[(OsString, OsString)],
7072
) -> Result<TaskLauncher, MachError>
@@ -91,6 +93,7 @@ impl TaskLauncher {
9193
args,
9294
child_env,
9395
iteration_count,
96+
ignore_exit_code,
9497
})
9598
}
9699

samply/src/mac/profiler.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub fn start_recording(
4444
command_name,
4545
args,
4646
iteration_count,
47+
ignore_exit_code,
4748
} = process_launch_props;
4849

4950
let task_launcher = if profile_creation_props.coreclr.any_enabled() {
@@ -62,6 +63,7 @@ pub fn start_recording(
6263
&command_name,
6364
&args,
6465
iteration_count,
66+
ignore_exit_code,
6567
&env_vars,
6668
task_accepter.extra_env_vars(),
6769
)?
@@ -70,6 +72,7 @@ pub fn start_recording(
7072
&command_name,
7173
&args,
7274
iteration_count,
75+
ignore_exit_code,
7376
&env_vars,
7477
task_accepter.extra_env_vars(),
7578
)?

samply/src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ struct RecordArgs {
203203
#[arg(long, default_value = "1")]
204204
iteration_count: u32,
205205

206+
/// Ignore exit code and continue running when iteration_count > 0
207+
#[arg(short, long)]
208+
ignore_exit_code: bool,
209+
206210
#[command(flatten)]
207211
profile_creation_args: ProfileCreationArgs,
208212

@@ -647,6 +651,7 @@ impl RecordArgs {
647651
command_name,
648652
args,
649653
iteration_count,
654+
ignore_exit_code: self.ignore_exit_code,
650655
};
651656

652657
RecordingMode::Launch(launch_props)

samply/src/shared/recording_props.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,5 @@ pub struct ProcessLaunchProps {
118118
pub command_name: OsString,
119119
pub args: Vec<OsString>,
120120
pub iteration_count: u32,
121+
pub ignore_exit_code: bool,
121122
}

samply/src/windows/profiler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub fn start_recording(
109109
// press Ctrl+C again, which would immediately terminate this process and not
110110
// give us a chance to stop xperf.
111111
let exit_status = child.wait().unwrap();
112-
if !exit_status.success() {
112+
if !process_launch_props.ignore_exit_code && !exit_status.success() {
113113
eprintln!(
114114
"Skipping remaining iterations due to non-success exit status: \"{}\"",
115115
exit_status

0 commit comments

Comments
 (0)