[lldb-dev] Question on lldb commands and remote connection

Greg Clayton gclayton at apple.com
Thu Oct 10 09:57:46 PDT 2013


On Oct 9, 2013, at 9:13 PM, Yin Ma <yin at affinic.com> wrote:

> Hi Greg,
> 
> Thank you for explaining all those in great detail.
> 
> However, for working-dir, I still cannot get a solution to 
> work for my case.
> 
> What I need to do is something like this 
> Process launch --working-dir /tmp  -Xxm100M

terminate your process launch arguments with --:

(lldb) process launch --working-dir /tmp -- -Xxm100M

> 
> However, if I use process launch, -Xxm100M doesn't work
> If I use run, -Xxm100M works but --working-dir doesn't work.

The run command doesn't work because 'run' is aliased to 'process launch -c /bin/bash --'

'run' is a GDB compatibility thing and people in GDB didn't have any options to "run" so any arguments that looked like options would just get passed though. "process launch" uses getopt_long() (as all command with options do) so the "process launch" command has its own options. You can terminate the options (see getopt_long man page) with "--". You will see this in _all_ LLDB commands that take options.

> 
> Is there any solution so far for this case?
> 
> Thanks,
> 
> Yin
> 
> -----Original Message-----
> From: Greg Clayton [mailto:gclayton at apple.com] 
> Sent: Wednesday, October 09, 2013 9:51 AM
> To: Yin Ma
> Cc: lldb-dev
> Subject: Re: [lldb-dev] Question on lldb commands and remote connection
> 
> 
> On Oct 9, 2013, at 8:06 AM, Yin Ma <yin at affinic.com> wrote:
> 
>> Hi
>> 
>> I cannot find the command set the working directory and
> 
> (lldb) process launch --working-dir /tmp
> 
> If you are attaching to a GDB server that already has an existing process running, your GDB server is responsible for setting the working directory prior to LLDB attaching. 
> 
> If you start GDB server with no executable, then you can use the LLDB specific packets for setting environment variables and setting the working directory, but most GDB servers don't support that. Let me know if you want to know more about that.
> 
> 
>> The command to set temporary breakpoint like tbreak in
>> Gdb.
> 
> (lldb) help tbreak 
>   Set a one shot breakpoint using a regular expression to specify the location, where <linenum> is in decimal and <address> is in hex.  This command takes 'raw' input (no need to quote stuff).
> 
> Syntax: _regexp-tbreak [<filename>:<linenum>]
> _regexp-break [<linenum>]
> _regexp-break [<address>]
> _regexp-break <...>
> 
> 'tbreak' is an abbreviation for '_regexp-tbreak'
> 
> 
>> 
>> For remote connection, I only find gdb-remote, which based
>> On manual is target remote. But I cannot find about how to
>> Use it and those matching control commands
>> target extended-remote
> 
> LLDB doesn't need to switch targets. To connect to a remote GDB server:
> 
> 1 - launch remote GDB server
> 
> remote% debugserver local:1234 -- /bin/ls -lAF
> 
> 2 - launch lldb and attach
> 
> local% lldb
> (lldb) process connect --plugin gdb-remote connect://remote:1234
> 
> The command below is equivalent to the above command:
> 
> (lldb) gdb-remote remote:1234
> 
> "gdb-remote" is just a regex alias that will run "process connect".
> 
>> disconnect
> 
> (lldb) process detach 
> 
>> monitor exit
> 
> I have no idea what this does.
> 
>> set remote exec-file
> 
> This is where you want to use the python API, but you can do this via the "script" command line command. Lets say you have a local copy of "/bin/ls" for your remote system on your current machine at "/tmp/ls". When you launch lldb you would use the local copy:
> 
> % lldb
> (lldb) target create --platform remote-macosx /tmp/ls 
> 
> When you can set the remote path:
> 
> (lldb) script exe_module = lldb.target.FindModule(lldb.SBFileSpec('/tmp/ls', false)); exe_module.SetPlatformFileSpec(lldb.SBFileSpec('/bin/ls', False))
> 
>> 
>> Could Anyone tell me what they are?
>> 
>> Thanks,
>> 
>> Yin
>> 
>> 
>> 
>> _______________________________________________
>> lldb-dev mailing list
>> lldb-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
> 




More information about the lldb-dev mailing list