Move cma dump to itself

Bug: 273380985
Test: adb bugreport
Change-Id: I6732dd8dbbf0367f99e25b29f2a0dd526aaac9d4
diff --git a/dumpstate/Android.bp b/dumpstate/Android.bp
index 9b6076d..6e0dd26 100644
--- a/dumpstate/Android.bp
+++ b/dumpstate/Android.bp
@@ -2,6 +2,13 @@
     default_applicable_licenses: ["Android-Apache-2.0"],
 }
 
+sh_binary {
+    name: "dump_gs101.sh",
+    src: "dump_gs101.sh",
+    vendor: true,
+    sub_dir: "dump",
+}
+
 cc_binary {
     name: "android.hardware.dumpstate-service.gs101",
     srcs: [
diff --git a/dumpstate/Dumpstate.cpp b/dumpstate/Dumpstate.cpp
index 57f929f..d4af35b 100644
--- a/dumpstate/Dumpstate.cpp
+++ b/dumpstate/Dumpstate.cpp
@@ -241,7 +241,6 @@
 
 Dumpstate::Dumpstate()
   : mTextSections{
-        { "memory", [this](int fd) { dumpMemorySection(fd); } },
         { "power", [this](int fd) { dumpPowerSection(fd); } },
         { "camera", [this](int fd) { dumpCameraSection(fd); } },
     } {
@@ -492,20 +491,6 @@
 
 }
 
-// Dump items related to memory
-void Dumpstate::dumpMemorySection(int fd) {
-    RunCommandToFd(fd, "Pixel CMA stat", {"/vendor/bin/sh", "-c",
-                   "for d in $(ls -d /sys/kernel/pixel_stat/mm/cma/*); do "
-                       "if [ -f $d ]; then "
-                           "echo --- $d; cat $d; "
-                       "else "
-                           "for f in $(ls $d); do "
-                               "echo --- $d/$f; cat $d/$f; "
-                               "done; "
-                        "fi; "
-                        "done"});
-}
-
 // Dump essential camera debugging logs
 void Dumpstate::dumpCameraSection(int fd) {
     RunCommandToFd(fd, "Camera HAL Graph State Dump", {"/vendor/bin/sh", "-c",
diff --git a/dumpstate/dump_gs101.sh b/dumpstate/dump_gs101.sh
new file mode 100644
index 0000000..211140c
--- /dev/null
+++ b/dumpstate/dump_gs101.sh
@@ -0,0 +1,14 @@
+#!/vendor/bin/sh
+echo "------ Pixel CMA stat ------"
+for d in $(ls -d /sys/kernel/pixel_stat/mm/cma/*); do
+  if [ -f $d ]; then
+    echo --- $d
+    cat $d
+  else
+    for f in $(ls $d); do
+      echo --- $d/$f
+      cat $d/$f
+    done
+  fi
+done
+
diff --git a/dumpstate/item.mk b/dumpstate/item.mk
new file mode 100644
index 0000000..7a1d2ba
--- /dev/null
+++ b/dumpstate/item.mk
@@ -0,0 +1,2 @@
+PRODUCT_PACKAGES += dump_gs101.sh
+