================
@@ -0,0 +1,223 @@
+//===-- main.cppp 
---------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "CoreSpec.h"
+#include "LCNoteWriter.h"
+#include "MemoryWriter.h"
+#include "ThreadWriter.h"
+#include "Utility.h"
+#include "yaml2corespec.h"
+
+#include "llvm/BinaryFormat/MachO.h"
+
+#include <getopt.h>
+#include <stdio.h>
+#include <string>
+#include <sys/stat.h>
+
+[[noreturn]] void print_help(void) {
+  fprintf(stderr, "Create a Mach-O corefile from a YAML register and memory "
+                  "description.\n");
+  fprintf(stderr, "Usage:\n");
+  fprintf(stderr, "   -i|--input <yaml spec>\n");
+  fprintf(stderr, "   -o|--output <corefile name>\n");
+  fprintf(stderr, "   -u|--uuids <uuid,uuid,uuid>\n");
+  fprintf(stderr, "   Add LC_NOTE 'load binary' for those UUIDs, "
+                  "at slide 0.\n");
+  exit(1);
+}
+
+std::vector<std::string> get_fields_from_delimited_string(std::string str,
+                                                          const char delim) {
+  std::vector<std::string> result;
+  std::string::size_type prev = std::string::npos;
+  std::string::size_type next = str.find(delim);
+  if (str.empty()) {
+    return result;
+  }
+  if (next == std::string::npos) {
+    result.push_back(str);
+  } else {
+    result.push_back(std::string(str, 0, next));
+    prev = next;
+    while ((next = str.find(delim, prev + 1)) != std::string::npos) {
+      result.push_back(std::string(str, prev + 1, next - prev - 1));
+      prev = next;
+    }
+    result.push_back(std::string(str, prev + 1));
+  }
+  return result;
+}
+
+int main(int argc, char **argv) {
+
+  const char *const short_opts = "i:o:u:h";
+  const option long_opts[] = {{"input", required_argument, nullptr, 'i'},
----------------
JDevlieghere wrote:

This should use `cl::opt` (https://llvm.org/docs/CommandLine.html). Even if the 
current implementation is slightly simpler, it makes it harder to extend in the 
future. It's used by every llvm tool (that doesn't use tablegen). 

https://github.com/llvm/llvm-project/pull/153911
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to