# LLDB



# LLDB Initialization

Example of a script to run LLDB on remote android server, receives an argument - process name (can also be package name)

> @echo ========Pushing lldb-server to target========  
> @adb push &lt;PATH\_TO: lldb-server&gt;  
> @adb shell "ls -al /data/local/tmp/lldb-server"  
> @adb shell su -c 'chmod 755 /data/local/tmp/lldb-server'  
> @adb shell "ls -al /data/local/tmp/lldb-server"  
> @  
> @echo ========Check if already running and kill========  
> @adb shell su -c "ps -A | grep -i lldb-server"  
> @echo ========Attempting to kill lldb-server========  
> @adb shell su -c pkill lldb-server  
> @adb shell su -c "ps -A | grep -i lldb-server"  
> @  
> @echo ========Forwarding ports from local 11966 to remote 11966========  
> @adb forward tcp:11966 tcp:11966  
> @  
> @echo ========Run program========  
> adb shell su -c /data/local/tmp/lldb-server g :11966 --attach $(ps -A ^| grep %1 ^| awk '{print $2}') 2&gt;&amp;1 1&gt;nul

Once Android Studio NDK is installed, on windows we can run the following to execute the LLDB client:

> C:\\Users\\&lt;USER&gt;\\AppData\\Local\\Android\\Sdk\\ndk\\&lt;VERSION&gt;\\toolchains\\llvm\\prebuilt\\windows-x86\_64\\bin\\lldb.cmd %\* --source &lt;LLDB\_SCRIPT&gt;

Where &lt;USER&gt; is the username AndroidStudio NDK was installed at, &lt;VERSION&gt; Might change according to the latest version  
&lt;LLDB\_SCRIPT&gt; is a path to the LLDB script, for example:

> command script import &lt;PATH\_TO\_PYTHON\_LLDB\_SCRIPT&gt;
> 
> platform select remote-android  
> gdb-remote 11966
> 
> b fopen  
> continue