CTF: handle forward reference type
authorWeimin Pan <weimin.pan@oracle.com>
Sun, 16 May 2021 22:24:14 +0000 (18:24 -0400)
committerWeimin Pan <weimin.pan@oracle.com>
Sun, 16 May 2021 22:24:14 +0000 (18:24 -0400)
commitea11a98dbdb311631a9d214617f2ce054369bc5d
treeff468f9b77f652b79bc6a7f0334f8849747c7e23
parent79633c125eb260a9ac9ed49e314b916f353c4373
CTF: handle forward reference type

The problems can be illustrated, with any program, below:

(gdb) print main
$1 = {main} 0x0

The return type was incorrectly set in read_func_kind_type, with
the name of the function, which leads c_type_print_base_1 to print
it. In addition, the address of a new function needs to be set with
that info in its minimal symtab entry, when the new function is added.

After the fix:

(gdb) print main
$1 = {int ()} 0x4004b7 <main>

A new test, gdb.ctf/funcreturn.exp, is added to the testsuite.

gdb/ChangeLog:
        * ctfread.c (new_symbol): Set function address.
        (read_func_kind_type): Remove incorrect type name setting.
        Don't copy name returned from ctf_type_ame_raw throughout file.

gdb/testsuite/ChangeLog:
        * gdb.ctf/funcreturn.exp: New file.
        * gdb.ctf/whatis.c: Copy from gdb.base.
gdb/ChangeLog
gdb/ctfread.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ctf/funcreturn.exp [new file with mode: 0644]
gdb/testsuite/gdb.ctf/whatis.c [new file with mode: 0644]