am 643e5722: Merge "Report errors to the log, not just stderr."

* commit '643e5722338d303c0b5aac41107432d8fde4081c':
  Report errors to the log, not just stderr.
This commit is contained in:
Elliott Hughes 2012-07-27 18:28:11 -07:00 committed by Android Git Automerger
commit 7a450b4d9e
7 changed files with 80 additions and 88 deletions

View File

@ -25,17 +25,19 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <grp.h>
#include <stdio.h>
#include <unistd.h>
#include <pwd.h>
#include <netdb.h>
#include <mntent.h>
#include <private/android_filesystem_config.h>
#include <pthread.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h>
#include <grp.h>
#include <mntent.h>
#include <netdb.h>
#include <private/android_filesystem_config.h>
#include <private/logd.h>
#include <pthread.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static int do_getpw_r(int by_name, const char* name, uid_t uid, static int do_getpw_r(int by_name, const char* name, uid_t uid,
struct passwd* dst, char* buf, size_t byte_count, struct passwd** result) struct passwd* dst, char* buf, size_t byte_count, struct passwd** result)
@ -438,65 +440,62 @@ getgrnam(const char *name)
return app_id_to_group( app_id_from_name(name), state ); return app_id_to_group( app_id_from_name(name), state );
} }
static void unimplemented_stub(const char* function) {
const char* fmt = "%s(3) is not implemented on Android\n";
__libc_android_log_print(ANDROID_LOG_WARN, "libc", fmt, function);
fprintf(stderr, fmt, function);
}
struct netent* getnetbyname(const char *name) #define UNIMPLEMENTED unimplemented_stub(__PRETTY_FUNCTION__)
{
fprintf(stderr, "FIX ME! implement getgrnam() %s:%d\n", __FILE__, __LINE__); struct netent* getnetbyname(const char* name) {
UNIMPLEMENTED;
return NULL; return NULL;
} }
void endpwent(void) void endpwent(void) {
{ UNIMPLEMENTED;
} }
struct mntent* getmntent(FILE* f) struct mntent* getmntent(FILE* f) {
{ UNIMPLEMENTED;
fprintf(stderr, "FIX ME! implement getmntent() %s:%d\n", __FILE__, __LINE__);
return NULL; return NULL;
} }
char* ttyname(int fd) char* ttyname(int fd) {
{ UNIMPLEMENTED;
fprintf(stderr, "FIX ME! implement ttyname() %s:%d\n", __FILE__, __LINE__);
return NULL; return NULL;
} }
int ttyname_r(int fd, char *buf, size_t buflen) int ttyname_r(int fd, char* buf, size_t buflen) {
{ UNIMPLEMENTED;
fprintf(stderr, "FIX ME! implement ttyname_r() %s:%d\n", __FILE__, __LINE__);
return -ERANGE; return -ERANGE;
} }
struct netent *getnetbyaddr(uint32_t net, int type) struct netent* getnetbyaddr(uint32_t net, int type) {
{ UNIMPLEMENTED;
fprintf(stderr, "FIX ME! implement %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
return NULL; return NULL;
} }
struct protoent *getprotobyname(const char *name) struct protoent* getprotobyname(const char* name) {
{ UNIMPLEMENTED;
fprintf(stderr, "FIX ME! implement %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
return NULL; return NULL;
} }
struct protoent *getprotobynumber(int proto) struct protoent* getprotobynumber(int proto) {
{ UNIMPLEMENTED;
fprintf(stderr, "FIX ME! implement %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
return NULL; return NULL;
} }
char* getusershell(void) char* getusershell(void) {
{ UNIMPLEMENTED;
fprintf(stderr, "FIX ME! implement %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
return NULL; return NULL;
} }
void setusershell(void) void setusershell(void) {
{ UNIMPLEMENTED;
fprintf(stderr, "FIX ME! implement %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
} }
void endusershell(void) void endusershell(void) {
{ UNIMPLEMENTED;
fprintf(stderr, "FIX ME! implement %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
} }

View File

@ -50,13 +50,13 @@ extern "C" {
#define __ATOMIC_INLINE__ static __inline__ __attribute__((always_inline)) #define __ATOMIC_INLINE__ static __inline__ __attribute__((always_inline))
#ifdef __arm__ #ifdef __arm__
# include <bionic_atomic_arm.h> # include "bionic_atomic_arm.h"
#elif defined(__i386__) #elif defined(__i386__)
# include <bionic_atomic_x86.h> # include "bionic_atomic_x86.h"
#elif defined(__mips__) #elif defined(__mips__)
# include <bionic_atomic_mips.h> # include "bionic_atomic_mips.h"
#else #else
# include <bionic_atomic_gcc_builtin.h> # include "bionic_atomic_gcc_builtin.h"
#endif #endif
#define ANDROID_MEMBAR_FULL __bionic_memory_barrier #define ANDROID_MEMBAR_FULL __bionic_memory_barrier

View File

@ -32,23 +32,23 @@
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <private/logd.h>
void // We log to stderr for the benefit of "adb shell" users, and the log for the benefit
__assert(const char *file, int line, const char *failedexpr) // of regular app developers who want to see their asserts.
{
(void)fprintf(stderr, void __assert(const char* file, int line, const char* failed_expression) {
"assertion \"%s\" failed: file \"%s\", line %d\n", const char* fmt = "%s:%d: assertion \"%s\" failed\n";
failedexpr, file, line); __libc_android_log_print(ANDROID_LOG_FATAL, "libc", fmt, file, line, failed_expression);
fprintf(stderr, fmt, file, line, failed_expression);
abort(); abort();
/* NOTREACHED */ /* NOTREACHED */
} }
void void __assert2(const char* file, int line, const char* function, const char* failed_expression) {
__assert2(const char *file, int line, const char *func, const char *failedexpr) const char* fmt = "%s:%d: %s: assertion \"%s\" failed\n";
{ __libc_android_log_print(ANDROID_LOG_FATAL, "libc", fmt, file, line, function, failed_expression);
(void)fprintf(stderr, fprintf(stderr, fmt, file, line, function, failed_expression);
"assertion \"%s\" failed: file \"%s\", line %d, function \"%s\"\n",
failedexpr, file, line, func);
abort(); abort();
/* NOTREACHED */ /* NOTREACHED */
} }

View File

@ -34,11 +34,6 @@
#include "thread_private.h" #include "thread_private.h"
#include "atexit.h" #include "atexit.h"
/* temporary, for bug hunting */
#include "logd.h"
#define debug_log(format, ...) \
__libc_android_log_print(ANDROID_LOG_DEBUG, "libc-abort", (format), ##__VA_ARGS__ )
#ifdef __arm__ #ifdef __arm__
__LIBC_HIDDEN__ void __LIBC_HIDDEN__ void
__libc_android_abort(void) __libc_android_abort(void)

View File

@ -3,7 +3,7 @@ LOCAL_PATH:= $(call my-dir)
# Common C++ flags to build this library. # Common C++ flags to build this library.
# Note that we need to access private Bionic headers # Note that we need to access private Bionic headers
# and define ANDROID_SMP accordingly. # and define ANDROID_SMP accordingly.
libstdc++_cflags := -Ibionic/libc/private libstdc++_cflags := -Ibionic/libc/
ifeq ($(TARGET_CPU_SMP),true) ifeq ($(TARGET_CPU_SMP),true)
libstdc++_cflags += -DANDROID_SMP=1 libstdc++_cflags += -DANDROID_SMP=1
else else

View File

@ -11,8 +11,8 @@
#include <stddef.h> #include <stddef.h>
#include <sys/atomics.h> #include <sys/atomics.h>
#include <endian.h> #include <endian.h>
#include <bionic_futex.h> #include <private/bionic_futex.h>
#include <bionic_atomic_inline.h> #include <private/bionic_atomic_inline.h>
// ARM C++ ABI and Itanium/x86 C++ ABI has different definition for // ARM C++ ABI and Itanium/x86 C++ ABI has different definition for
// one time construction: // one time construction:

View File

@ -1,10 +1,8 @@
#undef NDEBUG
#include <assert.h>
#include <stdio.h> extern "C" void __cxa_pure_virtual() {
#include <stdlib.h> // We can't call __libc_android_log_write from libstdc++ because it's private, so cheat.
assert(!"Pure virtual function called. Are you calling virtual methods from a destructor?");
extern "C" void __cxa_pure_virtual() /* NOTREACHED */
{
fprintf(stderr, "Pure virtual function called. Are you calling virtual methods from a destructor?\n");
abort();
} }