Skip to content

Commit

Permalink
Revert "更新 svuvm.cpp"
Browse files Browse the repository at this point in the history
This reverts commit 942d5fa.
  • Loading branch information
Dragon-Git committed Jul 1, 2024
1 parent 942d5fa commit ba6161d
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/pysvuvm/svuvm.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include <dlfcn.h>
#include <libgen.h>
#ifdef __APPLE__
#include <mach-o/dyld.h>
#endif
#include <pybind11/pybind11.h>
#include <pybind11/embed.h>
#include "svdpi.h"
Expand Down Expand Up @@ -61,19 +58,10 @@ void py_func(const char* mod_name, const char* func_name, const char* mod_paths)
}
}
#elif defined(__APPLE__)
uint32_t image_count = _dyld_image_count();
Dl_info dl_info;

for(uint32_t i=0; i<image_count; i++) {
const char* image_name = _dyld_get_image_name(i);
const struct mach_header* header = _dyld_get_image_header(i);

if (dladdr(header, &dl_info) && (dl_info.dli_fbase == header)) {
if (((intptr_t)py_func >= (intptr_t)header) && ((intptr_t)header + _dyld_get_image_vmaddr_slide(i)) > (intptr_t)py_func) {
dir_path = dirname(const_cast<char*>(image_name));
path.attr("append")(dir_path);
}
}
if (dladdr((void*)py_func, &dl_info)) {
dir_path = dirname(const_cast<char*>(dl_info.dli_fname));
path.attr("append")(dir_path);
}
#else
#error Platform not supported.
Expand Down

0 comments on commit ba6161d

Please sign in to comment.