MCPcopy Create free account
hub / github.com/bloomberg/pystack / getBytesFromAddress

Method getBytesFromAddress

src/pystack/_pystack/process.cpp:565–600  ·  view source on GitHub ↗

----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

563
564// ----------------------------------------------------------------------------
565std::string
566AbstractProcessManager::getBytesFromAddress(remote_addr_t addr) const
567{
568 ssize_t len;
569 std::vector<char> buffer;
570 remote_addr_t data_addr;
571
572 if (d_major == 2) {
573 LOG(DEBUG) << std::hex << std::showbase << "Handling bytes object of version 2 from address "
574 << addr;
575 Python2::_PyStringObject string;
576 copyObjectFromProcess(addr, &string);
577 len = string.ob_base.ob_size + 1;
578 buffer.resize(len);
579 data_addr = (remote_addr_t)((char*)addr + offsetof(Python2::_PyStringObject, ob_sval));
580 LOG(DEBUG) << std::hex << std::showbase << "Copying data for bytes object from address "
581 << data_addr;
582 copyMemoryFromProcess(data_addr, len, buffer.data());
583 } else {
584 LOG(DEBUG) << std::hex << std::showbase << "Handling bytes object of version 3 from address "
585 << addr;
586 Structure<py_bytes_v> bytes(shared_from_this(), addr);
587 len = bytes.getField(&py_bytes_v::o_ob_size) + 1;
588 if (len < 1) {
589 throw std::runtime_error("Incorrect size of the fetched bytes object");
590 }
591 buffer.resize(len);
592 data_addr = bytes.getFieldRemoteAddress(&py_bytes_v::o_ob_sval);
593
594 LOG(DEBUG) << std::hex << std::showbase << "Copying data for bytes object from address "
595 << data_addr;
596 copyMemoryFromProcess(data_addr, len, buffer.data());
597 }
598
599 return std::string(buffer.begin(), buffer.end() - 1);
600}
601
602remote_addr_t
603AbstractProcessManager::findSymbol(const std::string& symbol) const

Callers 2

toConcreteObjectMethod · 0.80
getLocationInfoFunction · 0.80

Calls 2

LOGClass · 0.85
getFieldRemoteAddressMethod · 0.80

Tested by

no test coverage detected