最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

fortran - GDB -var-create: unable to create variable object - Stack Overflow

programmeradmin3浏览0评论

I'm trying to debug a fortran90 application, using vscode with gdb. In one particular function:

subroutine get_hamiltonian(...)
    real :: list(:)
    ...
end subroutine get_hamiltonian

I can not print the value of variable list. Specifically, I get this error:

(gdb) list
-var-create: unable to create variable object

I have checked that list is actually correctly instantiated and I have managed to print the list too, and it works. Somehow, inside gdb, printing the value of list doesn't work. Why?

I'm trying to debug a fortran90 application, using vscode with gdb. In one particular function:

subroutine get_hamiltonian(...)
    real :: list(:)
    ...
end subroutine get_hamiltonian

I can not print the value of variable list. Specifically, I get this error:

(gdb) list
-var-create: unable to create variable object

I have checked that list is actually correctly instantiated and I have managed to print the list too, and it works. Somehow, inside gdb, printing the value of list doesn't work. Why?

Share Improve this question asked Mar 31 at 12:47 tornikeotornikeo 9678 silver badges21 bronze badges 3
  • Why not print list? – Vladimir F Героям слава Commented Mar 31 at 13:47
  • print, with or without any args also gives a '-var-create: unable...'. I assume it is also reserved in gdb. – tornikeo Commented Mar 31 at 14:00
  • If you mean print within the code, I've tried that, and it works. But debugging with GDB just makes my current task a bit easier. – tornikeo Commented Mar 31 at 14:02
Add a comment  | 

2 Answers 2

Reset to default 0

The problem is that inside GDB, keyword list is reserved. Specifically:

list linenum

    Print lines centered around line number linenum in the current source file.

So, the quickest solution to read the value of that variable is to rename it. For example, if you rename the variable list -> alist, then printing alist will work. For the purposes of debugging the application this should suffice.

Just use print to print variables using GDB. Having to rename to rename variables in your code just to be able to debug it is absurd.

(gdb) print list
$2 = (1, 2, 3, 4, 5)
发布评论

评论列表(0)

  1. 暂无评论