Sysprogs forums › Forums › VisualGDB › Debug view variables shows wrong on struct
- This topic has 6 replies, 2 voices, and was last updated 6 years, 3 months ago by Jensa.
-
AuthorPosts
-
August 20, 2018 at 12:31 #21722JensaParticipant
Hi,
I’ve noticed a bug in the latest build that I’m not sure was present earlier.
When you have a struct member with the same name as a local variable when you hoover over the struct member while debugging you’ll see the value of the local variable instead of the struct member.
I was going crazy with my debugging until I realized it showed wrong that 🙂See attached picture while hoovering over the ‘var’ member of test_struct.
Attachments:
You must be logged in to view attached files.August 20, 2018 at 17:23 #21726supportKeymasterHi,
Normally this is something handled by the toolchain/gdb. Could you please double-check that running the “print test_struct.var” command in the gdb session shows the same wrong output? If yes, please check if your code is built without optimization. Debugging optimized code is always inaccurate as gcc often eliminates unused variables and reuses fragments of the code.
August 22, 2018 at 11:48 #21737JensaParticipantHi,
The “print test_struct.var” command does print the correct output of the test_struct.var member and not the local var variable:
&"print test_struct.var\n" $1 = 22
The GUI does still however show the local var variable value when you hover over the ‘.var’ member. When you hoover over the test_struct variable though it shows the correct value of the var member and also the ‘Autos’ and ‘Locals’ windows shows it correct. It’s just that when you hoover over the “var” part of the “test_struct.var” code that it shows wrong. It also as you can see shows the variable name as “var” only and not “test_struct.var” which it usually does when it shows the correct struct member value.
Optimization is set to “Disabled (-O0)”. I haven’t done any changes from the default project template for a linux application and run the Debug configuration of that.
August 22, 2018 at 18:29 #21741supportKeymasterHi,
Thanks for checking this. If the “print” command works, this is likely an issue between VisualGDB and gdb, so we should be able to fix it easily.
Please create a diagnostic gdb log showing the incorrect value obtained via the “watch” window and the correct value for the same variable obtained via the “print” command and we should be able to see what is going on.
August 23, 2018 at 14:19 #21746JensaParticipantHi,
The “Watch” window shows the correct value as well. I think the issue is that when you hoover over the “var” part of “test_struct.var” it doesn’t recognize it as a member of the test_struct struct but just shows the local variable “var” instead.
I changed the code a bit to show more clearly what I mean. When I hoover over the “no_var” part of “test_struct.no_var” member the popup window shows “test_struct.no_var | 0x0000016”. But when I hoover over the “var” part of “test_struct.var” it just shows “var | 0x0000000a”. No “test_struct.” before “var”.
New code:
#include <iostream> using namespace std; typedef struct { int var; int no_var; } TestStruct; TestStruct foo( int var ) { TestStruct test_struct; test_struct.var = 22; test_struct.no_var = 22; test_struct.var = var; test_struct.no_var = var; return test_struct; } int main( int argc, char * argv[] ) { TestStruct test_struct = foo( 10 ); return 0; }
Attachments:
You must be logged in to view attached files.August 25, 2018 at 05:29 #21765supportKeymasterHi,
Thanks for narrowing it down. It looks like a combination of our language service and the debug engine was indeed causing a rather strange race condition inside the VS editor, that resulted in evaluating the incorrect expression.
We have changed the expression finding logic in a way that no longer triggers the problem in this build: http://sysprogs.com/files/tmp/VisualGDB-5.4.4.2406.msi
August 27, 2018 at 08:44 #21783JensaParticipantHi,
That did indeed solve it.
Thanks!
-
AuthorPosts
- You must be logged in to reply to this topic.