]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/jit: add function symbols to global block
authorJan Vrany <jan.vrany@labware.com>
Wed, 14 Jan 2026 14:31:36 +0000 (14:31 +0000)
committerJan Vrany <jan.vrany@labware.com>
Wed, 14 Jan 2026 14:31:36 +0000 (14:31 +0000)
commit452411b260c537d92dfd598b006a50fa4f7f45b5
treeab65dafc6e061e28490377b674238eb137c4fed6
parent18d0fe3ddb9dac96b23b446fbab60f1e6aa39c52
gdb/jit: add function symbols to global block

While playing with JIT reader I realized that it is not possible to set
a breakpoint on jitted function:

    (gdb) b jit_function_stack_mangle
    Function "jit_function_stack_mangle" not defined.
    Make breakpoint pending on future shared library load? (y or [n])

The problem is that symbols for jitted functions (jit_function_stack_mangle
in the above example) are not added to jitted compunit's global block:

    (gdb) maint print symtabs
    ...
    Symtab for file  at 0x55d6f8c186c0
    Read from object file << JIT compiled code at 0x5555555592a0 >> (0x55d6f8cd4090)
    Language: unknown

    Line table:

     line 1 at 0x7ffff7fbc000 (stmt)
     line 0 at 0x7ffff7fbc001 (stmt)

    Blockvector:

    block #000, object at 0x55d6f8c188b0, 0 symbols in 0x7ffff7fbc000..0x7ffff7fbc011
      block #001, object at 0x55d6f8c18910 under 0x55d6f8c188b0, 0 symbols in 0x7ffff7fbc000..0x7ffff7fbc011
        block #002, object at 0x55d6f8c18730 under 0x55d6f8c18910, 0 symbols in 0x7ffff7fbc000..0x7ffff7fbc00a, function jit_function_stack_mangle
        block #003, object at 0x55d6f8c187f0 under 0x55d6f8c18910, 0 symbols in 0x7ffff7fbc00a..0x7ffff7fbc011, function jit_function_add

This commit changes JIT reader to add jitted functions to the global
block:

    ...
    Blockvector:

    block #000, object at 0x55ed6665b180, 2 symbols in 0x7ffff7fbc000..0x7ffff7fbc011
     void jit_function_stack_mangle(); block object 0x55ed6665b000, 0x7ffff7fbc000..0x7ffff7fbc00a
     void jit_function_add(); block object 0x55ed6665b0c0, 0x7ffff7fbc00a..0x7ffff7fbc011
      block #001, object at 0x55ed6665b230 under 0x55ed6665b180, 0 symbols in 0x7ffff7fbc000..0x7ffff7fbc011
        block #002, object at 0x55ed6665b000 under 0x55ed6665b230, 0 symbols in 0x7ffff7fbc000..0x7ffff7fbc00a, function jit_function_stack_mangle
        block #003, object at 0x55ed6665b0c0 under 0x55ed6665b230, 0 symbols in 0x7ffff7fbc00a..0x7ffff7fbc011, function jit_function_add

Approved-By: Tom Tromey <tom@tromey.com>
gdb/jit.c
gdb/testsuite/gdb.base/jit-reader.exp