This question feels silly, but it really puzzles me. When I look at the source code of gem5, I always come across classes like typedef typename CPUPol::IQ IQ;
typedef typename Impl::DynInstPtr DynInstPtr;
. I want to see what functions are in these classes. But in vscode, I cannot jump to where they are defined. I can't even search for them. I also didn't find some files having similiar names with the class names.
In gem5, how do I know the specific location of the class?
198 views Asked by Gerrie At
1
gem5 uses in some points this horrible impl template pattern instead of virtual methods. Someone explained it to me why but I forgot.
Then IDEs such as Eclipse which I've tested with are not able to resolve "a list of templates used", here's a minimal test for that.
In the specific case of
typedef typename Impl::DynInstPtr DynInstPtr
I managed to find the definition as follows in Eclipse. This would likely also work on vscode.Start from one of the typedefs e.g.:
Search for usages of
BaseDynInst
(Ctrl + Alt + G). The first usage luckily is:which is an explicit template instantiation.
So now I just jump to the definition of
O3CPUImpl
and there it is:So yes, in this case I got lucky. If there was no explicit instantiation done, I would have had to search for all usages of the constructor that built the object to find what type was being set on the template.
Also, with the hindsight of the result, we could have noticed earlier that when searching for the definition of
DynInstPtr
(Ctrl + Shift + T), any results in a class named*Impl
would be the interesting ones, due to the gem5 naming pattern used.Finally, another guerrilla technique you could use you be to just:
which points us to
O3CPUImpl
with several entries of type:Some of this had been briefly mentioned here.
Tested on gem5 0d5a80cb469f515b95e03f23ddaf70c9fd2ecbf2.