]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
added -disasm-func to the qcvm
authorWolfgang Bumiller <blub@speed.at>
Sun, 23 Dec 2012 19:45:43 +0000 (20:45 +0100)
committerWolfgang Bumiller <blub@speed.at>
Sun, 23 Dec 2012 19:45:43 +0000 (20:45 +0100)
doc/qcvm.1
exec.c

index b018a8f811b66c9f8dffa9043426d97be3e436aa..857225f8e482a5aa6c19593f308780c1b7608d2e 100644 (file)
@@ -32,6 +32,9 @@ Print information from the program's header instead of executing.
 .B "-disasm"
 Disassemble the program by function instead of executing.
 .TP
+.BI "-disasm-func" function
+Search for and disassemble the given function.
+.TP
 .B "-printdefs"
 List all entries from the program's defs-section. Effectively
 listing all the global variables of the program.
diff --git a/exec.c b/exec.c
index dc5980dc4e27cde690c81c58e92a1bb2032124dc..8fe29434107ef1b67bc3dfea2704e7a4b3079ea0 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -824,14 +824,15 @@ static void usage()
 {
     printf("usage: %s [options] [parameters] file\n", arg0);
     printf("options:\n");
-    printf("  -h, --help    print this message\n"
-           "  -trace        trace the execution\n"
-           "  -profile      perform profiling during execution\n"
-           "  -info         print information from the prog's header\n"
-           "  -disasm       disassemble and exit\n"
-           "  -printdefs    list the defs section\n"
-           "  -printfields  list the field section\n"
-           "  -printfuns    list functions information\n");
+    printf("  -h, --help         print this message\n"
+           "  -trace             trace the execution\n"
+           "  -profile           perform profiling during execution\n"
+           "  -info              print information from the prog's header\n"
+           "  -disasm            disassemble and exit\n"
+           "  -disasm-func func  disassemble and exit\n"
+           "  -printdefs         list the defs section\n"
+           "  -printfields       list the field section\n"
+           "  -printfuns         list functions information\n");
     printf("parameters:\n");
     printf("  -vector <V>   pass a vector parameter to main()\n"
            "  -float  <f>   pass a float parameter to main()\n"
@@ -889,6 +890,7 @@ int main(int argc, char **argv)
     bool        opts_info        = false;
     bool        noexec           = false;
     const char *progsfile        = NULL;
+    const char **dis_list        = NULL;
 
     arg0 = argv[0];
 
@@ -934,6 +936,18 @@ int main(int argc, char **argv)
             opts_disasm = true;
             noexec = true;
         }
+        else if (!strcmp(argv[1], "-disasm-func")) {
+            --argc;
+            ++argv;
+            if (argc <= 1) {
+                usage();
+                exit(1);
+            }
+            vec_push(dis_list, argv[1]);
+            --argc;
+            ++argv;
+            noexec = true;
+        }
         else if (!strcmp(argv[1], "-printdefs")) {
             --argc;
             ++argv;
@@ -1048,6 +1062,17 @@ int main(int argc, char **argv)
         prog_delete(prog);
         return 0;
     }
+    for (i = 0; i < vec_size(dis_list); ++i) {
+        size_t k;
+        printf("Looking for `%s`\n", dis_list[i]);
+        for (k = 1; k < vec_size(prog->functions); ++k) {
+            const char *name = prog_getstring(prog, prog->functions[k].name);
+            if (!strcmp(name, dis_list[i])) {
+                prog_disasm_function(prog, k);
+                break;
+            }
+        }
+    }
     if (opts_disasm) {
         for (i = 1; i < vec_size(prog->functions); ++i)
             prog_disasm_function(prog, i);