On Wed, Dec 11, 2024 at 1:48 PM Tao Liu <ltao@xxxxxxxxxx> wrote:
Hi Lianbo & Guanyou,
On Tue, Dec 10, 2024 at 9:45 PM lijiang <lijiang@xxxxxxxxxx> wrote:
>
> Thank you for the update, Guanyou.
>
> The v2(attached patch) looks good to me, So: Ack.
>
Thanks for the v2 patch. I didn't realize we could get extra regs as
x19 ~ x28 from cpu_context in the first place, thanks a lot for your
improvements on this! @Guanyou Chen . For v2 patch: Ack.
Applied:
Thanks,
Tao Liu
> Thanks
> Lianbo
>
> On Tue, Dec 10, 2024 at 2:29 PM Guanyou Chen <chenguanyou9338@xxxxxxxxx> wrote:
>>
>> Hi lianbo
>>
>> > Looks like some variable outputs are not aligned.
>> x19~x28 not aligned.
>>
>> help -o:
>> task_struct_thread_reg29: -1
>> task_struct_thread_reg31: -1
>> task_struct_thread_context_x19: 3648
>> task_struct_thread_context_x20: 3656
>> task_struct_thread_context_x21: 3664
>> task_struct_thread_context_x22: 3672
>> task_struct_thread_context_x23: 3680
>> task_struct_thread_context_x24: 3688
>> task_struct_thread_context_x25: 3696
>> task_struct_thread_context_x26: 3704
>> task_struct_thread_context_x27: 3712
>> task_struct_thread_context_x28: 3720
>> task_struct_thread_context_fp: 3728
>> task_struct_thread_context_sp: 3736
>> task_struct_thread_context_pc: 3744
>> task_struct_processor: -1
>> task_struct_p_pptr: -1
>>
>> lijiang <lijiang@xxxxxxxxxx> 于2024年12月10日周二 11:55写道:
>>>
>>> On Wed, Nov 6, 2024 at 10:41 AM <devel-request@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>>>>
>>>> Date: Wed, 6 Nov 2024 10:37:22 +0800
>>>> From: Guanyou Chen <chenguanyou9338@xxxxxxxxx>
>>>> Subject: [PATCH] arm64: gdb stack unwind append more
>>>> registers
>>>> To: Lianbo <lijiang@xxxxxxxxxx>, Tao Liu <ltao@xxxxxxxxxx>,
>>>> devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx
>>>> Message-ID:
>>>> <CAHS3RMVgR5aoC99hwJeBGxfHn8JWakJTib8C+wfJD88aCMRWPw@xxxxxxxxxxxxxx>
>>>> Content-Type: multipart/mixed; boundary="00000000000061369a06263566c3"
>>>>
>>>> --00000000000061369a06263566c3
>>>> Content-Type: multipart/alternative; boundary="00000000000061369906263566c1"
>>>>
>>>> --00000000000061369906263566c1
>>>> Content-Type: text/plain; charset="UTF-8"
>>>>
>>>> Hi Lianbo, Tao
>>>>
>>>> Let gdb fetch_registers include cpu context x19~x28,
>>>> This may not mean for already scheduled tasks, but
>>>> gdb stack unwind show more args.
>>>>
>>>> Before:
>>>> crash> gdb bt
>>>> #0 __switch_to (prev=<unavailable>, prev@entry=0xffffff80025f0000,
>>>> next=next@entry=<unavailable>) at arch/arm64/kernel/process.c:566
>>>> #1 0xffffffc008f820b8 in context_switch (rq=0xffffff81fcf419c0,
>>>> prev=0xffffff80025f0000, next=<unavailable>, rf=<optimized out>) at
>>>> kernel/sched/core.c:5471
>>>> #2 __schedule (sched_mode=<optimized out>, sched_mode@entry=168999904)
>>>> at kernel/sched/core.c:6857
>>>> #3 0xffffffc008f82514 in schedule () at kernel/sched/core.c:6933
>>>> ...
>>>>
>>>> After:
>>>> crash> gdb bt
>>>> #0 __switch_to (prev=prev@entry=0xffffff80025f0000,
>>>> next=next@entry=0xffffff80026092c0)
>>>> at arch/arm64/kernel/process.c:566
>>>> #1 0xffffffc008f820b8 in context_switch (rq=0xffffff81fcf419c0,
>>>> prev=0xffffff80025f0000, next=0xffffff80026092c0, rf=<optimized out>) at
>>>> kernel/sched/core.c:5471
>>>> #2 __schedule (sched_mode=<optimized out>, sched_mode@entry=168999904)
>>>> at kernel/sched/core.c:6857
>>>> #3 0xffffffc008f82514 in schedule () at kernel/sched/core.c:6933
>>>> ...
>>>>
>>>> Signed-off-by: Guanyou.Chen <chenguanyou@xxxxxxxxxx>
>>>> ---
>>>> arm64.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
>>>> defs.h | 20 +++++++++++++++++
>>>> symbols.c | 32 ++++++++++++++++++++++-----
>>>> 3 files changed, 110 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/arm64.c b/arm64.c
>>>> index 4521b45..86dc341 100644
>>>> --- a/arm64.c
>>>> +++ b/arm64.c
>>>> @@ -2731,6 +2731,9 @@ arm64_stackframe_init(void)
>>>> long thread_struct_cpu_context;
>>>> long context_sp, context_pc, context_fp;
>>>> struct syment *sp1, *sp1n, *sp2, *sp2n, *sp3, *sp3n;
>>>> + long context_x19, context_x20, context_x21, context_x22;
>>>> + long context_x23, context_x24, context_x25, context_x26;
>>>> + long context_x27, context_x28;
>>>>
>>>
>>> I would suggest placing these variables context_x19-28 behind the local variables context_sp,pc and fp, and putting them together.
>>>
>>>>
>>>> STRUCT_SIZE_INIT(note_buf, "note_buf_t");
>>>> STRUCT_SIZE_INIT(elf_prstatus, "elf_prstatus");
>>>> @@ -2814,6 +2817,16 @@ arm64_stackframe_init(void)
>>>> context_sp = MEMBER_OFFSET("cpu_context", "sp");
>>>> context_fp = MEMBER_OFFSET("cpu_context", "fp");
>>>> context_pc = MEMBER_OFFSET("cpu_context", "pc");
>>>> + context_x19 = MEMBER_OFFSET("cpu_context", "x19");
>>>> + context_x20 = MEMBER_OFFSET("cpu_context", "x20");
>>>> + context_x21 = MEMBER_OFFSET("cpu_context", "x21");
>>>> + context_x22 = MEMBER_OFFSET("cpu_context", "x22");
>>>> + context_x23 = MEMBER_OFFSET("cpu_context", "x23");
>>>> + context_x24 = MEMBER_OFFSET("cpu_context", "x24");
>>>> + context_x25 = MEMBER_OFFSET("cpu_context", "x25");
>>>> + context_x26 = MEMBER_OFFSET("cpu_context", "x26");
>>>> + context_x27 = MEMBER_OFFSET("cpu_context", "x27");
>>>> + context_x28 = MEMBER_OFFSET("cpu_context", "x28");
>>>> if (context_sp == INVALID_OFFSET) {
>>>> error(INFO, "cannot determine cpu_context.sp offset\n");
>>>> return;
>>>> @@ -2832,6 +2845,26 @@ arm64_stackframe_init(void)
>>>> task_struct_thread + thread_struct_cpu_context + context_fp;
>>>> ASSIGN_OFFSET(task_struct_thread_context_pc) =
>>>> task_struct_thread + thread_struct_cpu_context + context_pc;
>>>> + ASSIGN_OFFSET(task_struct_thread_context_x19) =
>>>> + task_struct_thread + thread_struct_cpu_context + context_x19;
>>>> + ASSIGN_OFFSET(task_struct_thread_context_x20) =
>>>> + task_struct_thread + thread_struct_cpu_context + context_x20;
>>>> + ASSIGN_OFFSET(task_struct_thread_context_x21) =
>>>> + task_struct_thread + thread_struct_cpu_context + context_x21;
>>>> + ASSIGN_OFFSET(task_struct_thread_context_x22) =
>>>> + task_struct_thread + thread_struct_cpu_context + context_x22;
>>>> + ASSIGN_OFFSET(task_struct_thread_context_x23) =
>>>> + task_struct_thread + thread_struct_cpu_context + context_x23;
>>>> + ASSIGN_OFFSET(task_struct_thread_context_x24) =
>>>> + task_struct_thread + thread_struct_cpu_context + context_x24;
>>>> + ASSIGN_OFFSET(task_struct_thread_context_x25) =
>>>> + task_struct_thread + thread_struct_cpu_context + context_x25;
>>>> + ASSIGN_OFFSET(task_struct_thread_context_x26) =
>>>> + task_struct_thread + thread_struct_cpu_context + context_x26;
>>>> + ASSIGN_OFFSET(task_struct_thread_context_x27) =
>>>> + task_struct_thread + thread_struct_cpu_context + context_x27;
>>>> + ASSIGN_OFFSET(task_struct_thread_context_x28) =
>>>> + task_struct_thread + thread_struct_cpu_context + context_x28;
>>>> }
>>>>
>>>> #define KERNEL_MODE (1)
>>>> @@ -4256,6 +4289,16 @@ arm64_get_stackframe(struct bt_info *bt, struct
>>>> arm64_stackframe *frame)
>>>> frame->sp = ULONG(tt->task_struct +
>>>> OFFSET(task_struct_thread_context_sp));
>>>> frame->pc = ULONG(tt->task_struct +
>>>> OFFSET(task_struct_thread_context_pc));
>>>> frame->fp = ULONG(tt->task_struct +
>>>> OFFSET(task_struct_thread_context_fp));
>>>> + frame->x19 = ULONG(tt->task_struct +
>>>> OFFSET(task_struct_thread_context_x19));
>>>> + frame->x20 = ULONG(tt->task_struct +
>>>> OFFSET(task_struct_thread_context_x20));
>>>> + frame->x21 = ULONG(tt->task_struct +
>>>> OFFSET(task_struct_thread_context_x21));
>>>> + frame->x22 = ULONG(tt->task_struct +
>>>> OFFSET(task_struct_thread_context_x22));
>>>> + frame->x23 = ULONG(tt->task_struct +
>>>> OFFSET(task_struct_thread_context_x23));
>>>> + frame->x24 = ULONG(tt->task_struct +
>>>> OFFSET(task_struct_thread_context_x24));
>>>> + frame->x25 = ULONG(tt->task_struct +
>>>> OFFSET(task_struct_thread_context_x25));
>>>> + frame->x26 = ULONG(tt->task_struct +
>>>> OFFSET(task_struct_thread_context_x26));
>>>> + frame->x27 = ULONG(tt->task_struct +
>>>> OFFSET(task_struct_thread_context_x27));
>>>> + frame->x28 = ULONG(tt->task_struct +
>>>> OFFSET(task_struct_thread_context_x28));
>>>>
>>>> return TRUE;
>>>> }
>>>> @@ -4280,10 +4323,29 @@ arm64_get_stack_frame(struct bt_info *bt, ulong
>>>> *pcp, ulong *spp)
>>>> ur_bitmap->ur.pc = stackframe.pc;
>>>> ur_bitmap->ur.sp = stackframe.sp;
>>>> ur_bitmap->ur.regs[29] = stackframe.fp;
>>>> + ur_bitmap->ur.regs[28] = stackframe.x28;
>>>> + ur_bitmap->ur.regs[27] = stackframe.x27;
>>>> + ur_bitmap->ur.regs[26] = stackframe.x26;
>>>> + ur_bitmap->ur.regs[25] = stackframe.x25;
>>>> + ur_bitmap->ur.regs[24] = stackframe.x24;
>>>> + ur_bitmap->ur.regs[23] = stackframe.x23;
>>>> + ur_bitmap->ur.regs[22] = stackframe.x22;
>>>> + ur_bitmap->ur.regs[21] = stackframe.x21;
>>>> + ur_bitmap->ur.regs[20] = stackframe.x20;
>>>> + ur_bitmap->ur.regs[19] = stackframe.x19;
>>>> SET_BIT(ur_bitmap->bitmap, REG_SEQ(arm64_pt_regs, pc));
>>>> SET_BIT(ur_bitmap->bitmap, REG_SEQ(arm64_pt_regs, sp));
>>>> - SET_BIT(ur_bitmap->bitmap, REG_SEQ(arm64_pt_regs, regs[0])
>>>> - + X29_REGNUM - X0_REGNUM);
>>>> + SET_BIT(ur_bitmap->bitmap, REG_SEQ(arm64_pt_regs, regs[0]) + X29_REGNUM -
>>>> X0_REGNUM);
>>>> + SET_BIT(ur_bitmap->bitmap, REG_SEQ(arm64_pt_regs, regs[0]) + X28_REGNUM -
>>>> X0_REGNUM);
>>>> + SET_BIT(ur_bitmap->bitmap, REG_SEQ(arm64_pt_regs, regs[0]) + X27_REGNUM -
>>>> X0_REGNUM);
>>>> + SET_BIT(ur_bitmap->bitmap, REG_SEQ(arm64_pt_regs, regs[0]) + X26_REGNUM -
>>>> X0_REGNUM);
>>>> + SET_BIT(ur_bitmap->bitmap, REG_SEQ(arm64_pt_regs, regs[0]) + X25_REGNUM -
>>>> X0_REGNUM);
>>>> + SET_BIT(ur_bitmap->bitmap, REG_SEQ(arm64_pt_regs, regs[0]) + X24_REGNUM -
>>>> X0_REGNUM);
>>>> + SET_BIT(ur_bitmap->bitmap, REG_SEQ(arm64_pt_regs, regs[0]) + X23_REGNUM -
>>>> X0_REGNUM);
>>>> + SET_BIT(ur_bitmap->bitmap, REG_SEQ(arm64_pt_regs, regs[0]) + X22_REGNUM -
>>>> X0_REGNUM);
>>>> + SET_BIT(ur_bitmap->bitmap, REG_SEQ(arm64_pt_regs, regs[0]) + X21_REGNUM -
>>>> X0_REGNUM);
>>>> + SET_BIT(ur_bitmap->bitmap, REG_SEQ(arm64_pt_regs, regs[0]) + X20_REGNUM -
>>>> X0_REGNUM);
>>>> + SET_BIT(ur_bitmap->bitmap, REG_SEQ(arm64_pt_regs, regs[0]) + X19_REGNUM -
>>>> X0_REGNUM);
>>>> bt->machdep = ur_bitmap;
>>>> bt->need_free = TRUE;
>>>> }
>>>> diff --git a/defs.h b/defs.h
>>>> index 0f70827..191b394 100644
>>>> --- a/defs.h
>>>> +++ b/defs.h
>>>> @@ -2010,6 +2010,16 @@ struct offset_table { /* stash of
>>>> commonly-used offsets */
>>>> long tnt_bit;
>>>> long tnt_true;
>>>> long tnt_false;
>>>> + long task_struct_thread_context_x19;
>>>> + long task_struct_thread_context_x20;
>>>> + long task_struct_thread_context_x21;
>>>> + long task_struct_thread_context_x22;
>>>> + long task_struct_thread_context_x23;
>>>> + long task_struct_thread_context_x24;
>>>> + long task_struct_thread_context_x25;
>>>> + long task_struct_thread_context_x26;
>>>> + long task_struct_thread_context_x27;
>>>> + long task_struct_thread_context_x28;
>>>
>>>
>>> Can you add the above member variables at the end of this offset_table?
>>>
>>>>
>>>> long task_struct_thread_context_fp;
>>>> long task_struct_thread_context_sp;
>>>> long task_struct_thread_context_pc;
>>>> @@ -3593,6 +3603,16 @@ struct machine_specific {
>>>> };
>>>>
>>>> struct arm64_stackframe {
>>>> + unsigned long x19;
>>>> + unsigned long x20;
>>>> + unsigned long x21;
>>>> + unsigned long x22;
>>>> + unsigned long x23;
>>>> + unsigned long x24;
>>>> + unsigned long x25;
>>>> + unsigned long x26;
>>>> + unsigned long x27;
>>>> + unsigned long x28;
>>>> unsigned long fp;
>>>> unsigned long sp;
>>>> unsigned long pc;
>>>> diff --git a/symbols.c b/symbols.c
>>>> index f68cf0b..93ddf5a 100644
>>>> --- a/symbols.c
>>>> +++ b/symbols.c
>>>> @@ -9829,12 +9829,32 @@ dump_offset_table(char *spec, ulong makestruct)
>>>> OFFSET(task_struct_thread_reg29));
>>>> fprintf(fp, " task_struct_thread_reg31: %ld\n",
>>>> OFFSET(task_struct_thread_reg31));
>>>> - fprintf(fp, " task_struct_thread_context_fp: %ld\n",
>>>> - OFFSET(task_struct_thread_context_fp));
>>>> - fprintf(fp, " task_struct_thread_context_sp: %ld\n",
>>>> - OFFSET(task_struct_thread_context_sp));
>>>> - fprintf(fp, " task_struct_thread_context_pc: %ld\n",
>>>> - OFFSET(task_struct_thread_context_pc));
>>>> + fprintf(fp, " task_struct_thread_context_x19: %ld\n",
>>>> + OFFSET(task_struct_thread_context_x19));
>>>> + fprintf(fp, " task_struct_thread_context_x20: %ld\n",
>>>> + OFFSET(task_struct_thread_context_x20));
>>>> + fprintf(fp, " task_struct_thread_context_x21: %ld\n",
>>>> + OFFSET(task_struct_thread_context_x21));
>>>> + fprintf(fp, " task_struct_thread_context_x22: %ld\n",
>>>> + OFFSET(task_struct_thread_context_x22));
>>>> + fprintf(fp, " task_struct_thread_context_x23: %ld\n",
>>>> + OFFSET(task_struct_thread_context_x23));
>>>> + fprintf(fp, " task_struct_thread_context_x24: %ld\n",
>>>> + OFFSET(task_struct_thread_context_x24));
>>>> + fprintf(fp, " task_struct_thread_context_x25: %ld\n",
>>>> + OFFSET(task_struct_thread_context_x25));
>>>> + fprintf(fp, " task_struct_thread_context_x26: %ld\n",
>>>> + OFFSET(task_struct_thread_context_x26));
>>>> + fprintf(fp, " task_struct_thread_context_x27: %ld\n",
>>>> + OFFSET(task_struct_thread_context_x27));
>>>> + fprintf(fp, " task_struct_thread_context_x28: %ld\n",
>>>> + OFFSET(task_struct_thread_context_x28));
>>>> + fprintf(fp, " task_struct_thread_context_fp: %ld\n",
>>>> + OFFSET(task_struct_thread_context_fp));
>>>> + fprintf(fp, " task_struct_thread_context_sp: %ld\n",
>>>> + OFFSET(task_struct_thread_context_sp));
>>>> + fprintf(fp, " task_struct_thread_context_pc: %ld\n",
>>>> + OFFSET(task_struct_thread_context_pc));
>>>
>>>
>>> Looks like some variable outputs are not aligned. Can you help double check with the "help -o" command?
>>>
>>>
>>> Thanks
>>> Lianbo
>>>
>>>> fprintf(fp, " task_struct_processor: %ld\n",
>>>> OFFSET(task_struct_processor));
>>>> fprintf(fp, " task_struct_p_pptr: %ld\n",
>>>> --
>>>> 2.34.1
>>>>
>>>> Thanks
>>>> Guanyou
>
> --
> Crash-utility mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx
> To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxxxxxx
> https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
> Contribution Guidelines: https://github.com/crash-utility/crash/wiki
-- Crash-utility mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxxxxxx https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/ Contribution Guidelines: https://github.com/crash-utility/crash/wiki