Merge "Use -Werror in system/core/libpixelflinger"
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index c3b1bfb..df755aa 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -1354,7 +1354,7 @@
static unsigned fb_get_flash_block_size(Transport* transport, std::string name) {
std::string sizeString;
- if (!fb_getvar(transport, name.c_str(), &sizeString)) {
+ if (!fb_getvar(transport, name.c_str(), &sizeString) || sizeString.empty()) {
/* This device does not report flash block sizes, so return 0 */
return 0;
}
diff --git a/libbacktrace/UnwindStack.cpp b/libbacktrace/UnwindStack.cpp
index d17c211..3a38839 100644
--- a/libbacktrace/UnwindStack.cpp
+++ b/libbacktrace/UnwindStack.cpp
@@ -44,13 +44,13 @@
#include "UnwindStackMap.h"
bool Backtrace::Unwind(unwindstack::Regs* regs, BacktraceMap* back_map,
- std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames) {
- std::vector<std::string> skip_names{"libunwindstack.so", "libbacktrace.so"};
+ std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames,
+ std::vector<std::string>* skip_names) {
UnwindStackMap* stack_map = reinterpret_cast<UnwindStackMap*>(back_map);
auto process_memory = stack_map->process_memory();
unwindstack::Unwinder unwinder(MAX_BACKTRACE_FRAMES + num_ignore_frames, stack_map->stack_maps(),
regs, stack_map->process_memory());
- unwinder.Unwind(&skip_names, &stack_map->GetSuffixesToIgnore());
+ unwinder.Unwind(skip_names, &stack_map->GetSuffixesToIgnore());
if (num_ignore_frames >= unwinder.NumFrames()) {
frames->resize(0);
@@ -104,7 +104,8 @@
}
error_ = BACKTRACE_UNWIND_NO_ERROR;
- return Backtrace::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames);
+ std::vector<std::string> skip_names{"libunwindstack.so", "libbacktrace.so"};
+ return Backtrace::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames, &skip_names);
}
UnwindStackPtrace::UnwindStackPtrace(pid_t pid, pid_t tid, BacktraceMap* map)
@@ -124,5 +125,5 @@
}
error_ = BACKTRACE_UNWIND_NO_ERROR;
- return Backtrace::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames);
+ return Backtrace::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames, nullptr);
}
diff --git a/libbacktrace/include/backtrace/Backtrace.h b/libbacktrace/include/backtrace/Backtrace.h
index 73a58b5..e073533 100644
--- a/libbacktrace/include/backtrace/Backtrace.h
+++ b/libbacktrace/include/backtrace/Backtrace.h
@@ -109,7 +109,8 @@
virtual bool Unwind(size_t num_ignore_frames, ucontext_t* context = NULL) = 0;
static bool Unwind(unwindstack::Regs* regs, BacktraceMap* back_map,
- std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames);
+ std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames,
+ std::vector<std::string>* skip_names);
// Get the function name and offset into the function given the pc.
// If the string is empty, then no valid function name was found,
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
index 94029d8..c4795a7 100644
--- a/toolbox/Android.mk
+++ b/toolbox/Android.mk
@@ -59,3 +59,12 @@
$(INPUT_H_LABELS_H): $(LOCAL_PATH)/Android.mk $(LOCAL_PATH)/generate-input.h-labels.py $(UAPI_INPUT_EVENT_CODES_H)
$(INPUT_H_LABELS_H):
$(transform-generated-source)
+
+# We only want 'r' on userdebug and eng builds.
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := r.c
+LOCAL_CFLAGS += $(common_cflags)
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/upstream-netbsd/include/
+LOCAL_MODULE := r
+LOCAL_MODULE_TAGS := debug
+include $(BUILD_EXECUTABLE)
diff --git a/toolbox/r.c b/toolbox/r.c
new file mode 100644
index 0000000..b96cdb2
--- /dev/null
+++ b/toolbox/r.c
@@ -0,0 +1,102 @@
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+#if __LP64__
+#define strtoptr strtoull
+#else
+#define strtoptr strtoul
+#endif
+
+static int usage()
+{
+ fprintf(stderr,"r [-b|-s] <address> [<value>]\n");
+ return -1;
+}
+
+int main(int argc, char *argv[])
+{
+ if(argc < 2) return usage();
+
+ int width = 4;
+ if(!strcmp(argv[1], "-b")) {
+ width = 1;
+ argc--;
+ argv++;
+ } else if(!strcmp(argv[1], "-s")) {
+ width = 2;
+ argc--;
+ argv++;
+ }
+
+ if(argc < 2) return usage();
+ uintptr_t addr = strtoptr(argv[1], 0, 16);
+
+ uintptr_t endaddr = 0;
+ char* end = strchr(argv[1], '-');
+ if (end)
+ endaddr = strtoptr(end + 1, 0, 16);
+
+ if (!endaddr)
+ endaddr = addr + width - 1;
+
+ if (endaddr <= addr) {
+ fprintf(stderr, "end address <= start address\n");
+ return -1;
+ }
+
+ bool set = false;
+ uint32_t value = 0;
+ if(argc > 2) {
+ set = true;
+ value = strtoul(argv[2], 0, 16);
+ }
+
+ int fd = open("/dev/mem", O_RDWR | O_SYNC);
+ if(fd < 0) {
+ fprintf(stderr,"cannot open /dev/mem\n");
+ return -1;
+ }
+
+ off64_t mmap_start = addr & ~(PAGE_SIZE - 1);
+ size_t mmap_size = endaddr - mmap_start + 1;
+ mmap_size = (mmap_size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+
+ void* page = mmap64(0, mmap_size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, mmap_start);
+
+ if(page == MAP_FAILED){
+ fprintf(stderr,"cannot mmap region\n");
+ return -1;
+ }
+
+ while (addr <= endaddr) {
+ switch(width){
+ case 4: {
+ uint32_t* x = (uint32_t*) (((uintptr_t) page) + (addr & 4095));
+ if(set) *x = value;
+ fprintf(stderr,"%08"PRIxPTR": %08x\n", addr, *x);
+ break;
+ }
+ case 2: {
+ uint16_t* x = (uint16_t*) (((uintptr_t) page) + (addr & 4095));
+ if(set) *x = value;
+ fprintf(stderr,"%08"PRIxPTR": %04x\n", addr, *x);
+ break;
+ }
+ case 1: {
+ uint8_t* x = (uint8_t*) (((uintptr_t) page) + (addr & 4095));
+ if(set) *x = value;
+ fprintf(stderr,"%08"PRIxPTR": %02x\n", addr, *x);
+ break;
+ }
+ }
+ addr += width;
+ }
+ return 0;
+}