Getting Valgrind to run on macOS 10.15 Catalina, reboot

I posted about this about 5 years ago, and now at last it's close to being finished.

The main problem that I now have is related to matching up DWARF debuginfo and global variables. This works fairly well on macOS 10.14. On 10.15 much less so, and I think that the reason is how the macho data is mmap'd.

When Valgrind runs it does the job of the OS and loads the guest exe into memory. It'll then load and run dyld in Valgrind.

I can get memory map debug traces. In one test with a problem I see 4 load segments. __DATA_CONST and __DATA both have prot 3 (RW) so we load them RW and not R then RW.

Then I think that dyld munmaps and re mmaps the _DATA_CONST segment as RO. Valgrind works based on mmaps triggering reading debuginfo. I don't think that it handles munmap correctly. I need to debug that a lot more - I can see the changed mappings in the debug output but I don't see exactly what is happening with munmap and mmap (unless dyld is doing that on a section by basis).

Does what I'm saying about the mappings make any sense?

Answered by pjfloyd in 869828022

I've mostly fixed the issue.

It is a problem related to _DATA_CONST. Valgrind needs to be updated so that when the __DATA_CONST load command is handled it shouldn't trigger debuginfo reading. That should happen on the next load command (normally __DATA).

Accepted Answer

I've mostly fixed the issue.

It is a problem related to _DATA_CONST. Valgrind needs to be updated so that when the __DATA_CONST load command is handled it shouldn't trigger debuginfo reading. That should happen on the next load command (normally __DATA).

If all goes well I'll push the code for 10.15 tonight and then move on to macOS 11.

Getting Valgrind to run on macOS 10.15 Catalina, reboot
 
 
Q