Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@
import com.google.devtools.build.lib.exec.TreeDeleter;
import com.google.devtools.build.lib.sandbox.SandboxHelpers.SandboxInputs;
import com.google.devtools.build.lib.sandbox.SandboxHelpers.SandboxOutputs;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.util.CommandDescriptionForm;
import com.google.devtools.build.lib.util.CommandFailureUtils;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.Symlinks;
import java.io.IOException;
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
import javax.annotation.Nullable;

Expand All @@ -36,6 +39,8 @@
public class HardlinkedSandboxedSpawn extends AbstractContainerizingSandboxedSpawn {
private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();
private boolean sandboxDebug = false;
@Nullable private final ImmutableList<String> interactiveDebugArguments;


public HardlinkedSandboxedSpawn(
Path sandboxPath,
Expand All @@ -49,6 +54,7 @@ public HardlinkedSandboxedSpawn(
@Nullable Path sandboxDebugPath,
@Nullable Path statisticsPath,
boolean sandboxDebug,
@Nullable ImmutableList<String> interactiveDebugArguments,
String mnemonic) {
super(
sandboxPath,
Expand All @@ -63,6 +69,7 @@ public HardlinkedSandboxedSpawn(
statisticsPath,
mnemonic);
this.sandboxDebug = sandboxDebug;
this.interactiveDebugArguments = interactiveDebugArguments;
}

@Override
Expand Down Expand Up @@ -106,4 +113,24 @@ private void hardLinkRecursive(Path source, Path target) throws IOException {
}
}
}

@Nullable
@Override
public Optional<String> getInteractiveDebugInstructions() {
if (interactiveDebugArguments == null) {
return Optional.empty();
}
return Optional.of(
"Run this command to start an interactive shell in an identical sandboxed environment:\n"
+ CommandFailureUtils.describeCommand(
CommandDescriptionForm.COMPLETE,
/* prettyPrintArgs= */ false,
interactiveDebugArguments,
getEnvironment(),
/* environmentVariablesToClear= */ null,
/* cwd= */ sandboxExecRoot.getPathString(),
/* configurationChecksum= */ null,
/* executionPlatformLabel= */ null,
/* spawnRunner= */ null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ protected SandboxedSpawn prepareSpawn(Spawn spawn, SpawnExecutionContext context
sandboxDebugPath,
statisticsPath,
sandboxOptions.sandboxDebug,
makeInteractiveDebugArguments(commandLineBuilder, sandboxOptions),
spawn.getMnemonic());
} else {
return new SymlinkedSandboxedSpawn(
Expand Down
Loading