@@ -1166,6 +1166,7 @@ _py_proc__sample_interpreter(py_proc_t * self, PyInterpreterState * is, ctime_t
1166
1166
current_thread = _py_proc__get_current_thread_state_raddr (self );
1167
1167
}
1168
1168
1169
+ int64_t interp_id = V_FIELD_PTR (int64_t , is , py_is , o_id );
1169
1170
do {
1170
1171
if (pargs .memory ) {
1171
1172
mem_delta = 0 ;
@@ -1183,6 +1184,7 @@ _py_proc__sample_interpreter(py_proc_t * self, PyInterpreterState * is, ctime_t
1183
1184
1184
1185
py_thread__emit_collapsed_stack (
1185
1186
& py_thread ,
1187
+ interp_id ,
1186
1188
time_delta ,
1187
1189
mem_delta
1188
1190
);
@@ -1200,45 +1202,54 @@ _py_proc__sample_interpreter(py_proc_t * self, PyInterpreterState * is, ctime_t
1200
1202
// ----------------------------------------------------------------------------
1201
1203
int
1202
1204
py_proc__sample (py_proc_t * self ) {
1203
- ctime_t time_delta = gettime () - self -> timestamp ; // Time delta since last sample.
1205
+ ctime_t time_delta = gettime () - self -> timestamp ; // Time delta since last sample.
1206
+ void * current_interp = self -> is_raddr ;
1204
1207
1205
1208
V_DESC (self -> py_v );
1206
1209
1207
1210
PyInterpreterState is ;
1208
- if (fail (py_proc__get_type (self , self -> is_raddr , is ))) {
1209
- log_ie ("Failed to get interpreter state while sampling" );
1210
- FAIL ;
1211
- }
1212
1211
1213
- void * tstate_head = V_FIELD ( void * , is , py_is , o_tstate_head );
1214
- if (! isvalid ( tstate_head ))
1215
- // Maybe the interpreter state is in an invalid state. We'll try again
1216
- // unless there is a fatal error.
1217
- SUCCESS ;
1212
+ do {
1213
+ if (fail ( py_proc__get_type ( self , current_interp , is ))) {
1214
+ log_ie ( "Failed to get interpreter state while sampling" );
1215
+ FAIL ;
1216
+ }
1218
1217
1219
- #ifdef NATIVE
1220
- raddr_t raddr = { .pref = self -> proc_ref , .addr = tstate_head };
1221
- if (fail (_py_proc__interrupt_threads (self , & raddr ))) {
1222
- log_ie ("Failed to interrupt threads" );
1223
- FAIL ;
1224
- }
1225
- time_delta = gettime () - self -> timestamp ;
1226
- #endif
1218
+ void * tstate_head = V_FIELD (void * , is , py_is , o_tstate_head );
1219
+ if (!isvalid (tstate_head ))
1220
+ // Maybe the interpreter state is in an invalid state. We'll try again
1221
+ // unless there is a fatal error.
1222
+ SUCCESS ;
1227
1223
1228
- int result = _py_proc__sample_interpreter (self , & is , time_delta );
1224
+ #ifdef NATIVE
1225
+ raddr_t raddr = { .pref = self -> proc_ref , .addr = tstate_head };
1226
+ if (fail (_py_proc__interrupt_threads (self , & raddr ))) {
1227
+ log_ie ("Failed to interrupt threads" );
1228
+ FAIL ;
1229
+ }
1230
+ time_delta = gettime () - self -> timestamp ;
1231
+ #endif
1232
+
1233
+ int result = _py_proc__sample_interpreter (self , & is , time_delta );
1229
1234
1235
+ #ifdef NATIVE
1236
+ if (fail (_py_proc__resume_threads (self , & raddr ))) {
1237
+ log_ie ("Failed to resume threads" );
1238
+ FAIL ;
1239
+ }
1240
+ #endif
1241
+
1242
+ if (fail (result ))
1243
+ FAIL ;
1244
+ } while (isvalid (current_interp = V_FIELD (void * , is , py_is , o_next )));
1245
+
1230
1246
#ifdef NATIVE
1231
1247
self -> timestamp = gettime ();
1232
-
1233
- if (fail (_py_proc__resume_threads (self , & raddr ))) {
1234
- log_ie ("Failed to resume threads" );
1235
- FAIL ;
1236
- }
1237
1248
#else
1238
1249
self -> timestamp += time_delta ;
1239
1250
#endif
1240
1251
1241
- return result ;
1252
+ SUCCESS ;
1242
1253
} /* py_proc__sample */
1243
1254
1244
1255
0 commit comments