[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature request: open file before running poke script

From: Mohammad-Reza Nabipoor
Subject: Re: Feature request: open file before running poke script
Date: Sat, 6 Feb 2021 09:32:24 +0330

Hi, David.

On Fri, Feb 05, 2021 at 12:16:33PM -0800, David Faust wrote:
> As a motivating use case, I currently have a small poke script which
> collects BTF information in a file, and displays portions of it. But
> right now, I need to hardcode the filename (foo.o) into the script.
> Otherwise, the following happens:
>   $ poke -s myscript foo.o
>   unhandled no IOS exception
>   $ poke foo.o --script=myscript
>   unhandled no IOS exception
> With this improvement, it would be much easier to rapidly check multiple
> test cases:
>   $ poke -s myscript foo.o
>   (dump of relevant information in foo.o)
>   $ poke -s myscript bar.o
>   (dump of relevant information in bar.o)
>   ...
> Or maybe there is an existing way to do this, in which case the
> documentation around poke script usage could perhaps be improved?

You can use `-L` option (Section 1.4.5 of info documentation ("Scripts")).
Poke will send the list of command line arguments as an array of strings
called `argv`.

An example script (called `util-script.pk`):

#!/usr/bin/poke -L

for (arg in argv)
  printf ("Argument: %s\n", arg);

You can run this script either by

    $ poke -L util-script.pk A B C


    $ ./util-script.pk A B C

An example of such utility script is `utils/pk-elfextractor.in` file in
poke repo.

And if you need option/argument handling you can use the `argp` pickle (Section
9.1 of documentation ("argp")).

BTW patches are welcome :)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]