gdb debugger Error : "-var-create: Unable to create variable object" - c

I am Using Netbeans with C/C++ Plugin on Windows 7 x86 System. I am getting Error when debugging the code. But when I run the code, it runs with out any problem.. As soon as I start debugging the code, it stops at 2-3 Lines before "main()" application.. And getting debugger error as follow :
(gdb)
17^error,msg="-var-create: unable to create variable object"
(gdb)
18^done,changelist=[]
(gdb)
19^error,msg="-var-create: unable to create variable object"
(gdb)
20^done,changelist=[]
(gdb)
21^done,name="var3",numchild="4",value="{...}",type="const MyVar",has_more="0"
(gdb)
24-var-show-attributes "var3"
.
.
.
.
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
I will appreciate any suggestion.

Looks like its a bug in netbeans.
http://netbeans.org/bugzilla/show_bug.cgi?id=205708
Try other versions.(Whats the version you are using,Can you please update it , it will be useful for others). Thanks

Related

Debugging C: GDB returns "address where <file> has been loaded is missing"

I'm very new to the C language and have been tasked with modifying GRUB. What a way to learn, right? Anyway, I'm trying to debug my modified GRUB using VMWare and GDB. I've been able to get the debugger working before, but for some reason, every time I load up my VM and connect GDB, during the loading process of GRUB, I get:
.loadsym.gdb:1: Error in sourced command file:
The address where biosdisk.module has been loaded is missing
and I have no idea what to do about it. My first thought was, "Oh, I'll just add-symbol-file <file> and that'll fix it!" but apparently that tells GDB to forget every other symbol it loaded???? So I can't add the symbol-file and set a breakpoint.
My googling only returns one semi-relevant post that doesn't really go all that in-depth on fixing the issue.
This output may also be relevant.
info file biosdisk.module
Symbols from "H:\Workspace\GRUB\Bootloader\Trunk\grub-core\kernel.exec".
Remote serial target in gdb-specific protocol:
Debugging a target over a serial line.
While running this, GDB does not access memory from...
Local exec file:
`H:\Workspace\GRUB\Bootloader\Trunk\grub-core\kernel.exec', file type elf32-i386.
Entry point: 0x9000
0x00009000 - 0x0000e6e0 is .text
0x0000e6e0 - 0x0000f68d is .rodata
0x0000f6a0 - 0x0000fe74 is .data
0x0000fe80 - 0x000175d4 is .bss
Ended up being that my codebase wasn't the same. That is, on my Windows host, I had one copy of my code and on my Ubuntu VM was another.
Using version control solved this issue.

Gdb doesn't "see" breakpoint i have put, so it runs through whole program

I am following tutorial from yt, by Liveoverflow.
So point is that i should disassemble a program, but I couldn't successfully stop it at breaking point i made so it run the whole code.
I have done exact same steps as shown in the video but i got different results...
I have searched the Web but i couldn't find the solution. I have only tried typing instead of break, b and instead of *main, 1 (as first line of code) but none of that worked.
(gdb) break *main
Breakpoint 1 at 0x4005bd
(gdb) run
Starting program: /home/spida/Documents/Hacking/license_1
/bin/bash: /home/spida/Documents/Hacking/license_1: Permission denied
/bin/bash: line 0: exec: /home/spida/Documents/Hacking/license_1: cannot execute: Permission denied
During startup program exited with code 126.
(gdb)
Also at the video program stops running at the breakpoint so he could see registers info, for me registers were empty.
So sorry for English

SNMP subagent application crashes at init_agent()

I have implemented SNMP subagent functionality in my application using net-snmp library (http://www.net-snmp.org/tutorial/tutorial-5/toolkit/demon/).
The application crashes at init_agent() call.
GDB-BackTrace for the same:
#0 0x00002b123483aaa1 in init_traps () from /usr/lib64/libnetsnmpagent.so.10
#1 0x00002b1234835cd0 in init_agent () from /usr/lib64/libnetsnmpagent.so.10
...
The error message at "/var/log/messages":
sample_app.exe[6642]: segfault at 0000000000659de0 rip 00002ac2749c2aa1 rsp 00007fff38c6ec48 error 7
I am using "NET-SNMP version: 5.3.2.2" on CentOS 5.5(elf5) 64Bit. The sample_app code is same as provided in tutorial(http://www.net-snmp.org/tutorial/tutorial-5/toolkit/demon/example-demon.c)
The init_agent() is supposed to take config file name as argument, I have tried passing config file name which has 'correct configuration'/'incorrect configuration'/'file not present', In each case the application crashes with same error.
Please suggest any tools/links which will help me identify the actual cause of the crash. Any link for resolution of similar issue will also be helpful.
Thanks
Edit-
The issue has been resolved. The variable 'snmptrap_oid_len' was being declared/used in application's MIB C code, which is already part of net-snmp library 'agent_trap.c'. This was causing the conflict and hence crash.
PS: If you face similar issue, ensure that variables 'snmptrap_oid' and 'snmptrap_oid_len' are 'not redeclared'/'used correctly' in MIB C code.

linker issue or other? dynamically loaded lib

My program loads a dynamic library, but after it tries to load it (it doesn't seem to, or at least something's amiss with the loading. A free() throws an error, and I commented out that line.)
I get the following in gdb.
Program received signal SIGSEGV, Segmentation fault.
__strlen_ia32 () at ../sysdeps/i386/i686/multiarch/../../i586/strlen.S:99
99 ../sysdeps/i386/i686/multiarch/../../i586/strlen.S: No such file or directory.
in ../sysdeps/i386/i686/multiarch/../../i586/strlen.S
How would I go about addressing this?
EDIT1:
The above issue was due to me not having an xml file where it should have been.
Here's the first error that I covered up to get to the initial error I showed.
(gdb) s
__dlopen (file=0xbfffd03c "/usr/lib/libvisual-0.5/actor/actor_AVS.so", mode=1)
at dlopen.c:76
76 dlopen.c: No such file or directory.
in dlopen.c
(gdb) bt
#0 __dlopen (file=0xbfffd03c "/usr/lib/libvisual-0.5/actor/actor_AVS.so",
mode=1) at dlopen.c:76
#1 0xb7f8680d in visual_plugin_get_references (
pluginpath=0xbfffd03c "/usr/lib/libvisual-0.5/actor/actor_AVS.so",
count=0xbfffd020) at lv_plugin.c:834
#2 0xb7f86168 in plugin_add_dir_to_list (list=0x804e428,
dir=0x804e288 "/usr/lib/libvisual-0.5/actor") at lv_plugin.c:609
#3 0xb7f86b2b in visual_plugin_get_list (paths=0x804e3d8,
ignore_non_existing=1) at lv_plugin.c:943
#4 0xb7f9c5db in visual_init (argc=0xbffff170, argv=0xbffff174)
at lv_libvisual.c:370
#5 0x080494b7 in main (argc=2, argv=0xbffff204) at client.c:32
(gdb) quit
A debugging session is active.
Inferior 1 [process 3704] will be killed.
Quit anyway? (y or n) y
starlon#lyrical:client$ ls /usr/lib/libvisual-0.5/actor/actor_AVS.so
/usr/lib/libvisual-0.5/actor/actor_AVS.so
starlon#lyrical:client$
The file exists. Not sure what's up. Not sure what code to provide either.
Edit2: More info on the file. Permissions are ok.
816K -rwxr-xr-x 1 root root 814K 2011-11-08 15:06 /usr/lib/libvisual-0.5/actor/actor_AVS.so
You didn't tell what dynamic library it is.
If it is a free dynamic library -or a library whose source is accessible to you- you can compile it and use it with debugging enabled.
Several Linux distributions -notably Debian & Ubuntu- provide debugging variant of many libraries (e.g. GLibc, GTK, Qt, etc...), so you don't need to rebuild them. For example, Debian has libgtk-3-0 package (the binary libraries mostly), libgtk-3-dev the development files for it (headers, etc...) and libgtk-3-0-dbg (the debugging variant of the library). You need to set LD_LIBRARY_PATH appropriately to use it (since it is in /usr/lib/debug/usr/lib/libgdk-3.so.0.200.1).
Sometimes, using the debugging variants of system libraries help you to find bugs in your own code. (Of course, you also need to compile with -g -Wall your own code)
Turned out this was due to a faulty hard drive. Looks like I need a new one.

Getting error while debugging a C program in gdb mode

When I tried to run binary in gdb mode I am getting the below mentioned error message .Please find the error message in the attachment
(gdb) r /devl/aaa/BINARY/pfm.sql_Kavitha /devl/aaa/AVP/OCT_TEST /devl/aaa/ASAPDATA/READONLY /devl/aaa/ASAPDATA/READONLY 17 kk12345
Starting program: /devl/aaa/BINARY/pfm.sql_Kavitha /devl/aaa/AVP/OCT_TEST /devl/aaa/ASAPDATA/READONLY /devl/aaa/ASAPDATA/READONLY 17 kk12345
**No executable file specified.
Use the "file" or "exec-file" command.**
Please let me know if anybody knows how to resolve this issue.
thanks
Invoke gdb as:
gdb /devl/aaa/BINARY/pfm.sql_Kavitha
and then run the program from within gdb as:
(gdb) r /devl/aaa/BINARY/pfm.sql_Kavitha /devl/aaa/AVP/OCT_TEST /devl/aaa/ASAPDATA/READONLY /devl/aaa/ASAPDATA/READONLY 17 kk12345
(gdb) above is the prompt.
If you want to be able to specify the program to execute from within gdb, use file command, as the error message says:
(gdb) file /devl/aaa/BINARY/pfm.sql_Kavitha
followed by the r command as above.
There is some problem with the file you are trying to run from gdb -- either it is a corrupted file or the path is wrong. Try "gdb {filename}".
Instead of a single command, you will need two. One to specify the binary file and another to run the binary. In your case the commands are:
file /devl/aaa/BINARY/pfm.sql_Kavitha
run /devl/aaa/AVP/OCT_TEST /devl/aaa/ASAPDATA/READONLY /devl/aaa/ASAPDATA/READONLY 17 kk12345
Alternatively, instead of using the file command, you can give the binary name to gdb as an argument when you start gdb. Also notice the syntax of the run command. The binary name is not repeated!

Resources