Skip to content

Commit 86e73eb

Browse files
committed
gh-137293 remove exceptions in search_elf_file_for_section
1 parent 17b9d10 commit 86e73eb

1 file changed

Lines changed: 0 additions & 21 deletions

File tree

Python/remote_debug.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -572,35 +572,23 @@ search_elf_file_for_section(
572572

573573
int fd = open(elf_file, O_RDONLY);
574574
if (fd < 0) {
575-
PyErr_Format(PyExc_OSError,
576-
"Cannot open ELF file '%s' for section '%s' search: %s",
577-
elf_file, secname, strerror(errno));
578575
goto exit;
579576
}
580577

581578
struct stat file_stats;
582579
if (fstat(fd, &file_stats) != 0) {
583-
PyErr_Format(PyExc_OSError,
584-
"Cannot get file size for ELF file '%s' during section '%s' search: %s",
585-
elf_file, secname, strerror(errno));
586580
goto exit;
587581
}
588582

589583
file_memory = mmap(NULL, file_stats.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
590584
if (file_memory == MAP_FAILED) {
591-
PyErr_Format(PyExc_OSError,
592-
"Cannot memory map ELF file '%s' (size: %lld bytes) for section '%s' search: %s",
593-
elf_file, (long long)file_stats.st_size, secname, strerror(errno));
594585
goto exit;
595586
}
596587

597588
Elf_Ehdr* elf_header = (Elf_Ehdr*)file_memory;
598589

599590
// Validate ELF header
600591
if (elf_header->e_shstrndx >= elf_header->e_shnum) {
601-
PyErr_Format(PyExc_RuntimeError,
602-
"Invalid ELF file '%s': string table index %u >= section count %u",
603-
elf_file, elf_header->e_shstrndx, elf_header->e_shnum);
604592
goto exit;
605593
}
606594

@@ -635,9 +623,6 @@ search_elf_file_for_section(
635623
}
636624

637625
if (first_load_segment == NULL) {
638-
PyErr_Format(PyExc_RuntimeError,
639-
"No PT_LOAD segment found in ELF file '%s' (%u program headers examined)",
640-
elf_file, elf_header->e_phnum);
641626
goto exit;
642627
}
643628

@@ -650,9 +635,6 @@ search_elf_file_for_section(
650635
munmap(file_memory, file_stats.st_size);
651636
}
652637
if (fd >= 0 && close(fd) != 0) {
653-
PyErr_Format(PyExc_OSError,
654-
"Failed to close ELF file '%s': %s",
655-
elf_file, strerror(errno));
656638
result = 0;
657639
}
658640
return result;
@@ -732,9 +714,6 @@ search_linux_map_for_section(proc_handle_t *handle, const char* secname, const c
732714
if (retval) {
733715
break;
734716
}
735-
if (PyErr_Occurred()){
736-
PyErr_Clear();
737-
}
738717
}
739718
}
740719

0 commit comments

Comments
 (0)