Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Debug commit for MacOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
Heinrich Kuttler committed Feb 16, 2022
1 parent 6d0a62b commit 986f4be
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ jobs:
submodules: true
- name: Install from repo in test mode
run: "pip install -e '.[dev]'"
- name: Run dyld_info
run: "dyldinfo `python -c 'from nle.nethack import nethack; print(nethack.DLPATH)'` || echo 0"
- name: Run otool
run: "otool -l `python -c 'from nle.nethack import nethack; print(nethack.DLPATH)'` || echo 0"
- name: Run tests
run: "python -m pytest -svx nle/tests --basetemp=nle_test_data"
run: "DYLD_PRINT_SEGMENTS=1 python -m pytest -svx nle/tests --basetemp=nle_test_data"
- name: Compress test output dir
if: ${{ always() }}
run: |
Expand Down
12 changes: 12 additions & 0 deletions include/dloverride.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,24 @@ class DL
continue;

const auto *seg = (macho_segment_command *) cmd;

if (seg->nsects)
segs_.push_back(seg);
cmd = (const load_command *) (((uint8_t *) cmd) + cmd->cmdsize);
}

baseaddr_ = (uint8_t *) hdr_ - segs_[0]->vmaddr;

for (const auto *seg : segs_) {
fprintf(
stderr,
"Found a segment '%s' with %u sections at offset %#010lx. "
"cmdsize: %u. vmaddr: %#010llx. vmsize: 0x%llx. "
"Should be at %p->%p\n",
seg->segname, seg->nsects, (uint8_t *) cmd - (uint8_t *) hdr_,
cmd->cmdsize, seg->vmaddr, seg->vmsize, mem_addr(seg),
mem_addr(seg) + mem_size(seg));
}
#endif /* __linux__, __APPLE__ */
}

Expand Down
7 changes: 7 additions & 0 deletions include/nleinstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ class Instance
: dl_(dlpath.c_str(), "nle_start")
{
dl_.for_rw_regions([&](const auto &reg) {
fprintf(stderr, "memcpy out of [%p, %p)\n", dl_.mem_addr(reg),
dl_.mem_addr(reg) + dl_.mem_size(reg));

regions_.emplace_back(dl_.mem_size(reg));
memcpy(&regions_.back()[0], dl_.mem_addr(reg), dl_.mem_size(reg));
fprintf(stderr, "1 memcpy done\n");
});

start_ = dl_.func<void *, nle_obs *, FILE *, nle_seeds_init_t *,
Expand Down Expand Up @@ -62,6 +66,9 @@ class Instance

auto it = regions_.begin();
dl_.for_rw_regions([&](const auto &reg) {
fprintf(stderr, "memcpy into [%p, %p)\n", dl_.mem_addr(reg),
dl_.mem_addr(reg) + dl_.mem_size(reg));

memcpy(dl_.mem_addr(reg), it->data(), dl_.mem_size(reg));
++it;
});
Expand Down

0 comments on commit 986f4be

Please sign in to comment.