Reviewers: Dmitry Titov,

Message:
Hopefully this will be useful!

Description:
[Isolates] Script for looking for statics using objdump

Call as: tools/liststatics.sh heap.o

The lines above %%% in statics.whitelist are matched as suffixes;
the lines below are matched as regexes. As we determine that a symbol
is not problematic (like a constant that needs runtime initialization),
we can add it to the whitelist.b


Please review this at http://codereview.chromium.org/2853004/show

SVN Base: http://v8.googlecode.com/svn/branches/experimental/isolates/

Affected files:
  A     tools/liststatics.sh
  A     tools/statics.whitelist
  A     tools/swhitelist.ml


Index: tools/liststatics.sh
===================================================================
--- tools/liststatics.sh        (revision 0)
+++ tools/liststatics.sh        (revision 0)
@@ -0,0 +1,3 @@
+#!/bin/sh
+objdump --demangle -t obj/debug/$1 | grep '\.bss\|\.data\|\.rodata' \
+    | ocaml tools/swhitelist.ml tools/statics.whitelist

Property changes on: tools/liststatics.sh
___________________________________________________________________
Name: svn:executable
   + *

Index: tools/statics.whitelist
===================================================================
--- tools/statics.whitelist     (revision 0)
+++ tools/statics.whitelist     (revision 0)
@@ -0,0 +1,5 @@
+00000000 .data
+00000000 .bss
+00000000 .rodata
+%%%
+.*hidden vtable for.*
Index: tools/swhitelist.ml
===================================================================
--- tools/swhitelist.ml (revision 0)
+++ tools/swhitelist.ml (revision 0)
@@ -0,0 +1,43 @@
+(* swhitelist.ml
+ * Drops lines from stdin if they match criteria specified in an
+ * external file. *)
+
+#load "str.cma";;
+
+open Arg
+open List
+open Str
+
+let regexes = ref []
+let total_discard = ref 0
+
+let load_file fn =
+  let fb = open_in fn in
+  let rec read_regex () =
+    try
+      let nline = input_line fb in
+      regexes := regexp nline :: (!regexes);
+      read_regex ()
+    with End_of_file -> () in
+  let rec read_suffix () =
+    try
+      let nline = input_line fb in
+      if nline = "%%%" then read_regex ()
+      else
+        regexes := regexp (".*" ^ (quote nline)) :: (!regexes);
+        read_suffix ()
+    with End_of_file -> () in
+  read_suffix (); close_in fb
+
+let scrub_line l =
+  if exists (fun x -> string_match x l 0 &&
+          match_end () == String.length l) (!regexes)
+      then incr total_discard else print_endline l
+
+let rec scrub_stdin () =
+  try (scrub_line (read_line ()); scrub_stdin ()) with End_of_file -> ()
+
+let _ =
+  Arg.parse [] load_file "swhitelist [whitelist-files...]";
+  scrub_stdin ();
+  print_endline (string_of_int (!total_discard) ^ " lines discarded.")


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to