parent
612d5e6d65
commit
cdaab64be2
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@ -80,9 +80,6 @@ jobs:
|
||||
make -j
|
||||
sudo make install
|
||||
cd ../../cpptrace
|
||||
file /usr/lib/dyld
|
||||
otool -l /usr/lib/dyld
|
||||
uname -a
|
||||
- name: dependencies
|
||||
run: |
|
||||
pip3 install colorama
|
||||
|
||||
@ -110,7 +110,7 @@ def output_matches(raw_output: str, params: Tuple[str]):
|
||||
|
||||
return not errored
|
||||
|
||||
def run_command(*args: List[str], always_output=False):
|
||||
def run_command(*args: List[str]):
|
||||
global failed
|
||||
print(f"{Fore.CYAN}{Style.BRIGHT}Running Command \"{' '.join(args)}\"{Style.RESET_ALL}")
|
||||
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
@ -126,11 +126,6 @@ def run_command(*args: List[str], always_output=False):
|
||||
return False
|
||||
else:
|
||||
print(f"{Fore.GREEN}{Style.BRIGHT}Command succeeded{Style.RESET_ALL}")
|
||||
if always_output:
|
||||
print("stdout:")
|
||||
print(stdout.decode("utf-8"), end="")
|
||||
print("stderr:")
|
||||
print(stderr.decode("utf-8"), end="")
|
||||
return True
|
||||
|
||||
def run_test(test_binary, params: Tuple[str]):
|
||||
@ -260,8 +255,6 @@ def build_full_or_auto(matrix):
|
||||
|
||||
def test(matrix):
|
||||
if platform.system() != "Windows":
|
||||
if platform.system() == "Darwin":
|
||||
run_command("otool", "-l", "./test", always_output=True)
|
||||
return run_test(
|
||||
"./test",
|
||||
(matrix["compiler"], matrix["unwind"], matrix["symbols"], matrix["demangle"])
|
||||
@ -280,8 +273,6 @@ def test(matrix):
|
||||
|
||||
def test_full_or_auto(matrix):
|
||||
if platform.system() != "Windows":
|
||||
if platform.system() == "Darwin":
|
||||
run_command("otool", "-l", "./test", always_output=True)
|
||||
return run_test(
|
||||
"./test",
|
||||
(matrix["compiler"],)
|
||||
|
||||
@ -141,7 +141,6 @@ namespace detail {
|
||||
|
||||
public:
|
||||
mach_o(const std::string& object_path) : object_path(object_path) {
|
||||
fprintf(stderr, "new mach -------------------------------------- %s\n", object_path.c_str());
|
||||
file = std::fopen(object_path.c_str(), "rb");
|
||||
if(file == nullptr) {
|
||||
throw file_error("Unable to read object file " + object_path);
|
||||
@ -167,13 +166,11 @@ namespace detail {
|
||||
}
|
||||
|
||||
std::uintptr_t get_text_vmaddr() {
|
||||
fprintf(stderr, "get_text_vmaddr------------- %s\n", object_path.c_str());
|
||||
for(const auto& command : load_commands) {
|
||||
if(command.cmd == LC_SEGMENT_64 || command.cmd == LC_SEGMENT) {
|
||||
auto segment = command.cmd == LC_SEGMENT_64
|
||||
? load_segment_command<64>(command.file_offset)
|
||||
: load_segment_command<32>(command.file_offset);
|
||||
fprintf(stderr, "foo \"%s\", %d\n", segment.segname, std::strcmp(segment.segname, "__TEXT") == 0);
|
||||
if(std::strcmp(segment.segname, "__TEXT") == 0) {
|
||||
return segment.vmaddr;
|
||||
}
|
||||
@ -181,6 +178,7 @@ namespace detail {
|
||||
}
|
||||
// somehow no __TEXT section was found...
|
||||
throw std::runtime_error("Couldn't find __TEXT section while parsing Mach-O object");
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::size_t get_fat_index() const {
|
||||
@ -411,7 +409,6 @@ namespace detail {
|
||||
flags = header.flags;
|
||||
// handle load commands
|
||||
std::uint32_t ncmds = header.ncmds;
|
||||
fprintf(stderr, "ncmds: %u\n", ncmds);
|
||||
std::uint32_t load_commands_offset = load_base + header_size;
|
||||
// iterate load commands
|
||||
std::uint32_t actual_offset = load_commands_offset;
|
||||
@ -481,7 +478,6 @@ namespace detail {
|
||||
std::uint32_t magic = load_bytes<std::uint32_t>(file, mach_header_offset);
|
||||
load_base = mach_header_offset;
|
||||
fat_index = best - fat_arches.data();
|
||||
fprintf(stderr, "INDEX: %llu\n", to_ull(fat_index));
|
||||
if(is_magic_64(magic)) {
|
||||
load_mach<64>();
|
||||
} else {
|
||||
|
||||
@ -56,9 +56,7 @@ namespace detail {
|
||||
if(it == cache.end()) {
|
||||
// arguably it'd be better to release the lock while computing this, but also arguably it's good to not
|
||||
// have two threads try to do the same computation
|
||||
mach_o obj(object_path);
|
||||
obj.print_segments();
|
||||
auto base = obj.get_text_vmaddr();
|
||||
auto base = mach_o(object_path).get_text_vmaddr();
|
||||
cache.insert(it, {object_path, base});
|
||||
return base;
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user