How to use tokenize

Frank Ch. Eigler fche@redhat.com
Sat Oct 6 02:20:00 GMT 2012


Hi -

domenico.dileo@unina.it writes:

> [...]
> 		printf("%s \n", probefunc())
> 		while(strlen(address = tokenize(trace," ")) != 0){
> 		     printf("%s  \n", address)
> [...]
> The output is something like
> dnotify
> 0xc011698
> 0xc011698
> [...]
> It seems that the script gets stuck in the while loop.

Yes.  This would work better:

> 		address = tokenize(trace," ")
> 		while(address != "") {
> 		     printf("%s  \n", address)
> 		     address = tokenize(""," ")
> 		}

Note how, within the loop, the first parameter of tokenize() is empty,
so as to resume the previously started tokenization.  (This is hack to
work around the systemtap language's inability to treat an entire
array as a function return value.)



> I know that in stap there are function like "print_stack",
> I don't need them because I have to submit the stack
> trace to other elaborations.

You may like the new backtrace-enumeration functions smakarov 
added in time for systemtap 2.0.  They should make this tokenize
business purely historical.

- FChE



More information about the Systemtap mailing list