@@ -133,6 +133,10 @@ return_section_address(
133133
134134 cmd = (struct segment_command_64 * )((void * )cmd + cmd -> cmdsize );
135135 }
136+
137+ // We should not be here, but if we are there, we should say about this
138+ PyErr_SetString (
139+ PyExc_RuntimeError , "Cannot find section address.\n" );
136140 return 0 ;
137141}
138142
@@ -188,6 +192,7 @@ search_section_in_file(
188192
189193 munmap (map , fs .st_size );
190194 if (close (fd ) != 0 ) {
195+ // This might hide one of the above exceptions, maybe we should chain them?
191196 PyErr_SetFromErrno (PyExc_OSError );
192197 }
193198 return result ;
@@ -217,7 +222,9 @@ search_map_for_section(pid_t pid, const char* secname, const char* substr) {
217222
218223 mach_port_t proc_ref = pid_to_task (pid );
219224 if (proc_ref == 0 ) {
220- PyErr_SetString (PyExc_PermissionError , "Cannot get task for PID" );
225+ if (!PyErr_Occurred ()) {
226+ PyErr_SetString (PyExc_PermissionError , "Cannot get task for PID" );
227+ }
221228 return 0 ;
222229 }
223230
@@ -260,6 +267,8 @@ search_map_for_section(pid_t pid, const char* secname, const char* substr) {
260267
261268 address += size ;
262269 }
270+
271+ PyErr_SetString (PyExc_RuntimeError , "mach_vm_region failed" );
263272 return 0 ;
264273}
265274
@@ -306,6 +315,7 @@ find_map_start_address(pid_t pid, char* result_filename, const char* map)
306315
307316 if (!match_found ) {
308317 map_filename [0 ] = '\0' ;
318+ PyErr_SetString (PyExc_RuntimeError , "Cannot find map start address for map: %s" , map );
309319 }
310320
311321 return result_address ;
@@ -401,6 +411,7 @@ search_map_for_section(pid_t pid, const char* secname, const char* map)
401411static uintptr_t
402412search_map_for_section (pid_t pid , const char * secname , const char * map )
403413{
414+ PyErr_SetString (PyExc_NotImplementedError , "Not supported not this platform" );
404415 return 0 ;
405416}
406417#endif
@@ -792,6 +803,9 @@ parse_coro_chain(
792803 pid ,
793804 coro_address + offsets -> gen_object .gi_frame_state ,
794805 & gi_frame_state );
806+ if (err ) {
807+ return -1 ;
808+ }
795809
796810 if (gi_frame_state == FRAME_SUSPENDED_YIELD_FROM ) {
797811 char owner ;
0 commit comments