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

Function parseCoreSiginfo

src/pystack/_pystack/corefile.cpp:239–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239static StatusCode
240parseCoreSiginfo(const NoteData& note_data, CoreCrashInfo* result)
241{
242 if (note_data.data->d_size != sizeof(siginfo_t)) {
243 LOG(ERROR) << "Invalid siginfo note found";
244 return StatusCode::ERROR;
245 }
246
247 const size_t int_size = gelf_fsize(note_data.elf, ELF_T_WORD, 1, EV_CURRENT);
248 assert(int_size > 0);
249
250 const char* ptr = static_cast<const char*>(note_data.data->d_buf);
251 read_obj(&ptr, &result->si_signo, int_size);
252 read_obj(&ptr, &result->si_errno, int_size);
253 read_obj(&ptr, &result->si_code, int_size);
254
255 // We need to account for alignment in 64 bits
256 if (gelf_getclass(note_data.elf) == ELFCLASS64) {
257 ptr += 4;
258 }
259
260 if (result->si_code > 0) {
261 switch (result->si_signo) {
262 case SIGILL:
263 case SIGFPE:
264 case SIGSEGV:
265 case SIGBUS: {
266 const size_t addr_size = gelf_fsize(note_data.elf, ELF_T_ADDR, 1, EV_CURRENT);
267 assert(addr_size > 0);
268 read_obj(&ptr, &result->failed_addr, addr_size);
269 break;
270 }
271 default:
272 break;
273 }
274 } else if (result->si_code == SI_USER) {
275 read_obj(&ptr, &result->sender_pid, int_size);
276 read_obj(&ptr, &result->sender_uid, int_size);
277 }
278 assert(ptr <= reinterpret_cast<char*>(note_data.data->d_buf) + note_data.data->d_size);
279 return StatusCode::SUCCESS;
280}
281
282static StatusCode
283parseCoreFileNote(Elf* core, const NoteData& note_data, std::vector<CoreVirtualMap>& result)

Callers 1

extractFailureInfoMethod · 0.85

Calls 2

LOGClass · 0.85
read_objFunction · 0.85

Tested by

no test coverage detected