[PATCH] D68427: [scudo][standalone] Make malloc_info return a minimal XML

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 4 08:46:49 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL373754: [scudo][standalone] Make malloc_info return a minimal XML (authored by cryptoad, committed by ).

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68427/new/

https://reviews.llvm.org/D68427

Files:
  compiler-rt/trunk/lib/scudo/standalone/tests/combined_test.cpp
  compiler-rt/trunk/lib/scudo/standalone/tests/wrappers_c_test.cpp
  compiler-rt/trunk/lib/scudo/standalone/wrappers_c.inc


Index: compiler-rt/trunk/lib/scudo/standalone/wrappers_c.inc
===================================================================
--- compiler-rt/trunk/lib/scudo/standalone/wrappers_c.inc
+++ compiler-rt/trunk/lib/scudo/standalone/wrappers_c.inc
@@ -179,7 +179,8 @@
       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;
 }
Index: compiler-rt/trunk/lib/scudo/standalone/tests/combined_test.cpp
===================================================================
--- compiler-rt/trunk/lib/scudo/standalone/tests/combined_test.cpp
+++ compiler-rt/trunk/lib/scudo/standalone/tests/combined_test.cpp
@@ -101,7 +101,7 @@
   // 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;
Index: compiler-rt/trunk/lib/scudo/standalone/tests/wrappers_c_test.cpp
===================================================================
--- compiler-rt/trunk/lib/scudo/standalone/tests/wrappers_c_test.cpp
+++ compiler-rt/trunk/lib/scudo/standalone/tests/wrappers_c_test.cpp
@@ -281,3 +281,14 @@
 
   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);
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68427.223228.patch
Type: text/x-patch
Size: 1951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191004/546a88f7/attachment.bin>


More information about the llvm-commits mailing list