[Lldb-commits] [lldb] r141764 - /lldb/trunk/docs/lldb-for-gdb-users.txt

Johnny Chen johnny.chen at apple.com
Tue Oct 11 18:28:23 PDT 2011

Author: johnny
Date: Tue Oct 11 20:28:23 2011
New Revision: 141764

URL: http://llvm.org/viewvc/llvm-project?rev=141764&view=rev
Add description of a more capable 'cd' command using 'command script add'.


Modified: lldb/trunk/docs/lldb-for-gdb-users.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-for-gdb-users.txt?rev=141764&r1=141763&r2=141764&view=diff
--- lldb/trunk/docs/lldb-for-gdb-users.txt (original)
+++ lldb/trunk/docs/lldb-for-gdb-users.txt Tue Oct 11 20:28:23 2011
@@ -448,3 +448,38 @@
 (lldb) pwd
+Or for a more capable 'cd' command, create ~/utils.py like this:
+import os
+def chdir(debugger, args, result, dict):
+    """Change the working directory, or cd to ${HOME}."""
+    dir = args.strip()
+    if dir:
+        os.chdir(args)
+    else:
+        os.chdir(os.path.expanduser('~'))
+    print "Current working directory: %s" % os.getcwd()
+and, have the following in your ~/.lldbinit file:
+script import os, sys
+script sys.path.append(os.path.expanduser('~'))
+script import utils
+command alias pwd script print os.getcwd()
+command script add -f utils.chdir cd
+and, then in your lldb session, you can have:
+(lldb) help cd
+Change the working directory, or cd to ${HOME}.
+Syntax: cd
+(lldb) cd
+Current working directory: /Volumes/data/Users/johnny
+(lldb) cd /tmp
+Current working directory: /private/tmp
+(lldb) pwd

More information about the lldb-commits mailing list