Skip to content

Commit

Permalink
gcore, x86: follow renaming of fs/gs menbers of thread_struct on x86_64
Browse files Browse the repository at this point in the history
The following commit renamed thread_struct's fs/gs members to fsbase
and gsbase:

    $ git log -1 -p 296f781a
    commit 296f781a4b7801ad9c1c0219f9e87b6c25e196fe
    Author: Andy Lutomirski <[email protected]>
    Date:   Tue Apr 26 12:23:29 2016 -0700

    x86/asm/64: Rename thread_struct's fs and gs to fsbase and gsbase

    Unlike ds and es, these are base addresses, not selectors.  Rename
    them so their meaning is more obvious.

    On x86_32, the field is still called fs.  Fixing that could make sense
    as a future cleanup.

This commit follows the renaming.

Without this patch, gcore command on x86_64 fails during
initialization phase as follows:

    crash> gcore -f 127 -v 0 16488

    gcore: invalid structure member offset: thread_struct_fs
           FILE: libgcore/gcore_x86.c  LINE: 1035  FUNCTION: restore_segment_registers()

    [../crash/crash] error trace: 7f290ad1d43c => 7f290ad1bb3e => 52b04a => 52afcc

      52afcc: OFFSET_verify.part.28+92
      52b04a: OFFSET_verify+58

    gcore: invalid structure member offset: thread_struct_fs
           FILE: libgcore/gcore_x86.c  LINE: 1035  FUNCTION: restore_segment_registers()

    Failed.

Signed-off-by: HATAYAMA Daisuke <[email protected]>
  • Loading branch information
HATAYAMA Daisuke authored and d-hatayama committed Jan 22, 2021
1 parent 02fad3e commit 1d63e5f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/gcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,16 @@ static void gcore_offset_table_init(void)
GCORE_MEMBER_OFFSET_INIT(thread_info_vfpstate, "thread_info", "vfpstate");
GCORE_MEMBER_OFFSET_INIT(thread_struct_ds, "thread_struct", "ds");
GCORE_MEMBER_OFFSET_INIT(thread_struct_es, "thread_struct", "es");
GCORE_MEMBER_OFFSET_INIT(thread_struct_fs, "thread_struct", "fs");
if (MEMBER_EXISTS("thread_struct", "fs"))
GCORE_MEMBER_OFFSET_INIT(thread_struct_fs, "thread_struct", "fs");
else
GCORE_MEMBER_OFFSET_INIT(thread_struct_fs, "thread_struct", "fsbase");
GCORE_MEMBER_OFFSET_INIT(thread_struct_fsindex, "thread_struct", "fsindex");
GCORE_MEMBER_OFFSET_INIT(thread_struct_fpu, "thread_struct", "fpu");
GCORE_MEMBER_OFFSET_INIT(thread_struct_gs, "thread_struct", "gs");
if (MEMBER_EXISTS("thread_struct", "gs"))
GCORE_MEMBER_OFFSET_INIT(thread_struct_gs, "thread_struct", "gs");
else
GCORE_MEMBER_OFFSET_INIT(thread_struct_gs, "thread_struct", "gsbase");
GCORE_MEMBER_OFFSET_INIT(thread_struct_gsindex, "thread_struct", "gsindex");
GCORE_MEMBER_OFFSET_INIT(thread_struct_i387, "thread_struct", "i387");
GCORE_MEMBER_OFFSET_INIT(thread_struct_tls_array, "thread_struct", "tls_array");
Expand Down Expand Up @@ -499,9 +505,15 @@ static void gcore_size_table_init(void)
GCORE_MEMBER_SIZE_INIT(mm_struct_saved_auxv, "mm_struct", "saved_auxv");
GCORE_MEMBER_SIZE_INIT(thread_struct_ds, "thread_struct", "ds");
GCORE_MEMBER_SIZE_INIT(thread_struct_es, "thread_struct", "es");
GCORE_MEMBER_SIZE_INIT(thread_struct_fs, "thread_struct", "fs");
if (MEMBER_EXISTS("thread_struct", "fs"))
GCORE_MEMBER_SIZE_INIT(thread_struct_fs, "thread_struct", "fs");
else
GCORE_MEMBER_SIZE_INIT(thread_struct_fs, "thread_struct", "fsbase");
GCORE_MEMBER_SIZE_INIT(thread_struct_fsindex, "thread_struct", "fsindex");
GCORE_MEMBER_SIZE_INIT(thread_struct_gs, "thread_struct", "gs");
if (MEMBER_EXISTS("thread_struct", "gs"))
GCORE_MEMBER_SIZE_INIT(thread_struct_gs, "thread_struct", "gs");
else
GCORE_MEMBER_SIZE_INIT(thread_struct_gs, "thread_struct", "gsbase");
GCORE_MEMBER_SIZE_INIT(thread_struct_gsindex, "thread_struct", "gsindex");
GCORE_MEMBER_SIZE_INIT(thread_struct_tls_array, "thread_struct", "tls_array");
GCORE_STRUCT_SIZE_INIT(thread_xstate, "thread_xstate");
Expand Down

0 comments on commit 1d63e5f

Please sign in to comment.