[PATCH] run.py: allow multiple arguments to --trace

0 views
Skip to first unread message

Tomasz Grabiec

unread,
Mar 24, 2014, 11:09:17 AM3/24/14
to osv...@googlegroups.com
Currently --trace may only be used with one tracepoint, this
change allows to pass multiple like this:

scripts/run.py --trace trace_point1* trace_point2*

Signed-off-by: Tomasz Grabiec <tgra...@cloudius-systems.com>
---
scripts/run.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/run.py b/scripts/run.py
index c6a40e0..718fc70 100755
--- a/scripts/run.py
+++ b/scripts/run.py
@@ -55,7 +55,7 @@ def set_imgargs(options):
execute = execute.replace('java.so', 'java.so ' + debug_options)

if options.trace:
- execute = '--trace=%s %s' % (options.trace, execute)
+ execute = ' '.join('--trace=%s' % name for name in options.trace) + ' ' + execute

if options.trace_backtrace:
execute = '--trace-backtrace ' + execute
@@ -354,8 +354,8 @@ if (__name__ == "__main__"):
help = "redirect the API port (8000) for user-mode networking")
parser.add_argument("--pass-args", action="append",
help = "pass arguments to underlying hypervisor (e.g. qemu)")
- parser.add_argument("--trace", action="store",
- help="enable tracepoint")
+ parser.add_argument("--trace", nargs='*',
+ help="enable tracepoints")
parser.add_argument("--trace-backtrace", action="store_true",
help="enable collecting of backtrace at tracepoints")
cmdargs = parser.parse_args()
--
1.8.3.2

Nadav Har'El

unread,
Mar 24, 2014, 5:08:16 PM3/24/14
to Tomasz Grabiec, Osv Dev
On Mon, Mar 24, 2014 at 5:09 PM, Tomasz Grabiec <tgra...@cloudius-systems.com> wrote:
Currently --trace may only be used with one tracepoint,

Actually, you can use a comma or a space -

        scripts/run.py --trace trace_point1*,trace_point2*

or
        scripts/run.py --trace "trace_point1* tracepoint2*"

(see the boost::split() call in loader.cc).


 
this
change allows to pass multiple like this:

 scripts/run.py --trace trace_point1* trace_point2*

What I really don't like about Python's argument parser is how non-traditionally it behaves. The behavior you describe makes sense, if you are used to it, but people used to the hundreds of other existing Linux commands will not be used to it - they will be surprised that the "trace_point2*" argument is also part of --trace, and not a separate argument. I can't think of any other Linux utility that behaves this way (maybe I'm just not thinking hard enough).

I guess I should be happy that the python guys at least respected the tradition of starting options with "-", and didn't decide to go with "/" like in MS-DOS ;-)
 
--
1.8.3.2

--
You received this message because you are subscribed to the Google Groups "OSv Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages