summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2019-10-04 15:46:34 +0000
committerKostya Kortchinsky <kostyak@google.com>2019-10-04 15:46:34 +0000
commitdc802dbef28429f8b7bfa0ad8dc43d8c6233e825 (patch)
tree6579d5f2f822f6f6612c69be52c522f79e94a10e
parent237d0af7a8b8b9b507f86846842a51657810b20d (diff)
downloadbcm5719-llvm-dc802dbef28429f8b7bfa0ad8dc43d8c6233e825.tar.gz
bcm5719-llvm-dc802dbef28429f8b7bfa0ad8dc43d8c6233e825.zip
[scudo][standalone] Make malloc_info return a minimal XML
Summary: Initially, our malloc_info was returning ENOTSUP, but Android would rather have it return successfully and write a barebone XML to the stream, so we will oblige. Add an associated test. Reviewers: cferris, morehouse, hctim, eugenis, vitalybuka Reviewed By: morehouse Subscribers: delcypher, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D68427 llvm-svn: 373754
-rw-r--r--compiler-rt/lib/scudo/standalone/tests/combined_test.cpp2
-rw-r--r--compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp11
-rw-r--r--compiler-rt/lib/scudo/standalone/wrappers_c.inc7
3 files changed, 16 insertions, 4 deletions
diff --git a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
index c9c65690a53..3f971a30428 100644
--- a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
@@ -101,7 +101,7 @@ template <class Config> static void testAllocator() {
// returns the same chunk. This requires that all the sizes we iterate on use
// the same block size, but that should be the case for 2048 with our default
// class size maps.
- P = Allocator->allocate(DataSize, Origin);
+ P = Allocator->allocate(DataSize, Origin);
memset(P, Marker, DataSize);
for (scudo::sptr Delta = -32; Delta < 32; Delta += 8) {
const scudo::uptr NewSize = DataSize + Delta;
diff --git a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
index 28c21ebc8da..cb651f265f0 100644
--- a/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/wrappers_c_test.cpp
@@ -281,3 +281,14 @@ TEST(ScudoWrappersCTest, MallocIterateBoundary) {
free(P);
}
+
+TEST(ScudoWrappersCTest, MallocInfo) {
+ char Buffer[64];
+ FILE *F = fmemopen(Buffer, sizeof(Buffer), "w+");
+ EXPECT_NE(F, nullptr);
+ errno = 0;
+ EXPECT_EQ(malloc_info(0, F), 0);
+ EXPECT_EQ(errno, 0);
+ fclose(F);
+ EXPECT_EQ(strncmp(Buffer, "<malloc version=\"scudo-", 23), 0);
+}
diff --git a/compiler-rt/lib/scudo/standalone/wrappers_c.inc b/compiler-rt/lib/scudo/standalone/wrappers_c.inc
index cb2202dcedf..a9adbc83588 100644
--- a/compiler-rt/lib/scudo/standalone/wrappers_c.inc
+++ b/compiler-rt/lib/scudo/standalone/wrappers_c.inc
@@ -179,7 +179,8 @@ INTERFACE WEAK void *SCUDO_PREFIX(aligned_alloc)(size_t alignment,
SCUDO_ALLOCATOR.allocate(size, scudo::Chunk::Origin::Malloc, alignment));
}
-INTERFACE WEAK int SCUDO_PREFIX(malloc_info)(int, FILE *) {
- errno = ENOTSUP;
- return -1;
+INTERFACE WEAK int SCUDO_PREFIX(malloc_info)(UNUSED int options, FILE *stream) {
+ fputs("<malloc version=\"scudo-1\">", stream);
+ fputs("</malloc>", stream);
+ return 0;
}
OpenPOWER on IntegriCloud