Hi all,
Here is a query:
grep bar 'foo.txt' | awk '{print $3}'
The field name emitted by the 'awk' query are mangled C++ symbol names. I want to pass each to dem and finally output the output of 'dem'- i.e the demangled symbols.
Assume that the field separator is a ' ' (space).
-
How about
grep bar 'foo.txt' | awk '{ print $3 }' | xargs dem | awk '{ print $3 }'Charles Duffy : The way I read the dem man page, the symbol names should be on the command line rather than stdinDavid Zaslavsky : oops, I misread that. I edited in a call to xargs which should fix it.Johannes Schaub - litb : well, the c++ side could have spaces in them :)David Zaslavsky : darn, I was hoping that wouldn't be the case...Johannes Schaub - litb : yeah my c++filt stuff won't work with his (apparently) Sun mangling style :/. but you may lucky maybe dem doesn't put spaces into the c++ side? from what the examples show, it omits showing the return type, at least -
awkis a pattern matching language. Thegrepis totally unnecessary.awk '/bar/{print $3}' foot.txtdoes what your example does.
Edit Fixed up a bit after reading the comments on the precedeing answer (I don't know a thing about
dem...):You can make use of the
systemcall in awk with something like:awk '/bar/{cline="dem " $3; system(cline)}' foot.txtbut this would spawn an instance of
demfor each symbol processed. Very inefficient.So lets get more clever:
awk '/bar/{list = list " " $3;}END{cline="dem " list; system(cline)}' foot.txtBTW-- Untested as I don't have
demor your input.
Another thought: if you're going to use the
xargsformulation offered by other posters,cutmight well be more efficient thanawk. At that point, however, you would needgrepagain. -
This will print the demangled symbols, complete with argument lists in the case of methods:
awk '/bar/ { print $3 }' foo.txt | xargs dem | sed -e 's:.* == ::'This will print the demangled symbols, without argument lists in the case of methods:
awk '/bar/ { print $3 }' foo.txt | xargs dem | sed -e 's:.* == \([^(]*\).*:\1:'Cheers, V.
0 comments:
Post a Comment