[PATCH] C++: dlsym casts in gdb/linux-thread-db.c and gdb/gdbserver/thread-db.c

Doug Evans dje@google.com
Mon Aug 3 18:54:00 GMT 2015


On Mon, Aug 3, 2015 at 11:49 AM, Pedro Alves <palves@redhat.com> wrote:
> Implicit void * -> function pointer conversion doesn't work in C++, so
> in C++, we need to cast the result of dlsym.  This adds a few typedefs
> and macros that make this easy.  GDBserver's version already had the
> CHK macro, so I added it to GDB too.
>
> Tested on x86_64 Fedora 20.
>
> gdb/gdbserver/ChangeLog:
> 2015-08-03  Pedro Alves  <palves@redhat.com>
>
>         * thread-db.c (td_ta_new_ftype, td_ta_map_lwp2thr_ftype)
>         (td_ta_thr_iter_ftype, td_ta_event_addr_ftype)
>         (td_ta_set_event_ftype, td_ta_clear_event_ftype)
>         (td_ta_event_getmsg_ftype, td_thr_validate_ftype)
>         (td_thr_get_info_ftype, td_thr_event_enable_ftype)
>         (td_thr_tls_get_addr_ftype, td_thr_tlsbase_ftype)
>         (td_symbol_list_ftype, td_ta_delete_ftype): New typedefs.
>         (struct thread_db): Use them.
>         (try_thread_db_load_1): Define local TDB_DLSYM macro and use it in
>         CHK calls.
>         (disable_thread_event_reporting): Cast result of dlsym to
>         destination function pointer type.
>         (thread_db_mourn): Use td_ta_delete_ftype.
>
> gdb/ChangeLog:
> 2015-08-03  Pedro Alves  <palves@redhat.com>
>
>         * linux-thread-db.c (td_init_ftype, td_ta_new_ftype)
>         (td_ta_map_lwp2thr_ftype, td_ta_thr_iter_ftype)
>         (td_ta_event_addr_ftype, td_ta_set_event_ftype)
>         (td_ta_clear_event_ftype, td_ta_event_getmsg_ftype)
>         (td_thr_validate_ftype, td_thr_get_info_ftype)
>         (td_thr_event_enable_ftype, td_thr_tls_get_addr_ftype)
>         (td_thr_tlsbase_ftype): New typedefs.
>         (struct thread_db_info): Use them.
>         (try_thread_db_load_1): Define TDB_VERBOSE_DLSYM, TDB_DLSYM , CHK
>         local macros and use them instead of verbose_dlsym and dlsym
>         calls.

Hi.

Nit: Can we put all the typedefs in a common header?



More information about the Gdb-patches mailing list