i want to print the variables that are used in my C code .Its a 19KB file,so lot of variables are used in it.
我想打印我的C代码中使用的变量。它是一个19KB的文件,因此使用了很多变量。
i know its not so easy..b'z we donno whre my compiler puts this details..(debug info?..)
我知道它不那么容易..我们不知道我的编译器放了这个细节..(调试信息?..)
i am working in gcc ( Redhat (shrike))..
我在gcc工作(Redhat(shrike))..
Renjith G
5 个解决方案
#1
Run ctags on your sources, then read the output tags file.
在源上运行ctags,然后读取输出标记文件。
This will be a list of all visible identifiers (and possibly static ones too, depending on ctags options), the files they are defined in, and the location within the file.
这将是所有可见标识符的列表(也可能是静态标识符,具体取决于ctags选项),定义它们的文件以及文件中的位置。
This does not index local variables.
这不会索引局部变量。
#2
Maybe you mean something like the linux nm command, which lists symbols from an object file.
也许你的意思是linux nm命令,它列出了目标文件中的符号。
#3
You could run a regex similar to this on the source code:
您可以在源代码上运行与此类似的正则表达式:
(const *)? *(int|double|float|char) *(const *)? *(\* *)*(const *)? *;
Won't catch user defined types but if its a short enough code, you could add the relevant types manually.
不会捕获用户定义的类型,但如果它的代码足够短,您可以手动添加相关类型。
Edit: forgot the ; at the end
编辑:忘了;在末尾
#4
You could compile and check in the executable. check the file-type, if it is elf, then you can use "readelf --symbols --wide myfile" and grep for OBJECT.
您可以编译并签入可执行文件。检查文件类型,如果它是elf,那么你可以使用“readelf --symbols --wide myfile”和grep for OBJECT。
#5
You could use the Print button on the keyboard.Make sure you have the printer connected.
您可以使用键盘上的“打印”按钮。确保已连接打印机。
#1
Run ctags on your sources, then read the output tags file.
在源上运行ctags,然后读取输出标记文件。
This will be a list of all visible identifiers (and possibly static ones too, depending on ctags options), the files they are defined in, and the location within the file.
这将是所有可见标识符的列表(也可能是静态标识符,具体取决于ctags选项),定义它们的文件以及文件中的位置。
This does not index local variables.
这不会索引局部变量。
#2
Maybe you mean something like the linux nm command, which lists symbols from an object file.
也许你的意思是linux nm命令,它列出了目标文件中的符号。
#3
You could run a regex similar to this on the source code:
您可以在源代码上运行与此类似的正则表达式:
(const *)? *(int|double|float|char) *(const *)? *(\* *)*(const *)? *;
Won't catch user defined types but if its a short enough code, you could add the relevant types manually.
不会捕获用户定义的类型,但如果它的代码足够短,您可以手动添加相关类型。
Edit: forgot the ; at the end
编辑:忘了;在末尾
#4
You could compile and check in the executable. check the file-type, if it is elf, then you can use "readelf --symbols --wide myfile" and grep for OBJECT.
您可以编译并签入可执行文件。检查文件类型,如果它是elf,那么你可以使用“readelf --symbols --wide myfile”和grep for OBJECT。
#5
You could use the Print button on the keyboard.Make sure you have the printer connected.
您可以使用键盘上的“打印”按钮。确保已连接打印机。