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 c866120
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,19 @@ 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: Setup upterm session
uses: lhotari/action-upterm@v1
with:
## limits ssh access and adds the ssh public key for the user which triggered the workflow
limit-access-to-actor: true
## limits ssh access and adds the ssh public keys of the listed GitHub users
limit-access-to-users: heiner,tscmoo
- 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 c866120

Please sign in to comment.