DilithiumMatrix
DilithiumMatrix

Reputation: 18657

no symbol in current context for global variable (or macro)

I'm new to GDB, and I'm stepping through a function causing me trouble. I'm trying to print the value of a global variable (which determines control flow) but I'm getting no symbol in current context. I don't know where the symbol is defined, but shouldn't it be present here?

The block I'm looking at:

if (present(weights)) then
      numWeights = size(weights,1)
>     if (numWeights == NSPECIES) then
         weightsFull = weights
      else
         weightsFull = weights(1)
      endif
else
      weightsFull = 1.0
endif

And I'm trying to get the value of NSPECIES

Upvotes: 2

Views: 3115

Answers (2)

borizzzzz
borizzzzz

Reputation: 620

If NSPECIES exists within a namespace, you would need to call

(gdb) p '<namespace>::NSPECIES'

to view it. You can check by calling

(gdb) info variables

which lists all the variables defined in the current context. If you want to check the existence of NSPECIES specifically, you can even call

(gdb) info variables NSPECIES

which will list all defined variables matching that name.

Hope it helps.

Upvotes: 1

Andrew
Andrew

Reputation: 4781

Is it possible that NSPECIES is a macro rather than a variable? If it is then you will need to compile your program with -g3 in order to get the macro information included in the binary.

Upvotes: 3

Related Questions