| Attached Files | 0001-objinfo-dump-globals-defined-in-bytecode-executables.patch [^] (2,578 bytes) 2010-10-05 15:03 [Show Content] [Hide Content]From e3f718c32d0b161435c7d18fdb94bbec99448be0 Mon Sep 17 00:00:00 2001
From: Stephane Glondu <steph@glondu.net>
Date: Tue, 5 Oct 2010 14:49:57 +0200
Subject: [PATCH] objinfo: dump globals defined in bytecode executables
---
bytecomp/cmo_format.mli | 6 ++++++
bytecomp/symtable.ml | 6 ------
tools/Makefile.shared | 1 +
tools/objinfo.ml | 8 ++++++++
4 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/bytecomp/cmo_format.mli b/bytecomp/cmo_format.mli
index c87e6df..49e6c57 100644
--- a/bytecomp/cmo_format.mli
+++ b/bytecomp/cmo_format.mli
@@ -58,3 +58,9 @@ type library =
...
object code for last library member
library descriptor *)
+
+(* Tables for numbering objects *)
+
+type 'a numtable =
+ { num_cnt: int; (* The next number *)
+ num_tbl: ('a, int) Tbl.t } (* The table of already numbered objects *)
diff --git a/bytecomp/symtable.ml b/bytecomp/symtable.ml
index 136144e..d686fc3 100644
--- a/bytecomp/symtable.ml
+++ b/bytecomp/symtable.ml
@@ -29,12 +29,6 @@ type error =
exception Error of error
-(* Tables for numbering objects *)
-
-type 'a numtable =
- { num_cnt: int; (* The next number *)
- num_tbl: ('a, int) Tbl.t } (* The table of already numbered objects *)
-
let empty_numtable = { num_cnt = 0; num_tbl = Tbl.empty }
let find_numtable nt key =
diff --git a/tools/Makefile.shared b/tools/Makefile.shared
index 12bf76f..5929030 100644
--- a/tools/Makefile.shared
+++ b/tools/Makefile.shared
@@ -233,6 +233,7 @@ objinfo_helper$(EXE): objinfo_helper.c ../config/s.h
objinfo_helper.c $(LIBBFD_LINK)
OBJINFO=../utils/misc.cmo ../utils/config.cmo ../bytecomp/bytesections.cmo \
+ ../typing/ident.cmo ../utils/tbl.cmo \
objinfo.cmo
objinfo: objinfo_helper$(EXE) $(OBJINFO)
diff --git a/tools/objinfo.ml b/tools/objinfo.ml
index e9eb403..11b4a64 100644
--- a/tools/objinfo.ml
+++ b/tools/objinfo.ml
@@ -112,6 +112,12 @@ let print_general_infos name crc defines cmi cmx =
printf "Implementations imported:\n";
List.iter print_name_crc cmx
+let print_global_table table =
+ printf "Globals defined:\n";
+ Tbl.iter
+ (fun id _ -> print_line (Ident.name id))
+ table.num_tbl
+
open Cmx_format
let print_cmx_infos (ui, crc) =
@@ -177,6 +183,8 @@ let dump_byte ic =
"Primitives used"
print_line
(input_stringlist ic len)
+ | "SYMB" ->
+ print_global_table (input_value ic)
| _ -> ()
with _ -> ()
)
--
1.7.1
|