Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: mojo/devtools/common/mojo_debug

Issue 1325593004: Allow mojo_debug gdb attach to search symbols in multiple directories. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/devtools/common/android_gdb/session.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse 6 import argparse
7 import codecs 7 import codecs
8 import logging 8 import logging
9 import os.path 9 import os.path
10 import requests 10 import requests
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 logcat_cmd = [adb_path, 'logcat', '-d'] 136 logcat_cmd = [adb_path, 'logcat', '-d']
137 try: 137 try:
138 logcat = subprocess.Popen(logcat_cmd, stdout=subprocess.PIPE) 138 logcat = subprocess.Popen(logcat_cmd, stdout=subprocess.PIPE)
139 except OSError: 139 except OSError:
140 print 'failed to call adb, make sure it is in PATH or pass --adb-path' 140 print 'failed to call adb, make sure it is in PATH or pass --adb-path'
141 return 1 141 return 1
142 142
143 devtools_dir = os.path.dirname(os.path.abspath(__file__)) 143 devtools_dir = os.path.dirname(os.path.abspath(__file__))
144 stack_command = [os.path.join(devtools_dir, 'android_stack_parser', 'stack')] 144 stack_command = [os.path.join(devtools_dir, 'android_stack_parser', 'stack')]
145 if args.build_dir: 145 if args.build_dir:
146 stack_command.append('--build-dir=' + os.path.abspath(args.build_dir)) 146 stack_command.append('--build-dir=' +
147 os.path.abspath(','.join(args.build_dir)))
147 if args.ndk_dir: 148 if args.ndk_dir:
148 stack_command.append('--ndk-dir=' + os.path.abspath(args.ndk_dir)) 149 stack_command.append('--ndk-dir=' + os.path.abspath(args.ndk_dir))
149 stack_command.append('-') 150 stack_command.append('-')
150 stack = subprocess.Popen(stack_command, stdin=logcat.stdout) 151 stack = subprocess.Popen(stack_command, stdin=logcat.stdout)
151 152
152 logcat.wait() 153 logcat.wait()
153 stack.wait() 154 stack.wait()
154 155
155 if logcat.returncode: 156 if logcat.returncode:
156 print 'adb logcat failed, make sure the device is connected and available' 157 print 'adb logcat failed, make sure the device is connected and available'
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 'arm-linux-androideabi-4.9', 216 'arm-linux-androideabi-4.9',
216 'prebuilt', 217 'prebuilt',
217 # TODO(etiennej): DEPS mac NDK and use it on macs. 218 # TODO(etiennej): DEPS mac NDK and use it on macs.
218 'linux-x86_64', 219 'linux-x86_64',
219 'bin', 220 'bin',
220 'arm-linux-androideabi-gdb') 221 'arm-linux-androideabi-gdb')
221 python_gdb_script_path = os.path.join(os.path.dirname(__file__), 222 python_gdb_script_path = os.path.join(os.path.dirname(__file__),
222 'android_gdb', 'session.py') 223 'android_gdb', 'session.py')
223 debug_session_arguments = {} 224 debug_session_arguments = {}
224 if args.build_dir: 225 if args.build_dir:
225 debug_session_arguments["build_directory"] = args.build_dir 226 debug_session_arguments["build_directory_list"] = ','.join(args.build_dir)
226 else: 227 else:
227 try: 228 try:
228 debug_session_arguments["build_directory"] = os.path.join( 229 debug_session_arguments["build_directory_list"] = os.path.join(
229 _get_dir_above('out'), 'out', 'android_Debug') 230 _get_dir_above('out'), 'out', 'android_Debug')
230 if not os.path.exists(debug_session_arguments["build_directory"]): 231 if not os.path.exists(debug_session_arguments["build_directory_list"]):
231 raise DirectoryNotFoundException() 232 raise DirectoryNotFoundException()
232 except DirectoryNotFoundException: 233 except DirectoryNotFoundException:
233 logging.fatal("Unable to find the build directory, please specify it " 234 logging.fatal("Unable to find the build directory, please specify it "
234 "using --build-dir.") 235 "using --build-dir.")
235 return 236 return
236 237
237 if args.package_name: 238 if args.package_name:
238 debug_session_arguments["package_name"] = args.package_name 239 debug_session_arguments["package_name"] = args.package_name
239 else: 240 else:
240 debug_session_arguments["package_name"] = _DEFAULT_PACKAGE_NAME 241 debug_session_arguments["package_name"] = _DEFAULT_PACKAGE_NAME
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 '--adb-path)') 284 '--adb-path)')
284 device_parser.add_argument('--adb-path', type=str, 285 device_parser.add_argument('--adb-path', type=str,
285 help='path to the adb tool from the Android SDK (optional)') 286 help='path to the adb tool from the Android SDK (optional)')
286 device_subparser = device_parser.add_subparsers( 287 device_subparser = device_parser.add_subparsers(
287 help='the command to run') 288 help='the command to run')
288 289
289 device_stack_parser = device_subparser.add_parser('stack', 290 device_stack_parser = device_subparser.add_parser('stack',
290 help='symbolize the crash stacktraces from the device log') 291 help='symbolize the crash stacktraces from the device log')
291 device_stack_parser.add_argument('--ndk-dir', type=str, 292 device_stack_parser.add_argument('--ndk-dir', type=str,
292 help='path to the directory containing the Android NDK') 293 help='path to the directory containing the Android NDK')
293 device_stack_parser.add_argument('--build-dir', type=str, 294 device_stack_parser.add_argument('--build-dir', type=str, action='append',
294 help='list paths to the build directories, separated by commas') 295 help='paths to the build directory, may be repeated')
295 device_stack_parser.set_defaults(func=_device_stack) 296 device_stack_parser.set_defaults(func=_device_stack)
296 297
297 298
298 def _add_gdb_command(subparsers): 299 def _add_gdb_command(subparsers):
299 gdb_parser = subparsers.add_parser( 300 gdb_parser = subparsers.add_parser(
300 'gdb', help='Debug Mojo Shell and its apps using GDB') 301 'gdb', help='Debug Mojo Shell and its apps using GDB')
301 gdb_subparser = gdb_parser.add_subparsers( 302 gdb_subparser = gdb_parser.add_subparsers(
302 help='Commands to GDB') 303 help='Commands to GDB')
303 304
304 gdb_attach_parser = gdb_subparser.add_parser( 305 gdb_attach_parser = gdb_subparser.add_parser(
305 'attach', help='Attach GDB to a running Mojo Shell process') 306 'attach', help='Attach GDB to a running Mojo Shell process')
306 gdb_attach_parser.add_argument('--adb-path', type=str, 307 gdb_attach_parser.add_argument('--adb-path', type=str,
307 help='path to the adb tool from the Android SDK (optional)') 308 help='path to the adb tool from the Android SDK (optional)')
308 gdb_attach_parser.add_argument('--ndk-dir', type=str, 309 gdb_attach_parser.add_argument('--ndk-dir', type=str,
309 help='path to the directory containing the Android NDK') 310 help='path to the directory containing the Android NDK')
310 gdb_attach_parser.add_argument('--build-dir', type=str, 311 gdb_attach_parser.add_argument('--build-dir', type=str, action='append',
311 help='path to the build directory') 312 help='Paths to the build directory, may be repeated')
312 gdb_attach_parser.add_argument('--pyelftools-dir', type=str, 313 gdb_attach_parser.add_argument('--pyelftools-dir', type=str,
313 help='Path to a directory containing third party libraries') 314 help='Path to a directory containing third party libraries')
314 gdb_attach_parser.add_argument('--gsutil-dir', type=str, 315 gdb_attach_parser.add_argument('--gsutil-dir', type=str,
315 help='Path to a directory containing gsutil') 316 help='Path to a directory containing gsutil')
316 gdb_attach_parser.add_argument('--package-name', type=str, 317 gdb_attach_parser.add_argument('--package-name', type=str,
317 help='Name of the Mojo Shell android package to debug') 318 help='Name of the Mojo Shell android package to debug')
318 gdb_attach_parser.set_defaults(func=_gdb_attach) 319 gdb_attach_parser.set_defaults(func=_gdb_attach)
319 320
320 321
321 def main(): 322 def main():
322 parser = argparse.ArgumentParser(description='Command-line interface for ' 323 parser = argparse.ArgumentParser(description='Command-line interface for '
323 'mojo:debugger') 324 'mojo:debugger')
324 subparsers = parser.add_subparsers(help='the tool to run') 325 subparsers = parser.add_subparsers(help='the tool to run')
325 _add_device_command(subparsers) 326 _add_device_command(subparsers)
326 _add_tracing_command(subparsers) 327 _add_tracing_command(subparsers)
327 _add_wm_command(subparsers) 328 _add_wm_command(subparsers)
328 _add_gdb_command(subparsers) 329 _add_gdb_command(subparsers)
329 330
330 args = parser.parse_args() 331 args = parser.parse_args()
331 return args.func(args) 332 return args.func(args)
332 333
333 if __name__ == '__main__': 334 if __name__ == '__main__':
334 sys.exit(main()) 335 sys.exit(main())
OLDNEW
« no previous file with comments | « mojo/devtools/common/android_gdb/session.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698