OSDN Git Service

Remove libthread_db from bionic.
authorElliott Hughes <enh@google.com>
Mon, 27 Jan 2014 23:44:24 +0000 (15:44 -0800)
committerElliott Hughes <enh@google.com>
Mon, 27 Jan 2014 23:45:06 +0000 (15:45 -0800)
The NDK statically links its own copy into gdb.

Bug: 11882807
Change-Id: I0c7ed8761c32df3cc3644258551bc7d2e263f47b

libthread_db/Android.mk [deleted file]
libthread_db/MODULE_LICENSE_BSD [deleted file]
libthread_db/NOTICE [deleted file]
libthread_db/include/sys/procfs.h [deleted file]
libthread_db/include/thread_db.h [deleted file]
libthread_db/libthread_db.c [deleted file]

diff --git a/libthread_db/Android.mk b/libthread_db/Android.mk
deleted file mode 100644 (file)
index 5defe01..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-#
-# static
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
-       libthread_db.c
-
-LOCAL_MODULE:= libthread_db
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-include $(BUILD_STATIC_LIBRARY)
-
-#
-# shared
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_WHOLE_STATIC_LIBRARIES := libthread_db
-LOCAL_MODULE := libthread_db
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_SHARED_LIBRARIES := libdl libc
-LOCAL_ALLOW_UNDEFINED_SYMBOLS := false
-LOCAL_SYSTEM_SHARED_LIBRARIES :=
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/libthread_db/MODULE_LICENSE_BSD b/libthread_db/MODULE_LICENSE_BSD
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/libthread_db/NOTICE b/libthread_db/NOTICE
deleted file mode 100644 (file)
index 5487df6..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-Copyright 2006 The Android Open Source Project
-
--------------------------------------------------------------------
-
diff --git a/libthread_db/include/sys/procfs.h b/libthread_db/include/sys/procfs.h
deleted file mode 100644 (file)
index 0ae7a0b..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2006 The Android Open Source Project
- */
-
-#ifndef _SYS_PROCFS_H
-#define _SYS_PROCFS_H
-
-#include <sys/types.h>
-
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-typedef pid_t lwpid_t;
-typedef void *psaddr_t;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libthread_db/include/thread_db.h b/libthread_db/include/thread_db.h
deleted file mode 100644 (file)
index 1ed8ffc..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2006 The Android Open Source Project
- */
-
-#ifndef _LIBTHREAD_DB__THREAD_DB_H
-#define _LIBTHREAD_DB__THREAD_DB_H
-
-#include <pthread.h>
-#include <signal.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/procfs.h>
-
-#define TD_THR_ANY_USER_FLAGS       0xffffffff
-#define TD_THR_LOWEST_PRIORITY      -20
-#define TD_SIGNO_MASK               NULL
-
-/* td_err_e values */
-enum {
-    TD_OK,
-    TD_ERR,
-    TD_NOTHR,
-    TD_NOSV,
-    TD_NOLWP,
-    TD_BADPH,
-    TD_BADTH,
-    TD_BADSH,
-    TD_BADTA,
-    TD_BADKEY,
-    TD_NOMSG,
-    TD_NOFPREGS,
-    TD_NOLIBTHREAD,
-    TD_NOEVENT,
-    TD_NOCAPAB,
-    TD_DBERR,
-    TD_NOAPLIC,
-    TD_NOTSD,
-    TD_MALLOC,
-    TD_PARTIALREG,
-    TD_NOXREGS,
-    TD_VERSION
-};
-
-/*
- * td_event_e values 
- * NOTE: There is a max of 32 events
- */
-enum {
-    TD_CREATE,
-    TD_DEATH
-};
-
-/* td_thr_state_e values */
-enum {
-    TD_THR_ANY_STATE,
-    TD_THR_UNKNOWN,
-    TD_THR_SLEEP,
-    TD_THR_ZOMBIE
-};
-
-typedef int32_t td_err_e;
-typedef uint32_t td_event_e;
-typedef uint32_t td_notify_e;
-typedef uint32_t td_thr_state_e;
-typedef pthread_t thread_t;
-
-typedef struct
-{
-    pid_t pid;
-    struct ps_prochandle *ph;
-} td_thragent_t;
-
-typedef struct
-{
-    pid_t pid;
-    pid_t tid;
-} td_thrhandle_t;
-
-typedef struct
-{
-    td_event_e event;
-    td_thrhandle_t const * th_p;
-    union {
-        void * data;
-    } msg;
-} td_event_msg_t;
-
-typedef struct
-{
-    uint32_t events;
-} td_thr_events_t;
-
-typedef struct
-{
-    union {
-        void * bptaddr;
-    } u;
-} td_notify_t;
-
-typedef struct
-{
-    td_thr_state_e ti_state;
-    thread_t ti_tid; // pthread's id for the thread
-    int32_t ti_lid; // the kernel's id for the thread
-} td_thrinfo_t;
-
-
-#define td_event_emptyset(set) \
-    (set)->events = 0
-
-#define td_event_fillset(set) \
-    (set)->events = 0xffffffff
-
-#define td_event_addset(set, n) \
-    (set)->events |= (1 << n)
-
-
-typedef int td_thr_iter_f(td_thrhandle_t const *, void *);
-
-
-struct ps_prochandle;
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-extern td_err_e td_ta_new(struct ps_prochandle * proc_handle, td_thragent_t ** thread_agent);
-
-extern td_err_e td_ta_delete(td_thragent_t * ta);
-
-extern td_err_e td_ta_set_event(td_thragent_t const * agent, td_thr_events_t * event);
-
-extern td_err_e td_ta_event_addr(td_thragent_t const * agent, td_event_e event, td_notify_t * notify);
-
-extern td_err_e td_ta_clear_event(const td_thragent_t * ta_arg,
-                                 td_thr_events_t * event);
-
-extern td_err_e td_ta_event_getmsg(td_thragent_t const * agent, td_event_msg_t * event);
-
-extern td_err_e td_ta_map_lwp2thr(td_thragent_t const * agent, lwpid_t lwpid,
-                                 td_thrhandle_t *th);
-
-extern td_err_e td_thr_get_info(td_thrhandle_t const * handle,
-                               td_thrinfo_t * info);
-
-extern td_err_e td_thr_event_enable(td_thrhandle_t const * handle,
-                                   td_event_e event);
-
-extern td_err_e td_ta_thr_iter(td_thragent_t const * agent, td_thr_iter_f * func, void * cookie,
-                               td_thr_state_e state, int32_t prio, sigset_t * sigmask, uint32_t user_flags);
-
-extern td_err_e td_thr_event_enable(td_thrhandle_t const * handle, td_event_e event);
-
-extern td_err_e td_thr_get_info(td_thrhandle_t const * handle, td_thrinfo_t * info);
-
-extern char const ** td_symbol_list(void);
-
-extern td_err_e td_thr_tls_get_addr(const td_thrhandle_t * th,
-                                   psaddr_t map_address, size_t offset,
-                                   psaddr_t * address);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libthread_db/libthread_db.c b/libthread_db/libthread_db.c
deleted file mode 100644 (file)
index d899045..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright 2006 The Android Open Source Project
- */
-
-#include <dirent.h>
-#include <sys/ptrace.h>
-#include <stdint.h>
-#include <thread_db.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-extern int ps_pglobal_lookup (void *, const char *obj, const char *name, void **sym_addr);
-extern pid_t ps_getpid(struct ps_prochandle *ph);
-
-/*
- * This is the list of "special" symbols we care about whose addresses are
- * cached by gdbserver from the host at init time.
- */
-enum {
-    SYM_TD_CREATE,
-    SYM_THREAD_LIST,
-    NUM_SYMS
-};
-
-static char const * gSymbols[] = {
-    [SYM_TD_CREATE] = "_thread_created_hook",
-    NULL
-};
-
-
-char const **
-td_symbol_list(void)
-{
-    return gSymbols;
-}
-
-
-td_err_e
-td_ta_new(struct ps_prochandle * proc_handle, td_thragent_t ** agent_out)
-{
-    td_thragent_t * agent;
-
-    agent = (td_thragent_t *)malloc(sizeof(td_thragent_t));
-    if (!agent) {
-        return TD_MALLOC;
-    }
-
-    agent->pid = ps_getpid(proc_handle);
-    agent->ph = proc_handle;
-    *agent_out = agent;
-
-    return TD_OK;
-}
-
-
-td_err_e
-td_ta_delete(td_thragent_t * ta)
-{
-    free(ta);
-    // FIXME: anything else to do?
-    return TD_OK;
-}
-
-
-/* NOTE: not used by gdb 7.0 */
-
-td_err_e
-td_ta_set_event(td_thragent_t const * agent, td_thr_events_t * events)
-{
-    return TD_OK;
-}
-
-
-/* NOTE: not used by gdb 7.0 */
-static td_thrhandle_t gEventMsgHandle;
-
-/* NOTE: not used by gdb 7.0 */
-
-static int
-_event_getmsg_helper(td_thrhandle_t const * handle, void * bkpt_addr)
-{
-#if defined(__arm__)
-    void* pc = (void *)ptrace(PTRACE_PEEKUSR, handle->tid, (void *)60 /* r15/pc */, NULL);
-    if (pc == bkpt_addr) {
-        // The hook function takes the id of the new thread as it's first param,
-        // so grab it from r0.
-        gEventMsgHandle.pid = ptrace(PTRACE_PEEKUSR, handle->tid, (void *)0 /* r0 */, NULL);
-        gEventMsgHandle.tid = gEventMsgHandle.pid;
-        return 0x42;
-    }
-#elif defined(__i386__)
-    // Get the eip from offset 12*4 = 48 as defined in the struct
-    // user_regs_struct in user_32.h
-    void* pc = (void *)ptrace(PTRACE_PEEKUSR, handle->tid, (void *)48 /* eip */, NULL);
-    // FIXME - pc is a non-decremented breakpoint address, hence the
-    // addition of 1 on test.  This seems to work for the thread hook
-    // function in libc.so but should be properly fixed.
-    if (pc == ((int)bkpt_addr + 1)) {
-        // The hook function takes the id of the new thread as it's first
-        // param, so grab it from ecx at offset 4 in struct user_regs_struct
-        // (using fastcall convention for x86)
-        gEventMsgHandle.pid = ptrace(PTRACE_PEEKUSR, handle->tid, (void *)4 /* ecx */, NULL);
-        gEventMsgHandle.tid = gEventMsgHandle.pid;
-        return 0x42;
-    }
-#elif defined(__mips__)
-    void* pc = (void *)ptrace(PTRACE_PEEKUSR, handle->tid, (void *)(64*4) /* pc */, NULL);
-    if (pc == bkpt_addr) {
-        // The hook function takes the id of the new thread as it's first param,
-        // so grab it from a0
-        gEventMsgHandle.pid = ptrace(PTRACE_PEEKUSR, handle->tid, (void *)(4*4) /* a0 */, NULL);
-        gEventMsgHandle.tid = gEventMsgHandle.pid;
-        return 0x42;
-    }
-#endif
-    return 0;
-}
-
-/* NOTE: not used by gdb 7.0 */
-
-td_err_e
-td_ta_event_getmsg(td_thragent_t const * agent, td_event_msg_t * event)
-{
-    td_err_e err;
-    void * bkpt_addr;
-
-    err = ps_pglobal_lookup(NULL, NULL, gSymbols[SYM_TD_CREATE], &bkpt_addr);
-    if (err) {
-        return err;
-    }
-
-    err = td_ta_thr_iter(agent, _event_getmsg_helper, bkpt_addr, 0, 0, NULL, 0);
-    if (err != 0x42) {
-        return TD_NOMSG;
-    }
-
-    event->event = TD_CREATE;
-    event->th_p = &gEventMsgHandle; // Nasty hack, but it's the only way!
-
-    return TD_OK;
-}
-
-
-td_err_e
-td_ta_map_lwp2thr(td_thragent_t const * agent, lwpid_t lwpid,
-                 td_thrhandle_t *th)
-{
-    th->pid = ps_getpid(agent->ph);
-    th->tid = lwpid;
-    return TD_OK;
-}
-
-
-td_err_e
-td_thr_get_info(td_thrhandle_t const * handle, td_thrinfo_t * info)
-{
-    info->ti_tid = handle->tid;
-    info->ti_lid = handle->tid;
-    info->ti_state = TD_THR_SLEEP; /* XXX this needs to be read from /proc/<pid>/task/<tid>.
-                                      This is only used to see if the thread is a zombie or not */
-    return TD_OK;
-}
-
-
-/* NOTE: not used by gdb 7.0 */
-
-td_err_e
-td_thr_event_enable(td_thrhandle_t const * handle, td_event_e event)
-{
-    // I don't think we need to do anything here...
-    return TD_OK;
-}
-
-
-/* NOTE: not used by gdb 7.0 */
-
-td_err_e
-td_ta_event_addr(td_thragent_t const * agent, td_event_e event, td_notify_t * notify_out)
-{
-    int32_t err;
-
-    /*
-     * This is nasty, ps_pglobal_lookup is implemented in gdbserver and looks up
-     * the symbol from it's cache, which is populated at start time with the
-     * symbols returned from td_symbol_list via calls back to the host.
-     */
-
-    switch (event) {
-        case TD_CREATE:
-            err = ps_pglobal_lookup(NULL, NULL, gSymbols[SYM_TD_CREATE], &notify_out->u.bptaddr);
-            if (err) {
-                return TD_NOEVENT;
-            }
-            return TD_OK;
-    }
-    return TD_NOEVENT;
-}
-
-
-td_err_e
-td_ta_clear_event(const td_thragent_t * ta_arg, td_thr_events_t * event)
-{
-    /* Given that gdb 7.0 doesn't use thread events,
-       there's nothing we need to do here.  */
-    return TD_OK;
-}
-
-
-td_err_e
-td_ta_thr_iter(td_thragent_t const * agent, td_thr_iter_f * func, void * cookie,
-               td_thr_state_e state, int32_t prio, sigset_t * sigmask, uint32_t user_flags)
-{
-    td_err_e err = TD_OK;
-    char path[32];
-    DIR * dir;
-    struct dirent * entry;
-    td_thrhandle_t handle;
-
-    snprintf(path, sizeof(path), "/proc/%d/task/", agent->pid);
-    dir = opendir(path);
-    if (!dir) {
-        return TD_NOEVENT;
-    }
-
-    handle.pid = agent->pid;
-    while ((entry = readdir(dir)) != NULL) {
-        if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
-            continue;
-        }
-        handle.tid = atoi(entry->d_name);
-        if (func(&handle, cookie) != 0) {
-           err = TD_DBERR;
-            break;
-        }
-    }
-
-    closedir(dir);
-
-    return err;
-}
-
-td_err_e
-td_thr_tls_get_addr(const td_thrhandle_t * th,
-                   psaddr_t map_address, size_t offset, psaddr_t * address)
-{
-    return TD_NOAPLIC; // FIXME: TODO
-}