I need a way to analyze how a line of code can be executed, but am having some difficulty. Currently, I'm doing it manually, which is a real PITA and think that an automated solution should be available. My steps as of
now are:
- Use the Call Hierarchy to determine where a function is being called from. If this is a constructor, this may not work as it doesn't seem to detect this as a function, in which case I have to find in Current
Project with Match Case, Match Whole Word, Use Regular Expressions, something like <class-name>\s+[a-zA-Z_][a-zA-Z0-9_]*|new\s+<class-name>,
which is a nuisance as I then have to filter the overloaded constructors by hand.
- Have to do a manual find in Current Project with Match Case, Match
Whole Word on<function-name> to find any messages that this can be called from if any. This more or less works and I could refine it to look for ON_MESSAGE()/ON_BN_CLICKED()/etc...
macro usage, but may miss things like ON_EVENT_RANGE()/ON_COMMAND_RANGE()/etc... However, in any of these cases, this could filter out those symbol names that are not actually the symbol names I'm looking for (i.e. not a member of the correct class) which
is bad, but let's say, 'tolerable' for the moment.
- Have to also detect if called from a Invoke(DISPID dispidMember, REFIID riid, LCID, WORD wFlags, ...) function as this is a dispatcher for a COM API and then determine what COM function was called to generate this call.
- Go to step 1 on the current function until this is determined to be recursive or there are no more ways to have this called (e.g. called from a GUI event, a COM API call, etc...).
All of this is not a trivial task, and I'm actually missing the conditionals that are in the functions to get to the line where the function call is being generated, which would be a good idea.
I'm looking for ideas as to how I can possibly implement this code path analysis tool or if one is in the works from MS? I'm thinking I might be able to do this with the help of the .pdb files, but given that I have to do a find
text instead of symbols, I'm afraid that I'm going to start something that will not pan out due to limitations of the system which I really don't have time for.
Can anyone tell me if this is the case or not and or if something is already in the works so that I don't waste my time?
My platform is Win32/64, MFC, C++ native.
Thanks,
A
p.s. if this is the wrong forum, please point me in the direction of the correct one. Thanks
I don't mind someone marking a post as "Proposed as answer", but DO NOT mark it as "Answered". If I am the OP, I will decide if a post actually answers my post or not. Thank you.