How to set argument -Xxm100M for an executable?

Hi

To set up a run argument, based on the document, it should be

Settings set target.run-args , like gdb set args

However, no matter how, I cannot set my argument to –Xxm100M

I tried

Settings set target.run-args –Xxm100M

Lldb: invalid option – X

I also tried

Settings set target.run-args “-Xxm100M”

Doesn’t work.

Could somebody let me know how to correctly set an argument.

On gdb, if we run

Set args

This means no argument

However, under lldb

Settings set target.run-args

It will report an error

Is this a good behavior?

Thanks,

Yin

Hi

To set up a run argument, based on the document, it should be
Settings set target.run-args , like gdb set args

However, no matter how, I cannot set my argument to –Xxm100M
I tried
Settings set target.run-args –Xxm100M
Lldb: invalid option – X

I also tried
Settings set target.run-args “-Xxm100M”
Doesn’t work.

Unfortunately you seem to be right. The only way I have been able to make this work is by saying:
(lldb) sett set target.run-args -- --Xxm100M
(lldb) r
Process 5112 launched: '/private/tmp/args' (x86_64)
argv[0] = args
argv[1] = --
argv[2] = --Xxm100M

but as you can see, this causes a spurious - - (double dash) to be passed down to your inferior process
Seems worth of a bugzilla to me. With that said, while I have not tried it, I am kinda optimistic that SBLaunchInfo (the API class) would not be subject to the same bug, since this is more of a command-line issue than anything

Could somebody let me know how to correctly set an argument.

On gdb, if we run
Set args
This means no argument
However, under lldb
Settings set target.run-args
It will report an error

Is this a good behavior?

In LLDB, you would say
(lldb) sett set target.run-args ""

Since our settings set command is meant to set any kind of setting, it makes sense that we ask for an argument. If we were to allow setting set <foo> <end of command>, we would probably need a way to know which is the “default value” for any specific setting. Feel free to file an ER bugzilla for that too

Thanks,

Yin
_______________________________________________
lldb-dev mailing list
lldb-dev@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev

Enrico Granata
:envelope_with_arrow: egranata@.com
:phone: 27683

Hi Enrico,

Since there is no way to work around –Xxm100M problem, I know we can define

our own command. I am wondering if it is possible to expend set command in llvm

by importing a python file, like set args xxx, it will call my python function

to use API to do the job? If yes, could you provide me a simple example about how

to do this?

Thanks,

Yin

Hi Yin,
the problem with your approach is that you would not simply be able to do the API equivalent of “set args” and then return.
If you are going down the SBLaunchInfo route, you will also need to launch through the API (what you do is make an SBLaunchInfo and then pass it to SBTarget::Launch, and get an SBProcess back)
Once you are in the business of launching through the API, you might also want to start listening to process events for your launched inferior
It seems like, pending a fix for the settings set bugzilla issue (thanks for filing, btw), going the API way might be your best bet, as I think others have pointed you at

A good example of how to do that is in examples/python/process_events.py, or the whole lldb-perf project if you’re more of a C++ developer

Enrico Granata
:envelope_with_arrow: egranata@.com
:phone: 27683

Hi Enrico,

This is quite complex implementation. So for this bug,

I have reported this problem in bugzilla.

I would like to know how likely or how long this bug could be fixed

and released to the public? This bug is reported by our client who is using

lldb with our GUI program. This problem is blocking his work.

I would like to know more to reply him.

Thanks,

Yin

I apologize for not being able to help here, but I am unfortunately not in the position to comment on timelines
I am sure you understand

Enrico Granata
:envelope_with_arrow: egranata@.com
:phone: 27683

As I commented in the bug:

The arguments to your process can be specified on the command line when starting lldb:

% lldb -- /private/tmp/args -Xxm100M
(lldb) run

Or your can specify them when using the "run" alias:

% lldb /private/tmp/args
(lldb) run -Xxm100M

'run' is an abbreviation for 'process launch -c /bin/bash --', so you don't need to type the "--" to terminate your arguments above. If you use the "process launch" directory you will need to add the "--" to terminate the "process launch" options:

% lldb /private/tmp/args
(lldb) process launch -- -Xxm100M

So there is a way to do this, but I agree that the "target.run-args" settings are broken for this case.