Skip to content
Open
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
16 changes: 13 additions & 3 deletions modules/utils/rrutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ const path = require("path");
const subprocess = require("child_process");
const { Regexes } = require("../constants");

function isFlatpack() {
return !!process.env.FLATPAK_ID || process.env.container === "flatpack";
}

function escapeFromFlatpack(command) {
return isFlatpack() ? `flatpak-spawn --host ${command}` : command;
}

/**
* @param { string } rr - Path to rr
* @param { string | "" } workspaceDir - Workspace directory containing N traces
* @returns { Promise<string[]> }
*/
async function getTraces(rr, workspaceDir = "") {
return new Promise((resolve, reject) => {
const command = `${rr} ls ${workspaceDir} -t -r`;
const command = escapeFromFlatpack(`${rr} ls ${workspaceDir} -t -r`);
subprocess.exec(command, (err, stdout, stderr) => {
if (err) {
reject(stderr);
Expand Down Expand Up @@ -73,7 +81,8 @@ function fallbackParseOfrrps(data) {
*/
async function getTraceInfo(rr, trace) {
return new Promise((resolve, reject) => {
subprocess.exec(`${rr} ps ${trace}`, (error, stdout, stderr) => {
const command = escapeFromFlatpack(`${rr} ps ${trace}`);
subprocess.exec(command, (error, stdout, stderr) => {
if (error) {
reject(stderr);
} else {
Expand Down Expand Up @@ -149,7 +158,8 @@ const tracePicked = async (rr, traceDirectory) => {
*/
function getGdbInit(rr) {
return new Promise((res, rej) => {
subprocess.exec(`${rr} gdbinit`, (error, stdout) => {
const command = escapeFromFlatpack(`${rr} gdbinit`);
subprocess.exec(command, (error, stdout) => {
if (error) rej(error);
else res(stdout.toString());
});
Expand Down