move some files around
This commit is contained in:
@ -5,7 +5,7 @@ use warnings;
|
||||
use diagnostics;
|
||||
|
||||
use FindBin;
|
||||
use lib $FindBin::Bin;
|
||||
use lib "$FindBin::Bin/Modules";
|
||||
|
||||
use Util;
|
||||
use TUI;
|
||||
|
||||
80
scripts/charts/combined_sankey.r
Normal file
80
scripts/charts/combined_sankey.r
Normal file
@ -0,0 +1,80 @@
|
||||
library(ggplot2)
|
||||
library(ggalluvial)
|
||||
|
||||
# Usage: Rscript combined_comparion.r exp_abspath1 exp_abspath2 ...
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
argc <- length(args)
|
||||
|
||||
if (argc != 2) {
|
||||
print("Expecting two input files")
|
||||
stop()
|
||||
}
|
||||
|
||||
for (experiment in args) {
|
||||
datafile <- paste(experiment, "/faults.csv", sep = "")
|
||||
if (!file.exists(datafile)) {
|
||||
print(paste("Input file", datafile, "is missing"))
|
||||
stop()
|
||||
}
|
||||
}
|
||||
|
||||
resulttype_labels <- c(
|
||||
OK_MARKER = "OK",
|
||||
FAIL_MARKER = "FAIL",
|
||||
DETECTED_MARKER = "DETECTED",
|
||||
TIMEOUT = "TIMEOUT",
|
||||
TRAP = "TRAP",
|
||||
ACCESS_OUTERSPACE = "OUTERSPC",
|
||||
WRITE_TEXTSEGMENT = "WRITETXT"
|
||||
)
|
||||
|
||||
# Read data
|
||||
datafile1 <- paste(args[1], "/faults.csv", sep = "")
|
||||
data1 <- readr::read_csv(datafile1)
|
||||
data1$fault_address <- strtoi(data1$fault_address)
|
||||
data1$resulttype <- resulttype_labels[data1$resulttype]
|
||||
# tibble::glimpse(data1)
|
||||
|
||||
datafile2 <- paste(args[2], "/faults.csv", sep = "")
|
||||
data2 <- readr::read_csv(datafile2)
|
||||
data2$fault_address <- strtoi(data2$fault_address)
|
||||
data2$resulttype <- resulttype_labels[data2$resulttype]
|
||||
# tibble::glimpse(data2)
|
||||
|
||||
# https://corybrunson.github.io/ggalluvial/
|
||||
joined <- merge(
|
||||
data1[, c("fault_address", "resulttype", "faults")],
|
||||
data2[, c("fault_address", "resulttype", "faults")],
|
||||
by = "fault_address",
|
||||
suffixes = c("_bench1", "_bench2")
|
||||
)
|
||||
|
||||
streams <- aggregate(
|
||||
faults_bench2 ~ resulttype_bench1 + resulttype_bench2,
|
||||
data = joined,
|
||||
sum
|
||||
)
|
||||
names(streams) <- c("bench1", "bench2", "faults")
|
||||
|
||||
plot <- ggplot(
|
||||
data = streams,
|
||||
aes(axis1 = bench1, axis2 = bench2, y = faults)
|
||||
) +
|
||||
scale_x_discrete(
|
||||
# TODO: Name the benchmarks
|
||||
# limits = c(args[1], args[2])
|
||||
limits = c("Bench A", "Bench B")
|
||||
) +
|
||||
labs(x = "Benchmark", y = "Faults") +
|
||||
geom_alluvium(aes(fill = bench1)) +
|
||||
geom_stratum() +
|
||||
geom_text(stat = "stratum", aes(label = after_stat(stratum))) +
|
||||
theme_minimal() +
|
||||
theme(legend.position = "none")
|
||||
|
||||
# TODO: Name the file according to the benchmarks
|
||||
ggsave(
|
||||
paste(args[2], "/../sankey.svg", sep = ""),
|
||||
plot = plot,
|
||||
)
|
||||
26
scripts/charts/single_result.r
Normal file
26
scripts/charts/single_result.r
Normal file
@ -0,0 +1,26 @@
|
||||
library(ggplot2)
|
||||
|
||||
# Usage: Rscript single_result.r exp_abspath
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
experiment <- args[1]
|
||||
datafile <- paste(experiment, "/resultsdata.csv", sep = "")
|
||||
|
||||
if (!file.exists(datafile)) {
|
||||
print(paste("Input file", datafile, "is missing"))
|
||||
stop()
|
||||
}
|
||||
|
||||
data <- readr::read_csv(datafile)
|
||||
tibble::glimpse(data)
|
||||
|
||||
plot <- ggplot(data, aes(x = benchmark, y = faults, fill = resulttype)) +
|
||||
geom_col(position = "dodge") +
|
||||
scale_y_log10() +
|
||||
labs(x = "Benchmark", y = "Faults", fill = "Result Type") +
|
||||
theme_minimal()
|
||||
|
||||
ggsave(
|
||||
paste(experiment, "/single_result.svg", sep = ""),
|
||||
plot = plot,
|
||||
)
|
||||
32
scripts/charts/single_scatter.r
Normal file
32
scripts/charts/single_scatter.r
Normal file
@ -0,0 +1,32 @@
|
||||
library(ggplot2)
|
||||
|
||||
# Usage: Rscript single_scatter.r exp_abspath
|
||||
|
||||
# TODO: Allow filtering resulttypes (or at least exclude OK_MARKER)
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
experiment <- args[1]
|
||||
datafile <- paste(experiment, "/faults.csv", sep = "")
|
||||
|
||||
if (!file.exists(datafile)) {
|
||||
print(paste("Input file", datafile, "is missing"))
|
||||
stop()
|
||||
}
|
||||
|
||||
data <- readr::read_csv(datafile)
|
||||
data$fault_address <- strtoi(data$fault_address)
|
||||
tibble::glimpse(data)
|
||||
|
||||
plot <- ggplot(data, aes(x = fault_address, y = faults)) +
|
||||
geom_point(aes(color = resulttype)) +
|
||||
scale_x_continuous(
|
||||
labels = function(x) sprintf("0x%X", as.integer(x))
|
||||
) +
|
||||
scale_y_log10() +
|
||||
labs(x = "Address", y = "Faults", color = "Type") +
|
||||
theme_minimal()
|
||||
|
||||
ggsave(
|
||||
paste(experiment, "/scatter.svg", sep = ""),
|
||||
plot = plot,
|
||||
)
|
||||
@ -7,7 +7,7 @@ use File::Copy qw(copy);
|
||||
use File::Path qw(rmtree make_path);
|
||||
use Cwd qw(abs_path);
|
||||
use FindBin;
|
||||
use lib $FindBin::Bin;
|
||||
use lib "$FindBin::Bin/Modules";
|
||||
use Util;
|
||||
|
||||
# ========================================================================================= #
|
||||
|
||||
@ -5,7 +5,7 @@ use warnings;
|
||||
use diagnostics;
|
||||
|
||||
use FindBin;
|
||||
use lib $FindBin::Bin;
|
||||
use lib "$FindBin::Bin/Modules";
|
||||
|
||||
use Util;
|
||||
use Mars;
|
||||
|
||||
@ -5,7 +5,7 @@ use warnings;
|
||||
use diagnostics;
|
||||
|
||||
use FindBin;
|
||||
use lib $FindBin::Bin;
|
||||
use lib "$FindBin::Bin/Modules";
|
||||
|
||||
use Util;
|
||||
use Mars;
|
||||
|
||||
115
scripts/ghidra/ImportMarkersAsBookmarks.java
Normal file
115
scripts/ghidra/ImportMarkersAsBookmarks.java
Normal file
@ -0,0 +1,115 @@
|
||||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.BookmarkManager;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
|
||||
public class ImportMarkersAsBookmarks extends GhidraScript {
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
// Can't do this in headless mode
|
||||
// File input = askFile("Select CSV file", "Import");
|
||||
|
||||
String[] args = getScriptArgs();
|
||||
if (args.length < 1) {
|
||||
throw new IllegalArgumentException(
|
||||
"Missing CSV file path.\nUsage: ImportMarkersAsBookmarks <markers.csv>");
|
||||
}
|
||||
|
||||
File input = new File(args[0]);
|
||||
if (!input.isFile()) {
|
||||
throw new IllegalArgumentException(
|
||||
"CSV file does not exist or is not a regular file: " + input.getAbsolutePath());
|
||||
}
|
||||
|
||||
println("Importing bookmarks from: " + input.getAbsolutePath());
|
||||
|
||||
// https://ghidra.re/ghidra_docs/api/ghidra/program/model/listing/BookmarkManager.html
|
||||
BookmarkManager bm = currentProgram.getBookmarkManager();
|
||||
|
||||
int imported = 0;
|
||||
int skipped = 0;
|
||||
int lineNo = 0;
|
||||
|
||||
// CSV columns: (benchmark, resulttype, faults, fault_address)
|
||||
// Example: (ip , OK_MARKER , 4311 , 0x10001B )
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(input))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
lineNo++;
|
||||
|
||||
line = line.trim();
|
||||
if (line.isEmpty() || line.startsWith("#") || line.startsWith("benchmark")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Make sure to always use "," delimiter and never quotations
|
||||
String[] parts = line.split(",");
|
||||
if (parts.length != 4) {
|
||||
skipped++;
|
||||
printerr("Line " + lineNo + ": malformed");
|
||||
continue;
|
||||
}
|
||||
|
||||
String benchText = parts[0].trim();
|
||||
String typeText = parts[1].trim();
|
||||
String countText = parts[2].trim();
|
||||
String addrText = parts[3].trim();
|
||||
|
||||
if (benchText.isEmpty()
|
||||
|| typeText.isEmpty()
|
||||
|| countText.isEmpty()
|
||||
|| addrText.isEmpty()) {
|
||||
skipped++;
|
||||
printerr("Line " + lineNo + ": malformed");
|
||||
continue;
|
||||
}
|
||||
|
||||
Address addr = parseAddress(addrText);
|
||||
if (addr == null) {
|
||||
skipped++;
|
||||
printerr("Line " + lineNo + ": invalid address: " + addrText);
|
||||
continue;
|
||||
}
|
||||
|
||||
println(
|
||||
"Adding bookmark at "
|
||||
+ addr
|
||||
+ " with type "
|
||||
+ benchText
|
||||
+ " with category "
|
||||
+ benchText // ip, mem or regs
|
||||
+ " - "
|
||||
+ typeText
|
||||
+ " description "
|
||||
+ countText
|
||||
+ "x");
|
||||
|
||||
// TYPE CATEGORY DESCRIPTION
|
||||
bm.setBookmark(addr, benchText, benchText + " - " + typeText, countText + "x");
|
||||
imported++;
|
||||
}
|
||||
}
|
||||
|
||||
println("Imported " + imported + " bookmarks.");
|
||||
if (skipped > 0) {
|
||||
println("Skipped " + skipped + " lines.");
|
||||
}
|
||||
}
|
||||
|
||||
public Address parseAddress(String text) {
|
||||
text = text.trim();
|
||||
|
||||
if (text.startsWith("0x") || text.startsWith("0X")) {
|
||||
text = text.substring(2);
|
||||
}
|
||||
|
||||
try {
|
||||
return toAddr(text);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
36
scripts/ghidra/RemapSourcePaths.java
Normal file
36
scripts/ghidra/RemapSourcePaths.java
Normal file
@ -0,0 +1,36 @@
|
||||
import ghidra.program.database.sourcemap.UserDataPathTransformer;
|
||||
import ghidra.program.model.sourcemap.SourcePathTransformer;
|
||||
|
||||
// Remap:
|
||||
// /build/source/core (libiwasm)
|
||||
// /home/christoph/Notes/TU/MastersThesis/FailNix/build-sum2_repl_cored_late/module_host.c
|
||||
public class RemapSourcePaths extends GhidraScript {
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
String[] args = getScriptArgs();
|
||||
if (args.length < 2) {
|
||||
throw new IllegalArgumentException(
|
||||
"Missing file paths.\nUsage: RemapSourcePaths <libiwasm> <host>");
|
||||
}
|
||||
|
||||
// https://ghidra.re/ghidra_docs/api/ghidra/program/model/sourcemap/SourcePathTransformer.html
|
||||
SourcePathTransformer tx = UserDataPathTransformer.getPathTransformer(currentProgram);
|
||||
|
||||
String oldIwasmDir = "/build/source/core";
|
||||
String newIwasmDir = args[0];
|
||||
|
||||
tx.addDirectoryTransform(oldIwasmDir, newIwasmDir);
|
||||
println("Added transform:");
|
||||
println(" " + oldIwasmDir + " -> " + newIwasmDir);
|
||||
|
||||
// TODO: What to do here? Need to know the build dir name...
|
||||
String failNix = "/home/christoph/Notes/TU/MastersThesis/FailNix";
|
||||
String oldHostDir = failNix + "/build-.../module_host.c";
|
||||
String newHostDir = args[1];
|
||||
|
||||
tx.addDirectoryTransform(oldHostDir, newHostDir);
|
||||
println("Added transform:");
|
||||
println(" " + oldHostDir + " -> " + newHostDir);
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,7 @@ use warnings;
|
||||
use diagnostics;
|
||||
|
||||
use FindBin;
|
||||
use lib $FindBin::Bin;
|
||||
use lib "$FindBin::Bin/Modules";
|
||||
|
||||
use Util;
|
||||
use Mars;
|
||||
@ -25,9 +25,9 @@ my $local_wamr = "$local_root/wamr";
|
||||
my $local_scripts_dir = "$local_root/scripts";
|
||||
my $local_builds_dir = "$local_root/builds";
|
||||
my $local_archive_dir = "$local_root/injections";
|
||||
my $local_charts_dir = "$local_root/charts";
|
||||
my $local_ghidra_projects = "$local_root/ghidra/projects";
|
||||
my $local_ghidra_scripts = "$local_root/ghidra/scripts";
|
||||
my $local_charts_dir = "$local_root/scripts/charts";
|
||||
my $local_ghidra_projects = "$local_root/ghidra";
|
||||
my $local_ghidra_scripts = "$local_root/scripts/ghidra";
|
||||
my $local_db_conf = "$local_root/db.conf";
|
||||
|
||||
my $resultbrowser_port = '5000';
|
||||
|
||||
@ -5,7 +5,7 @@ use warnings;
|
||||
use diagnostics;
|
||||
|
||||
use FindBin;
|
||||
use lib $FindBin::Bin;
|
||||
use lib "$FindBin::Bin/Modules";
|
||||
|
||||
use Util;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ use diagnostics;
|
||||
|
||||
use FindBin;
|
||||
use lib $FindBin::Bin;
|
||||
use lib "$FindBin::Bin/../../scripts";
|
||||
use lib "$FindBin::Bin/../../scripts/Modules";
|
||||
|
||||
use Util;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user