From d607495b892fe6ffa1cd30eaad114eec97d77681 Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Fri, 10 Jan 2014 16:05:12 -0800 Subject: [PATCH] Move to C++ for debuggerd. This is part 1, only including the bare minimum changes because our diff tool doesn't easily show differences when a file moves. This also breaks it into a small chunk in case some other changes break things, as unlikely as I think that will be. Change-Id: Ib7a3e7a2cc1ac574d15b65fda23813ebcf5d31af --- debuggerd/Android.mk | 24 +++++++++++++++-------- debuggerd/arm/{machine.c => machine.cpp} | 0 debuggerd/{backtrace.c => backtrace.cpp} | 0 debuggerd/{debuggerd.c => debuggerd.cpp} | 4 ++-- debuggerd/{getevent.c => getevent.cpp} | 6 +++--- debuggerd/mips/{machine.c => machine.cpp} | 0 debuggerd/{tombstone.c => tombstone.cpp} | 0 debuggerd/{utility.c => utility.cpp} | 0 debuggerd/x86/{machine.c => machine.cpp} | 0 9 files changed, 21 insertions(+), 13 deletions(-) rename debuggerd/arm/{machine.c => machine.cpp} (100%) rename debuggerd/{backtrace.c => backtrace.cpp} (100%) rename debuggerd/{debuggerd.c => debuggerd.cpp} (99%) rename debuggerd/{getevent.c => getevent.cpp} (95%) rename debuggerd/mips/{machine.c => machine.cpp} (100%) rename debuggerd/{tombstone.c => tombstone.cpp} (100%) rename debuggerd/{utility.c => utility.cpp} (100%) rename debuggerd/x86/{machine.c => machine.cpp} (100%) diff --git a/debuggerd/Android.mk b/debuggerd/Android.mk index 2fe7c7aa9..422a86aab 100644 --- a/debuggerd/Android.mk +++ b/debuggerd/Android.mk @@ -6,14 +6,20 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ - backtrace.c \ - debuggerd.c \ - getevent.c \ - tombstone.c \ - utility.c \ - $(TARGET_ARCH)/machine.c + backtrace.cpp \ + debuggerd.cpp \ + getevent.cpp \ + tombstone.cpp \ + utility.cpp \ + $(TARGET_ARCH)/machine.cpp \ + +LOCAL_CONLYFLAGS := -std=gnu99 +LOCAL_CPPFLAGS := -std=gnu++11 +LOCAL_CFLAGS := \ + -Wall \ + -Wno-array-bounds \ + -Werror \ -LOCAL_CFLAGS := -Wall -Wno-unused-parameter -std=gnu99 LOCAL_MODULE := debuggerd ifeq ($(ARCH_ARM_HAVE_VFP),true) @@ -30,6 +36,8 @@ LOCAL_SHARED_LIBRARIES := \ liblog \ libselinux \ +include external/stlport/libstlport.mk + include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) @@ -38,7 +46,7 @@ LOCAL_SRC_FILES += $(TARGET_ARCH)/crashglue.S LOCAL_MODULE := crasher LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) LOCAL_MODULE_TAGS := optional -LOCAL_CFLAGS += -fstack-protector-all +LOCAL_CFLAGS += -fstack-protector-all -Wno-unused-parameter -Wno-free-nonheap-object #LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_SHARED_LIBRARIES := libcutils liblog libc include $(BUILD_EXECUTABLE) diff --git a/debuggerd/arm/machine.c b/debuggerd/arm/machine.cpp similarity index 100% rename from debuggerd/arm/machine.c rename to debuggerd/arm/machine.cpp diff --git a/debuggerd/backtrace.c b/debuggerd/backtrace.cpp similarity index 100% rename from debuggerd/backtrace.c rename to debuggerd/backtrace.cpp diff --git a/debuggerd/debuggerd.c b/debuggerd/debuggerd.cpp similarity index 99% rename from debuggerd/debuggerd.c rename to debuggerd/debuggerd.cpp index 4fd031201..a9f59c88c 100644 --- a/debuggerd/debuggerd.c +++ b/debuggerd/debuggerd.cpp @@ -123,7 +123,7 @@ static void wait_for_user_action(pid_t pid) { int _ = -dit; int ___ = 3*_; int _______ = 7*_; - const signed char codes[] = { + const int codes[] = { dit,_,dit,_,dit,___,dah,_,dah,_,dah,___,dit,_,dit,_,dit,_______ }; size_t s = 0; @@ -132,7 +132,7 @@ static void wait_for_user_action(pid_t pid) { init_debug_led(); enable_debug_led(); do { - int timeout = abs((int)(codes[s])) * ms; + int timeout = abs(codes[s]) * ms; int res = get_event(&e, timeout); if (res == 0) { if (e.type == EV_KEY diff --git a/debuggerd/getevent.c b/debuggerd/getevent.cpp similarity index 95% rename from debuggerd/getevent.c rename to debuggerd/getevent.cpp index ebd070c06..8d0b149db 100644 --- a/debuggerd/getevent.c +++ b/debuggerd/getevent.cpp @@ -54,13 +54,13 @@ static int open_device(const char *device) idstr[0] = '\0'; } - new_ufds = realloc(ufds, sizeof(ufds[0]) * (nfds + 1)); + new_ufds = reinterpret_cast(realloc(ufds, sizeof(ufds[0]) * (nfds + 1))); if(new_ufds == NULL) { fprintf(stderr, "out of memory\n"); return -1; } ufds = new_ufds; - new_device_names = realloc(device_names, sizeof(device_names[0]) * (nfds + 1)); + new_device_names = reinterpret_cast(realloc(device_names, sizeof(device_names[0]) * (nfds + 1))); if(new_device_names == NULL) { fprintf(stderr, "out of memory\n"); return -1; @@ -162,7 +162,7 @@ int init_getevent() const char *device_path = "/dev/input"; nfds = 1; - ufds = calloc(1, sizeof(ufds[0])); + ufds = reinterpret_cast(calloc(1, sizeof(ufds[0]))); ufds[0].fd = inotify_init(); ufds[0].events = POLLIN; diff --git a/debuggerd/mips/machine.c b/debuggerd/mips/machine.cpp similarity index 100% rename from debuggerd/mips/machine.c rename to debuggerd/mips/machine.cpp diff --git a/debuggerd/tombstone.c b/debuggerd/tombstone.cpp similarity index 100% rename from debuggerd/tombstone.c rename to debuggerd/tombstone.cpp diff --git a/debuggerd/utility.c b/debuggerd/utility.cpp similarity index 100% rename from debuggerd/utility.c rename to debuggerd/utility.cpp diff --git a/debuggerd/x86/machine.c b/debuggerd/x86/machine.cpp similarity index 100% rename from debuggerd/x86/machine.c rename to debuggerd/x86/machine.cpp