Skip to content

Commit

Permalink
mach-engine: Don't allow --pid, format
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonKagstrom committed Aug 18, 2023
1 parent bcc1b5d commit 7ae72b7
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/engines/mach-engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,17 @@ class MachEngine : public IEngine
// From IEngine
virtual int registerBreakpoint(unsigned long addr) override
{
uint32_t data;
uint32_t data = 0;

// There already?
if (m_instructionMap.find(addr) != m_instructionMap.end())
return 0;

data = peekWord(getAligned(addr));
if (IConfiguration::getInstance().keyAsInt("running-mode") !=
IConfiguration::MODE_REPORT_ONLY)
{
data = peekWord(getAligned(addr));
}
m_instructionMap[addr] = data;
m_pendingBreakpoints.insert(addr);

Expand All @@ -216,6 +220,13 @@ class MachEngine : public IEngine
{
m_listener = &listener;

if (IConfiguration::getInstance().keyAsInt("attach-pid") != 0)
{
error("the mach-engine does not support --pid (on OSX)");
exit(1);
}


posix_spawnattr_t attr;

auto rv = posix_spawnattr_init(&attr);
Expand All @@ -234,7 +245,7 @@ class MachEngine : public IEngine
}

// Fork the process, in suspended mode
auto &conf = IConfiguration::getInstance();
auto& conf = IConfiguration::getInstance();
auto argv = conf.getArgv();
rv = posix_spawn(&m_pid, argv[0], nullptr, &attr, (char* const*)argv, environ);
if (rv != 0)
Expand All @@ -251,15 +262,18 @@ class MachEngine : public IEngine
auto kcov_path = get_real_path(conf.keyAsString("kcov-binary-path"));

error("task_for_pid failed with %d\n"
"\n"
"This usually means that the kcov binary needs to be signed with codesign, when\n"
"not running as root. See https://github.com/SimonKagstrom/kcov/blob/master/INSTALL.md\n"
"for instructions on how to do that.\n"
"\n"
"Then run\n"
"\n"
" codesign -s \"Apple Development: [email protected] (XXXXXXXXX)\" --entitlements <kcov-source>/osx-entitlements.xml -f %s"
, kret, kcov_path.c_str());
"\n"
"This usually means that the kcov binary needs to be signed with codesign, when\n"
"not running as root. See "
"https://github.com/SimonKagstrom/kcov/blob/master/INSTALL.md\n"
"for instructions on how to do that.\n"
"\n"
"Then run\n"
"\n"
" codesign -s \"Apple Development: [email protected] (XXXXXXXXX)\" "
"--entitlements <kcov-source>/osx-entitlements.xml -f %s",
kret,
kcov_path.c_str());

exit(1);
return false;
Expand Down

0 comments on commit 7ae72b7

Please sign in to comment.