Show definition classes, names, and backlinks
authorNick Downing <nick@ndcode.org>
Sat, 12 Oct 2019 23:14:51 +0000 (10:14 +1100)
committerNick Downing <nick@ndcode.org>
Sat, 12 Oct 2019 23:16:40 +0000 (10:16 +1100)
definition_dcls.h
multics_sim.c

index 463f51d..22c0e50 100644 (file)
@@ -9,20 +9,20 @@
 
 // declare (
 enum {
- // CLASS_TEXT init (0), /* text section definition */
- CLASS_TEXT = 0,
- // CLASS_LINKAGE init (1), /* linkage section definition */
- CLASS_LINKAGE = 1,
- // CLASS_SYMBOL init (2), /* symbol section definition */
- CLASS_SYMBOL = 2,
- // CLASS_SEGNAME init (3), /* segment name definition */
- CLASS_SEGNAME = 3,
- // CLASS_STATIC init (4), /* static section definition */
- CLASS_STATIC = 4,
- // CLASS_SYSTEM init (5), /* valid only in self links, not def class */
- CLASS_SYSTEM = 5,
- // CLASS_HEAP init (6) /* valid only in self links, not def class */
- CLASS_HEAP = 6
 // CLASS_TEXT init (0), /* text section definition */
 CLASS_TEXT = 0,
 // CLASS_LINKAGE init (1), /* linkage section definition */
 CLASS_LINKAGE = 1,
 // CLASS_SYMBOL init (2), /* symbol section definition */
 CLASS_SYMBOL = 2,
 // CLASS_SEGNAME init (3), /* segment name definition */
 CLASS_SEGNAME = 3,
 // CLASS_STATIC init (4), /* static section definition */
 CLASS_STATIC = 4,
 // CLASS_SYSTEM init (5), /* valid only in self links, not def class */
 CLASS_SYSTEM = 5,
 // CLASS_HEAP init (6) /* valid only in self links, not def class */
 CLASS_HEAP = 6
 // ) fixed bin (3) unsigned internal static options (constant);
 };
 
index ae69d7a..341ad4a 100644 (file)
@@ -16,6 +16,16 @@ char *paths[] = {
   "tape/word/system_library_standard/"
 };
 
+void get_acc_string(uint64_t *acc_string, char *buf, int buf_len) {
+  int len = (acc_string[0] >> 27) & 0777;
+  rassert(len < buf_len);
+
+  static int shifts[4] = {27, 18, 9, 0};
+  for (int i = 0, j = 1; i < len; ++i, ++j)
+    buf[i] = (acc_string[j >> 2] >> shifts[j & 3]) & 0xff;
+  buf[len] = 0;
+}
+
 int main(int argc, char **argv) {
   if (argc < 2) {
     printf("usage: %s executable [arguments]\n", argv[0]);
@@ -26,6 +36,7 @@ int main(int argc, char **argv) {
   int path_index;
   for (path_index = 0; path_index < N_PATHS; ++path_index) {
     char name[0x1000];
+    rassert(strlen(paths[path_index]) + strlen(argv[1]) < sizeof(name));
     strcpy(name, paths[path_index]);
     strcat(name, argv[1]);
 
@@ -51,6 +62,7 @@ found_path:
   uint64_t bitcount;
   {
     char name[0x1000];
+    rassert(strlen(paths[path_index]) + 4 < sizeof(name));
     strcpy(name, paths[path_index]);
     strcat(name, ".dir");
 
@@ -96,11 +108,29 @@ found_bitcount:
     definition = (struct definition *)(
       (uint64_t *)definition_header + definition_relp
     );
-    printf(
-      "%06o %06o\n",
-      object_map->definition_offset + definition->segname_relp,
-      object_map->definition_offset + definition->name_relp
+
+    char name[0x20];
+    get_acc_string(
+      (uint64_t *)definition_header + definition->name_relp,
+      name,
+      sizeof(name)
     );
+
+    if (definition->class == CLASS_SEGNAME)
+      printf(
+        "%06o segname \"%s\" first_relp %06o\n",
+        definition_relp,
+        name,
+        ((struct segname_definition *)definition)->first_relp
+      );
+    else
+      printf(
+        "%06o %s \"%s\" segname_relp %06o\n",
+        definition_relp,
+        class_names[definition->class],
+        name,
+        definition->segname_relp
+      );
   }
   return 0;
 }