I was wondering if someone here had written/uses a script which parses the output of objdump and extracts opcodes from it? I have a very very trivial implementation but I'm looking for something better.
The problem I am facing with this script is simply that it does simple string parsing; this is more of a utility script, and thats why I haven't written tests for these. I was wondering if the same could be done by writing a custom made parser or a simple yet efficient regular expression.
This query is for the purpose of learning, so that I can approach such a problem in a (hopefully)better manner next time.
I don't mind the specifics of the implementation(shell,ruby,python,perl; anything would do). The code does not even matter that much, really, I'd like a few hints on how you would do it.
The BEST solution would be to build objdump from source and make a python or other language swig wrapper that gets the output directly.  You CAN do it with string parsing, but that's often buggy(read as implemented poorly).  It is definitely possible to do the string parsing properly...I have a utility that relies on this.
parsing objdump output