@@ -244,35 +244,53 @@ static int compute_signal(int tt)
244244void sleeping_thread_to_gdb_regs (unsigned long * gdb_regs , struct task_struct * p )
245245{
246246 int reg ;
247- struct thread_info * ti = task_thread_info (p );
248- unsigned long ksp = (unsigned long )ti + THREAD_SIZE - 32 ;
249- struct pt_regs * regs = (struct pt_regs * )ksp - 1 ;
250247#if (KGDB_GDB_REG_SIZE == 32 )
251248 u32 * ptr = (u32 * )gdb_regs ;
252249#else
253250 u64 * ptr = (u64 * )gdb_regs ;
254251#endif
255252
256253 for (reg = 0 ; reg < 16 ; reg ++ )
257- * (ptr ++ ) = regs -> regs [ reg ] ;
254+ * (ptr ++ ) = 0 ;
258255
259256 /* S0 - S7 */
260- for (reg = 16 ; reg < 24 ; reg ++ )
261- * (ptr ++ ) = regs -> regs [reg ];
257+ * (ptr ++ ) = p -> thread .reg16 ;
258+ * (ptr ++ ) = p -> thread .reg17 ;
259+ * (ptr ++ ) = p -> thread .reg18 ;
260+ * (ptr ++ ) = p -> thread .reg19 ;
261+ * (ptr ++ ) = p -> thread .reg20 ;
262+ * (ptr ++ ) = p -> thread .reg21 ;
263+ * (ptr ++ ) = p -> thread .reg22 ;
264+ * (ptr ++ ) = p -> thread .reg23 ;
262265
263266 for (reg = 24 ; reg < 28 ; reg ++ )
264267 * (ptr ++ ) = 0 ;
265268
266269 /* GP, SP, FP, RA */
267- for (reg = 28 ; reg < 32 ; reg ++ )
268- * (ptr ++ ) = regs -> regs [reg ];
269-
270- * (ptr ++ ) = regs -> cp0_status ;
271- * (ptr ++ ) = regs -> lo ;
272- * (ptr ++ ) = regs -> hi ;
273- * (ptr ++ ) = regs -> cp0_badvaddr ;
274- * (ptr ++ ) = regs -> cp0_cause ;
275- * (ptr ++ ) = regs -> cp0_epc ;
270+ * (ptr ++ ) = (long )p ;
271+ * (ptr ++ ) = p -> thread .reg29 ;
272+ * (ptr ++ ) = p -> thread .reg30 ;
273+ * (ptr ++ ) = p -> thread .reg31 ;
274+
275+ * (ptr ++ ) = p -> thread .cp0_status ;
276+
277+ /* lo, hi */
278+ * (ptr ++ ) = 0 ;
279+ * (ptr ++ ) = 0 ;
280+
281+ /*
282+ * BadVAddr, Cause
283+ * Ideally these would come from the last exception frame up the stack
284+ * but that requires unwinding, otherwise we can't know much for sure.
285+ */
286+ * (ptr ++ ) = 0 ;
287+ * (ptr ++ ) = 0 ;
288+
289+ /*
290+ * PC
291+ * use return address (RA), i.e. the moment after return from resume()
292+ */
293+ * (ptr ++ ) = p -> thread .reg31 ;
276294}
277295
278296void kgdb_arch_set_pc (struct pt_regs * regs , unsigned long pc )
0 commit comments