MCPcopy Create free account
hub / github.com/F-Stack/f-stack / dumpCodeAroundEIP

Function dumpCodeAroundEIP

app/redis-6.2.6/src/debug.c:1773–1801  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1771}
1772
1773void dumpCodeAroundEIP(void *eip) {
1774 Dl_info info;
1775 if (dladdr(eip, &info) != 0) {
1776 serverLog(LL_WARNING|LL_RAW,
1777 "\n------ DUMPING CODE AROUND EIP ------\n"
1778 "Symbol: %s (base: %p)\n"
1779 "Module: %s (base %p)\n"
1780 "$ xxd -r -p /tmp/dump.hex /tmp/dump.bin\n"
1781 "$ objdump --adjust-vma=%p -D -b binary -m i386:x86-64 /tmp/dump.bin\n"
1782 "------\n",
1783 info.dli_sname, info.dli_saddr, info.dli_fname, info.dli_fbase,
1784 info.dli_saddr);
1785 size_t len = (long)eip - (long)info.dli_saddr;
1786 unsigned long sz = sysconf(_SC_PAGESIZE);
1787 if (len < 1<<13) { /* we don't have functions over 8k (verified) */
1788 /* Find the address of the next page, which is our "safety"
1789 * limit when dumping. Then try to dump just 128 bytes more
1790 * than EIP if there is room, or stop sooner. */
1791 void *base = (void *)info.dli_saddr;
1792 unsigned long next = ((unsigned long)eip + sz) & ~(sz-1);
1793 unsigned long end = (unsigned long)eip + 128;
1794 if (end > next) end = next;
1795 len = end - (unsigned long)base;
1796 serverLogHexDump(LL_WARNING, "dump of function",
1797 base, len);
1798 dumpX86Calls(base, len);
1799 }
1800 }
1801}
1802
1803void sigsegvHandler(int sig, siginfo_t *info, void *secret) {
1804 UNUSED(secret);

Callers 1

sigsegvHandlerFunction · 0.85

Calls 2

serverLogHexDumpFunction · 0.85
dumpX86CallsFunction · 0.85

Tested by

no test coverage detected