T O P I C R E V I E W |
mvolkar |
Posted - Mar 20 2024 : 08:27:00 AM We recently upgraded from using Visual Studio 2019 to 2022 and at the same time started using the latest version of Visual Assist (I am currently using version 10.9.2511). Unfortunately, we have noticed situations where the Find References feature is not returning all references, and have started to lose faith in the tool. This is not a problem that we had in the older versions.
I don't think it is realistic to try to come up with a simple reproducible case, and our code base is somewhat complex, so I'm hoping that someone can suggest some troubleshooting steps. In the particular situation I ran into this morning, the Visual Studio Find All References feature seemed to return all of the results I would expect to see.
Any help you can provide would be appreciated. |
15 L A T E S T R E P L I E S (Newest First) |
feline |
Posted - Jun 13 2024 : 09:52:55 AM Can you find some examples in your code base where Find References always fails, and some where it works? If so, we can work from here. |
virtuousden |
Posted - Jun 13 2024 : 04:47:17 AM quote: Originally posted by mariahcarey
quote: Originally posted by mvolkar
Using the same field of the same struct as my screenshot from yesterday, I looked at the Context/Definition bar at the top of the editor window. Interestingly, it shows the wrong thing (the class data member of the same name):
If I do an Alt-G, it then (logically) takes me to the wrong definition.
At some point yesterday, I had considered if this might simply be another instance of the bug I reported in https://forums.wholetomato.com/forum/topic.asp?TOPIC_ID=14008 https://flappy-bird.co back in 2017, but the struct in question is using the "tag workaround" you had proposed there.
For the sake of this investigation, if I rename the symbol to something that doesn't have the same name, then Find References seems to work as expected. Interestingly, even in this case (i.e., with the renamed symbol), the Context and Definition bars are blank as you guessed, so maybe that is still a clue.
I will say, however, that I don't think every instance of missing results that I've seen has been due to conflicting names. I'll try to find a different/better example, but I've also see the results be inconsistent.
Attempt to reproduce the issue with different code constructs or scenarios in your codebase. While it may not always be possible to create a simple reproducible case, identifying specific patterns or scenarios where Find References fails to return expected results can help narrow down the problem.
How can you easily identify specific patterns or situations where Find References that do not return expected results can help narrow down the problem? |
feline |
Posted - Apr 02 2024 : 08:54:18 AM Do you use partial template specialization in your code? In the example where I have been able to reproduce the problem, the following code concept is being used:
template<bool T>
class templateShowingSpecializationSpecificMembers
{
private:
short m_nUnspecializedMember;
};
template<>
class templateShowingSpecializationSpecificMembers<true>
{
private:
short m_nTrueSpecializedMember;
public:
short GetTrueHeight() { return 12; }
short GetTrueDepth() { return 21; }
}; I had no idea you could have different class members for the same class, depending on the template specialization, but the code compiles quite happily. This seems to be a factor in the Find References problem, since sometimes VA is getting confused here. |
mariahcarey |
Posted - Mar 31 2024 : 11:39:57 PM quote: Originally posted by mvolkar
Using the same field of the same struct as my screenshot from yesterday, I looked at the Context/Definition bar at the top of the editor window. Interestingly, it shows the wrong thing (the class data member of the same name):
If I do an Alt-G, it then (logically) takes me to the wrong definition.
At some point yesterday, I had considered if this might simply be another instance of the bug I reported in https://forums.wholetomato.com/forum/topic.asp?TOPIC_ID=14008 https://wordlewebsite.com back in 2017, but the struct in question is using the "tag workaround" you had proposed there.
For the sake of this investigation, if I rename the symbol to something that doesn't have the same name, then Find References seems to work as expected. Interestingly, even in this case (i.e., with the renamed symbol), the Context and Definition bars are blank as you guessed, so maybe that is still a clue.
I will say, however, that I don't think every instance of missing results that I've seen has been due to conflicting names. I'll try to find a different/better example, but I've also see the results be inconsistent.
Attempt to reproduce the issue with different code constructs or scenarios in your codebase. While it may not always be possible to create a simple reproducible case, identifying specific patterns or scenarios where Find References fails to return expected results can help narrow down the problem. |
feline |
Posted - Mar 22 2024 : 07:31:26 AM I have the test files, many thanks for these:
case=164351
I have replied via email to avoid splitting the conversation into two places. |
feline |
Posted - Mar 22 2024 : 05:46:21 AM Of course, if you have anything you feel it is acceptable to share ONLY with us, which will be used ONLY for debugging this problem, please send me the files via email:
[email protected]
including this thread ID or URL in the description, so we can match it up. The first thing I will do, after confirming I can reproduce the problem, will be to try and simplify the problem right down, so deleting as much of your code as possible, never to be seen again. |
mvolkar |
Posted - Mar 21 2024 : 3:17:16 PM Since this problem is happening on one fairly isolated C++ file, I'm going to see if I can reproduce it in a dummy project with basically only that file. If I can do so, is there a way I can send you this project, which will contain one small part of our code? Although it's probably not that interesting, I don't want to post it in a public forum. |
feline |
Posted - Mar 21 2024 : 1:58:12 PM Simplifying this right down, probably far to far, I have this in a header file:
typedef struct Registers_tag
{
uint32_t cosGainFoo;
} Registers_t; and this in the matching cpp file:
void testingArrayAccessOnPointer()
{
Registers_t volatile *fpgaRegisters;
fpgaRegisters[0].cosGainFoo = 1;
} and everything is working just fine for me here. Which is reassuring, since while array access on a pointer is probably a "bad" thing if you are reckless, I suspect it is also done a lot, for plenty of good reasons. So if we simply don't handle that at all we are going to have a lot of problems.
If you copy the access line and place it at the top of the class member function, does that make any difference? I am trying to work out if the reasonable looking like using "cosGainFoo" is the problem, or if the problem is coming from something else that is going on here in the same function or file.
Does Alt-G take you to the correct location when used on "fpgaRegisters"?
Am I reading this right, that you are working with a 2 component template class? |
mvolkar |
Posted - Mar 21 2024 : 1:27:20 PM I think you may be on to something here. Continuing with the renamed field just to eliminate the duplication for a moment, here is the situation I have in the class definition (code simplified for the sake of brevity):
typedef struct Registers_tag
{
...
uint32_t cosGainFoo;
...
} Registers_t;
Registers_t volatile *fpgaRegisters;
Then, the only usage of cosGainFoo looks like this: this->fpgaRegisters[encoderChannel].cosGainFoo
We're doing something that is perhaps a bit unorthodox here and indexing a pointer as if it was an array. Perhaps that is confusing Visual Assist's parsing here. When I click on fpgaRegisters, the Context/Definition does show my the correct thing, however:
|
feline |
Posted - Mar 21 2024 : 1:15:37 PM Starting from this point, where the "cogGain" is getting the wrong context and definition information, what about the symbol before the dot?
To try and explain what I am getting at, consider the following, deliberately INVALID code:
struct CorrectContainer
{
int cosGain;
};
struct WrongContainer
{
int cosGain;
};
void TestingFindRefOnCosGain(void *pUnknownType)
{
pUnknownType->cosGain;
} Place the caret into the last "cosGain" in this code snippet, and the context and definition fields are blank. But place them into "pUnknownType" and they have a value.
In your code, does VA have the correct type for the symbol before the dot? Or is that also wrong? I am guessing that somehow VA has the wrong type for "pUnknownType", but thinks that the wrong type is a type that happens to contain a "cosGain" member, which is why this "cosGain" isn't showing up as an unknown reference. |
mvolkar |
Posted - Mar 21 2024 : 12:49:58 PM Using the same field of the same struct as my screenshot from yesterday, I looked at the Context/Definition bar at the top of the editor window. Interestingly, it shows the wrong thing (the class data member of the same name):
If I do an Alt-G, it then (logically) takes me to the wrong definition.
At some point yesterday, I had considered if this might simply be another instance of the bug I reported in https://forums.wholetomato.com/forum/topic.asp?TOPIC_ID=14008 back in 2017, but the struct in question is using the "tag workaround" you had proposed there.
For the sake of this investigation, if I rename the symbol to something that doesn't have the same name, then Find References seems to work as expected. Interestingly, even in this case (i.e., with the renamed symbol), the Context and Definition bars are blank as you guessed, so maybe that is still a clue.
I will say, however, that I don't think every instance of missing results that I've seen has been due to conflicting names. I'll try to find a different/better example, but I've also see the results be inconsistent. |
feline |
Posted - Mar 21 2024 : 08:14:25 AM Can both of you please find a place or two where the symbol is being used, but not found, and then place the keyboard caret into the symbol. What, if anything, is shown in VA's context and definition fields? These are normally shown at the top of the editor window, and are where the Alt-M list appears from.
My first guess is that the context and definition fields will be blank, which happens when our parser doesn't understand the code well enough to display anything there. But if that was the case, I would expect there to be unknown/guess hits coming up, so VA might be displaying the wrong information there.
What, if anything, does Alt-G do on this not found symbol instance?
What, if anything, does triggering Find References on this not found symbol instance do?
Basically we need to find and study some examples to get some idea of what is going wrong here. Clearly its a bug, possibly even a regression, but I need to be able to reproduce something here ideally to try and help fix the problem, or at least get a bug report in.
If I can prove its a regression, and find out when it broke, that will help, and also make this a more urgent bug report. |
shippy |
Posted - Mar 20 2024 : 1:30:00 PM I'm hitting this same issue. If I use VA's Find References (Ctrl+Alt+F) on a method, then it is finding the .h declaration and .cpp implementation, but not uses of the method. It's not true for every case, but it was enough to get me to start noticing something was off and hit up the forums. If I use VS's version of Find All References (Shift+F12) it finds it all just fine. I do not see any "Display unknown/guess hits" option for VA find references, either.
VA_X64.dll file version 10.9.2511.0 built 2024.01.23 DevEnv.exe version 17.9.34701.34 Enterprise msenv.dll version 17.0.34701.34
|
mvolkar |
Posted - Mar 20 2024 : 11:44:30 AM The reproducible case I had earlier this morning is no longer reproducible, but I found another instance. Anecdotally, the problem seems to occur most often with members of structs or unions, but I can't say it's never happened in other situations.
In this case, I am trying to find a field in a struct. Starting from the definition, Find Reference returns only one result, which is the in the struct definition. When I right-click the results, I don't even have an option to "Display unknown/guess hits". I have attached a screenshot:
When I navigate to one of the missing references (found via Find in Files) and perform a Find References, more results are shown. Unfortunately, in this case we have a class data member with the same name as the field in the struct (also used in the same class) and so both results are being shown. This is different than the missing references, but equally wrong, because these are two different things. |
feline |
Posted - Mar 20 2024 : 10:54:16 AM Can you please try right clicking in the Find References Results list, and turn On:
Display unknown/guess hits (G)
what effect, if any, does this have on the problem?
If you find one of the missing results, can you trigger Find References on this missing result? If not, that will tell us that our parser isn't properly understanding the code. If we can find specific examples where our parser is confused, hopefully we can study them and work out what is going wrong, especially if this is a regression in VA. |
|
|