2

I want to use some intrinsic functions and matrix operations in debugging, but failed. It looks like this:

(gdb) p tau
$12 = (( 0, 0, 0) ( -0.23499999999999999, 0.23499999999999999, 0.25) )
(gdb) p alat
$13 = 10.2631
(gdb) p tau * alat
Argument to arithmetic operation not a number or boolean.
(gdb) p tau + 1.0
Argument to arithmetic operation not a number or boolean.
(gdb) p SUM(tau)
No symbol "SUM" in current context.

According to this post it seems there is no general way to use intrinsic functions, but there may be hacks for some specific ones.

Any suggestions on how to use SUM or do matrix operations in Fortran way? Many thanks.

Ian Bush
  • 6,996
  • 1
  • 21
  • 27
zhu
  • 21
  • 4
  • 2
    You already have the answer in the post you a referring to: use `nm` to find the symbols in your executable. If a symbol does not exist, how do you think gdb is going to find it? –  Sep 07 '21 at 06:35
  • `sizeof` is also not in `nm` output, but I can use it. There're only symbols like "_gfortran_size0@@GFORTRAN_8". Maybe I can have a look at the naming rules of gfortran, but even then there are possibilities that maybe symbols with another name, like "add" or something, exist for that purpose. Besides, this only answers the first question. The second question, how to automatically broadcast operators like "+" when needed (as in Fortran), is not touched in that post. Maybe gdb is mainly written for C/C++ and does not fully support Fortran syntax, but I'm not sure and an answer is appreciated. – zhu Sep 07 '21 at 09:27
  • `sizeof` is a gdb extension, see [this](https://stackoverflow.com/questions/28982534/gdb-size-of-a-struct-that-isnt-in-context). It's of course not a symbol in your executable. But you don't expect gdb to know Fortran 90 intrinsics, do you? Compile with `-g` and check again with `nm`. `SUM` is probably inlined anyway, but you may get something useful to you. And yes, gfortran internal symbols may have a surprising name. –  Sep 07 '21 at 09:32
  • Thanks for the explanation. As for the second question, I found [this post](https://stackoverflow.com/questions/26970617/gdb-will-not-perform-binary-operation/27542754#27542754) and it seems that it might be a gdb limitation. – zhu Sep 07 '21 at 09:53

0 Answers0