Allow several build directories to be specified to search for symbols

Address the `device stack` part of domokit/devtools#38.

R=ppi@chromium.org

Review URL: https://codereview.chromium.org/1312283003 .

Cr-Mirrored-From: https://github.com/domokit/mojo
Cr-Mirrored-Commit: c66af0d5b43b7725c9c77559bd25c03119c5d8dc
diff --git a/android_stack_parser/stack b/android_stack_parser/stack
index f75d097..9bfc18b 100755
--- a/android_stack_parser/stack
+++ b/android_stack_parser/stack
@@ -99,7 +99,7 @@
     elif option == "--arch":
       symbol.ARCH = value
     elif option == "--build-dir":
-      symbol.BUILD_DIR = value
+      symbol.BUILD_DIRS = value.split(',')
     elif option == "--ndk-dir":
       symbol.NDK_DIR = value
     elif option == "--more-info":
@@ -107,13 +107,13 @@
     elif option == "--less-info":
       more_info = False
 
-  if not symbol.BUILD_DIR:
+  if not symbol.BUILD_DIRS:
     guess = stack_utils.GuessDir(_DEFAULT_BUILD_DIR)
     if not guess:
       print "Couldn't find the build directory, please pass --build-dir."
       return 1
     print "Inferring the build directory path as " + guess
-    symbol.BUILD_DIR = guess
+    symbol.BUILD_DIRS = [guess]
 
   if not symbol.NDK_DIR:
     guess = stack_utils.GuessDir(_DEFAULT_NDK_DIR)
@@ -144,7 +144,7 @@
   if symbol.SYMBOLS_DIR:
     print "Reading Android symbols from", symbol.SYMBOLS_DIR
 
-  print "Reading Mojo symbols from", symbol.BUILD_DIR
+  print "Reading symbols from", symbol.BUILD_DIRS
   stack_core.ConvertTrace(lines, more_info, stack_utils.GetSymbolMapping(lines))
 
   if rootdir:
diff --git a/android_stack_parser/symbol.py b/android_stack_parser/symbol.py
index 797326c..a0ae6a0 100644
--- a/android_stack_parser/symbol.py
+++ b/android_stack_parser/symbol.py
@@ -25,7 +25,7 @@
 import zipfile
 
 NDK_DIR = ""
-BUILD_DIR = ""
+BUILD_DIRS = []
 SYMBOLS_DIR = ""
 
 ARCH = "arm"
@@ -190,7 +190,7 @@
   Returns:
     A list of candidate files ordered by modification time, newest first.
   """
-  candidates = [BUILD_DIR]
+  candidates = list(BUILD_DIRS)
 
   if relative_dirs:
     candidates = PathListJoin(candidates, relative_dirs)
diff --git a/mojo_debug b/mojo_debug
index fb4459f..31a93de 100755
--- a/mojo_debug
+++ b/mojo_debug
@@ -287,7 +287,7 @@
   device_stack_parser.add_argument('--ndk-dir', type=str,
       help='path to the directory containing the Android NDK')
   device_stack_parser.add_argument('--build-dir', type=str,
-      help='path to the build directory')
+      help='list paths to the build directories, separated by commas')
   device_stack_parser.set_defaults(func=_device_stack)