@@ -198,31 +198,52 @@ lldb_private::DynamicLoader *ProcessAIXCore::GetDynamicLoader() {
198
198
void ProcessAIXCore::ParseAIXCoreFile () {
199
199
200
200
Log *log = GetLog (LLDBLog::Process);
201
- AIXSigInfo siginfo;
202
- ThreadData thread_data;
203
201
204
202
const lldb_private::UnixSignals &unix_signals = *GetUnixSignals ();
205
203
const ArchSpec &arch = GetArchitecture ();
206
204
207
- siginfo.Parse (m_aixcore_header, arch, unix_signals);
208
- thread_data.siginfo = siginfo;
205
+ const uint32_t num_threads = m_aixcore_header.NumberOfThreads ;
209
206
SetID (m_aixcore_header.User .process .pi_pid );
207
+ m_thread_data.clear ();
208
+ m_thread_data.reserve (num_threads > 0 ? (num_threads + 1 ) : 1 );
209
+
210
+ for (uint32_t i = 0 ; i <= num_threads; i++) {
210
211
211
- thread_data.name .assign (m_aixcore_header.User .process .pi_comm ,
212
- strnlen (m_aixcore_header.User .process .pi_comm ,
213
- sizeof (m_aixcore_header.User .process .pi_comm )));
214
-
215
- lldb::DataBufferSP data_buffer_sp (new lldb_private::DataBufferHeap (sizeof (m_aixcore_header.Fault .context ), 0 ));
216
-
217
- memcpy (static_cast <void *>(const_cast <uint8_t *>(data_buffer_sp->GetBytes ())),
218
- &m_aixcore_header.Fault .context , sizeof (m_aixcore_header.Fault .context ));
219
-
220
- lldb_private::DataExtractor data (data_buffer_sp, lldb::eByteOrderBig, 8 );
212
+ AIXSigInfo siginfo;
213
+ ThreadData thread_data;
214
+ size_t regs_size;
215
+
216
+ std::string base_name (m_aixcore_header.User .process .pi_comm ,
217
+ strnlen (m_aixcore_header.User .process .pi_comm ,
218
+ sizeof (m_aixcore_header.User .process .pi_comm )));
219
+
220
+ regs_size = (i == 0 ) ? sizeof (m_aixcore_header.Fault .context )
221
+ : sizeof (m_aixcore_header.threads [i-1 ].context );
222
+
223
+ lldb::DataBufferSP regs_buf_sp (new lldb_private::DataBufferHeap (regs_size, 0 ));
224
+ if (i == 0 ) { // The crash thread
225
+ thread_data.tid = m_aixcore_header.Fault .thread .ti_tid ;
226
+ thread_data.name = base_name;
227
+ memcpy (static_cast <void *>(const_cast <uint8_t *>(regs_buf_sp->GetBytes ())),
228
+ &m_aixcore_header.Fault .context , regs_size);
229
+ thread_data.siginfo .Parse (m_aixcore_header, arch, unix_signals);
230
+ }
231
+ else { // Other threads
232
+ thread_data.tid = m_aixcore_header.threads [i-1 ].thread .ti_tid ;
233
+ thread_data.name = base_name + " -*thread-" + std::to_string (i) + " *" ;
234
+
235
+ memcpy (static_cast <void *>(const_cast <uint8_t *>(regs_buf_sp->GetBytes ())),
236
+ &m_aixcore_header.threads [i-1 ].context , regs_size);
237
+ }
238
+ lldb_private::DataExtractor regs_data (regs_buf_sp, lldb::eByteOrderBig, 8 );
239
+ thread_data.gpregset = DataExtractor (regs_data, 0 , regs_size);
221
240
222
- thread_data.gpregset = DataExtractor (data, 0 , sizeof (m_aixcore_header. Fault . context )) ;
223
- m_thread_data. push_back (thread_data);
224
- LLDB_LOGF (log, " ProcessAIXCore: Parsing Complete! " );
241
+ thread_data.prstatus_sig = 0 ;
242
+
243
+ m_thread_data. push_back ( std::move (thread_data) );
225
244
245
+ LLDB_LOGF (log, " ProcessAIXCore: Parsing Complete! tid %d\n " ,i);
246
+ }
226
247
}
227
248
228
249
void ProcessAIXCore::ParseAIXCore32File () {
@@ -233,25 +254,49 @@ void ProcessAIXCore::ParseAIXCore32File() {
233
254
234
255
const lldb_private::UnixSignals &unix_signals = *GetUnixSignals ();
235
256
const ArchSpec &arch = GetArchitecture ();
236
-
237
- siginfo.Parse (m_aixcore32_header, arch, unix_signals);
238
- thread_data.siginfo = siginfo;
239
- SetID (m_aixcore32_header.User .process .pi_pid );
240
-
241
- thread_data.name .assign (m_aixcore32_header.User .process .pi_comm ,
242
- strnlen (m_aixcore32_header.User .process .pi_comm ,
243
- sizeof (m_aixcore32_header.User .process .pi_comm )));
244
-
245
- lldb::DataBufferSP data_buffer_sp (new lldb_private::DataBufferHeap (sizeof (m_aixcore32_header.Fault .context ), 0 ));
246
-
247
- memcpy (static_cast <void *>(const_cast <uint8_t *>(data_buffer_sp->GetBytes ())),
248
- &m_aixcore32_header.Fault .context , sizeof (m_aixcore32_header.Fault .context ));
249
-
250
- lldb_private::DataExtractor data (data_buffer_sp, lldb::eByteOrderBig, 8 );
251
-
252
- thread_data.gpregset = DataExtractor (data, 0 , sizeof (m_aixcore32_header.Fault .context ));
253
- m_thread_data.push_back (thread_data);
254
- LLDB_LOGF (log, " ProcessAIXCore: Parsing Complete!" );
257
+
258
+ const uint32_t num_threads = m_aixcore32_header.NumberOfThreads ;
259
+ SetID (m_aixcore32_header.User .process .pi_pid );
260
+ m_thread_data.clear ();
261
+ m_thread_data.reserve (num_threads > 0 ? (num_threads + 1 ) : 1 );
262
+
263
+ for (uint32_t i = 0 ; i <= num_threads; i++) {
264
+
265
+ AIXSigInfo siginfo;
266
+ ThreadData thread_data;
267
+ size_t regs_size;
268
+
269
+ std::string base_name (m_aixcore32_header.User .process .pi_comm ,
270
+ strnlen (m_aixcore32_header.User .process .pi_comm ,
271
+ sizeof (m_aixcore32_header.User .process .pi_comm )));
272
+
273
+ regs_size = (i == 0 ) ? sizeof (m_aixcore32_header.Fault .context )
274
+ : sizeof (m_aixcore32_header.threads [i-1 ].context );
275
+
276
+ lldb::DataBufferSP regs_buf_sp (new lldb_private::DataBufferHeap (regs_size, 0 ));
277
+ if (i == 0 ) { // The crash thread
278
+ thread_data.tid = m_aixcore32_header.Fault .thread .ti_tid ;
279
+ thread_data.name = base_name;
280
+ memcpy (static_cast <void *>(const_cast <uint8_t *>(regs_buf_sp->GetBytes ())),
281
+ &m_aixcore32_header.Fault .context , regs_size);
282
+ thread_data.siginfo .Parse (m_aixcore32_header, arch, unix_signals);
283
+ }
284
+ else { // Other threads
285
+ thread_data.tid = m_aixcore32_header.threads [i-1 ].thread .ti_tid ;
286
+ thread_data.name = base_name + " -*thread-" + std::to_string (i) + " *" ;
287
+
288
+ memcpy (static_cast <void *>(const_cast <uint8_t *>(regs_buf_sp->GetBytes ())),
289
+ &m_aixcore32_header.threads [i-1 ].context , regs_size);
290
+ }
291
+ lldb_private::DataExtractor regs_data (regs_buf_sp, lldb::eByteOrderBig, 8 );
292
+ thread_data.gpregset = DataExtractor (regs_data, 0 , regs_size);
293
+
294
+ thread_data.prstatus_sig = 0 ;
295
+
296
+ m_thread_data.push_back (std::move (thread_data));
297
+
298
+ LLDB_LOGF (log, " ProcessAIXCore: Parsing Complete! tid %d\n " ,i);
299
+ }
255
300
256
301
}
257
302
// Process Control
@@ -337,12 +382,20 @@ Status ProcessAIXCore::DoLoadCore() {
337
382
bool ProcessAIXCore::DoUpdateThreadList (ThreadList &old_thread_list,
338
383
ThreadList &new_thread_list)
339
384
{
340
- const ThreadData &td = m_thread_data[0 ];
341
-
342
- lldb::ThreadSP thread_sp =
343
- std::make_shared<ThreadAIXCore>(*this , td);
344
- new_thread_list.AddThread (thread_sp);
345
-
385
+ Log *log = GetLog (LLDBLog::Process);
386
+ const uint32_t num_threads = m_is64bit ? m_aixcore_header.NumberOfThreads :
387
+ m_aixcore32_header.NumberOfThreads ;
388
+ LLDB_LOGF (log," Number Of Threads %d\n " , num_threads);
389
+ for (lldb::tid_t tid = 0 ; tid <= num_threads; ++tid) {
390
+ const ThreadData &td = m_thread_data[tid];
391
+ lldb::ThreadSP thread_sp =
392
+ std::make_shared<ThreadAIXCore>(*this , td);
393
+ if (!thread_sp) {
394
+ LLDB_LOGF (log," Thread not added %d\n " , tid);
395
+ continue ;
396
+ }
397
+ new_thread_list.AddThread (thread_sp);
398
+ }
346
399
return true ;
347
400
}
348
401
0 commit comments