Home > gdb error > gdb error attempt to dereference a generic pointer

Gdb Error Attempt To Dereference A Generic Pointer

Contents

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack

Gdb Print Void Pointer

Overflow the company Business Learn more about hiring developers or posting ads with us gdb pointer Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community

Gdb Dereference Register

of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up GDB: Attempt to dereference generic pointer up vote 9 down vote favorite 4 How can I make GDB do extra dereferences in a printing function like x/s? When I try explicit dereferences in x/ I get the error "Attempt to dereference a generic pointer". Using x/ multiple times works, since each use includes an implicit dereference, but this is annoying since I have to copy and paste each intermediate result. Example Consider the very useful C program, example.c: #include int main(int argc, char **argv) { printf("argv[0] = %s\n", argv[0]); } If I build it and load it into GDB, I see that argv is stored at 0xc(%ebp), since a double dererence of that is passed as the second argument to printf (i.e. in 0x4(%esp)) on line 26: $ gcc -o example example.c $ gdb example (gdb) disass main Dump of assembler code for function main: 0x080483e4 <+0>: push %ebp 0x080483e5 <+1>: mov %esp,%ebp 0x080483e7 <+3>: and $0xfffffff0,%esp 0x080483ea <+6>: sub $0x10,%esp 0x080483ed <+9>: mov 0xc(%ebp),%eax 0x080483f0 <+12>: mov (%eax),%edx 0x080483f2 <+14>: mov $0x80484e0,%eax 0x080483f7 <+19>: mov %edx,0x4(%esp) 0x080483fb <+23>: mov %eax,(%esp) 0x080483fe <+26>: call 0x8048300 0x08048403 <+31>: leave 0x08048404 <+32>: ret End of assembler dump. I break at printf and run the program with arguments first and second: (gdb) break *main + 26 Breakpoint 1 at 0x80483fe (gdb) run first second Starting program: /var/tmp/SO-attempt-to-dereference-generic-pointer/example first second I attempt to print argv[0] in GDB, but I get the "generic pointer" error: Breakpoint 1, 0x080483e5 in main () (gdb) x/s **(0xc + $ebp) Attempt to dereference a generic pointer. However, by using 'x/xw' to manually dereference a few times, I'm eventually able to print argv[0] (and argv[1]): (gdb) x/xw 0xc + $ebp 0xbfffeba4: 0xbfffec34 (gdb) x/xw 0xbfffec34 0xbfffec34: 0xbfffedc8 (gdb) x/s 0xbfffedc8 0xbfffedc8: "/var/tmp/SO-attempt-to-dereference-generic-pointer/example" (gdb) x/xw 0xbfffec34 + 4

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up how to check the value of pointer (void) not be zero (Attempt to dereference a generic pointer) up vote 1 down vote favorite Sorry http://stackoverflow.com/questions/20414699/gdb-attempt-to-dereference-generic-pointer it must be very simple question , but since I tried in diffrenet ways without any success I have to ask here to be sure. C programming : There is a struct name rtg. EDIT: type of mtch is LLIST type of initial is LL_NODE typr of obj is pointer (void) . Using gdb when I check (gdb) print *rtg->mtch->initial->obj Attempt to dereference a generic pointer. (gdb) print rtg->mtch->initial->obj $10 = (void *) 0x4cc660 (gdb) x http://stackoverflow.com/questions/15251805/how-to-check-the-value-of-pointer-void-not-be-zero-attempt-to-dereference-a-g 0x4cc660 0x4cc660: 0x00000000 This null pointer causes segfault in my program. What I am looking for is simply how to check the value of what rtg->mtch->initial->obj is pointing not be zero? (to prevent above segfault) I mean if I check with if (rtg->mtch->initial->obj) , it would just check if pointer obj , adress not be zero (this is not what I intend , I intend to check the value of that pointer not be zero (but when I use * before checking in gdb it says "Attempt to dereference a generic pointer". So what is the correct way to check that value not be zero (and prevent this segfault)? Edit : i had tried this if (*((char *) rtg->mtch->initial->obj) != NULL) but i got compile warning : warning: comparison between pointer and integer EDIT2 , here what are these defined in the source code ECM_REQUEST is struct ECM_REQUEST rtg; in this struct defind mtch as LLIST mtch; initial is LL_NODE obj is a pointer i want to check obj value not be zero so now everything are clear about my question isn't it? Thanks c pointers null segmentation-fault share|improve this question edited Mar 6 '13 at 16:28 asked Mar 6 '13 at 15:47 nima tajfar 2828 8 You must show more code, like the structure declarations. Don't talk about them, show them. &nd

Programming Boards C++ Programming dereferencing a void * Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems Thread: dereferencing http://cboard.cprogramming.com/cplusplus-programming/30048-dereferencing-void-*.html a void * Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 12-04-2002 #1 pointing Guest dereferencing a void * i use a void pointer to point either one of two distinct class types. say: class x{...} class y{...} and void *p; x object1; y object2; p = (x *)&object1; etc.... and somehow when i need to reach to one of object1's gdb error fields: i want to use p to reach the object but i receive "attempt to dereference a generic pointer" error? is there anybody who has faced this error before? thanks in advance 12-04-2002 #2 Polymorphic OOP View Profile View Forum Posts Visit Homepage Programming Sex-God Join Date Nov 2002 Posts 1,078 You have to typecast the void pointer to a pointer to the type you want to access. so *(x*)(p) But you really should not have to gdb error attempt deal with void pointers much in C++ because of templating and inheritance. void pointers are generally more necissary in C than C++. My collection of useless files Contact Me! 12-04-2002 #3 pointing View Profile View Forum Posts Registered User Join Date Dec 2002 Posts 4 yeah that was pretty much the same solution that i have tried but it didn't work you might be right about not using void * in C++ but does anyone has an advice to use what when i need to point two distict types via only one pointer. (i'm implemeting a b+ tree and i need to point to internal nodes and leaf nodes with a unique type of pointer) 12-04-2002 #4 Polymorphic OOP View Profile View Forum Posts Visit Homepage Programming Sex-God Join Date Nov 2002 Posts 1,078 That should work. Make sure you encase that in parenthesis before you use it. You can use the arrow operator instead of dereferencing the cast pointer as well. My collection of useless files Contact Me! 12-04-2002 #5 pointing View Profile View Forum Posts Registered User Join Date Dec 2002 Posts 4 that's what i'm doing actually, it's probably a property of C++ but i couldn't fix let me be more informative: class Int_Node{ public: //internal node vector keys; vector pointers; }; class Leaf_Node{ public: //leaf node vector records; Int_Node *parent_node; }; Leaf_Node bk2; //......

 

Related content

gdb error 193

Gdb Error p here for a quick overview of relatedl the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of million programmers just like you helping each other Join them it only takes a minute Sign up Cygwin GDB gives error when trying to start program

gdb error attempt dereference generic pointer

Gdb Error Attempt Dereference Generic Pointer p here for a quick overview of the site Help Center Detailed answers to relatedl any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of million programmers just like you helping each other Join them it only takes a minute Sign up Attempt to dereference a generic

gdb error accessing memory address invalid argument

Gdb Error Accessing Memory Address Invalid Argument p x User account creation filtered due to spam Bug - relatedl g gdb incorrectly maps variables in fortran common block Summary g gdb incorrectly maps variables in fortran common block Status RESOLVED INVALID Alias None Product gcc Classification Unclassified Component debug show other bugs Version Importance P normal Target Milestone --- Assignee Not yet assigned to anyone URL Keywords Depends on Blocks Reported - - UTC by potterveld Modified - - UTC History CC List user show gcc-bugs See Also Host Target alpha-dec-osf d Build Known to work Known to fail Last

gdb error initializing thread_db library

Gdb Error Initializing Thread db Library table id toc tbody tr td div id toctitle Contents div ul li a href Warning dynamic Section For Is Not At The Expected Address wrong Library Or Version Mismatch a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to relatedl any questions you might have Meta Discuss the p h id Warning dynamic Section For Is Not At The Expected Address wrong Library Or Version Mismatch p workings and policies of this site About Us Learn more about Stack solib-absolute-prefix Overflow the

gdb error in sourced command file

Gdb Error In Sourced Command File p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss relatedl the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of million programmers just like you helping each other Join them it only takes a minute Sign up gdb stops in a command

gdb error while loading shared libraries libreadline.so.5

Gdb Error While Loading Shared Libraries Libreadline so p SEGGER US Store The link you are trying to reach is no longer available or is invalid Forum Software Burning Board developed by WoltLab GmbH p p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and relatedl policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow

gdb error 0377

Gdb Error p your question and get tips relatedl solutions from a community of IT Pros process exited with code Developers It's quick easy Problem - program exited with gdb cheat sheet code P n a Seo Jae Ick Hi My name is Seo Jae Ick I have a problem with running a program on Linux RedHat GDB have reported this program exited with code I think this statement comes when explicit call in process exit - - octet - decimal return - in main function any other case exists I have searched exit - in whole codes but not

gdb error while loading shared libraries libpython2.6.so.1.0

Gdb Error While Loading Shared Libraries Libpython so p here for a quick relatedl overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of million programmers just like you helping each other Join them it only takes a minute Sign up libpython so cannot

gdb error detected on stdin

Gdb Error Detected On Stdin p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more relatedl about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of million programmers just like you helping each other Join them it only takes a minute Sign up gdb pipe redirection Error gdb Hangup

gdb error creating process 193

Gdb Error Creating Process p here for a quick overview of the site relatedl Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of million programmers just like you helping each other Join them it only takes a minute Sign up gdb fails with error when debugging MinGW-compiled

gdb error while loading shared libraries libexpat.so.0

Gdb Error While Loading Shared Libraries Libexpat so p Comments Here again another post about CentOS Today relatedl morning while I was trying to start gdb with default compiler gcc which comes with CentOS - it crashed with following descriptive error gdb error while loading shared libraries libexpat so cannot open shared object file No such file or directory After a min search I found expat rpm for Cent OS from I downloaded and try to install it with rpm -ivh command but it failed because of expact-devel dependancy Then I used command yum install expat- - el i rpm

gdb error while loading shared libraries libexpat.so.1

Gdb Error While Loading Shared Libraries Libexpat so p Search HCL Search Reviews Search ISOs Go to Page LinuxQuestions org Forums Linux Forums Linux - General error while loading shared libraries libexpat so cannot open shared object file User Name relatedl Remember Me Password Linux - General This Linux forum is for general Linux questions and discussion If it is Linux Related and doesn't seem to fit in any other forum then this is the place Notices Welcome to LinuxQuestions org a friendly and active Linux Community You are currently viewing LQ as a guest By joining our community you

gdb error while loading shared libraries libncurses.so.5

Gdb Error While Loading Shared Libraries Libncurses so p communities company blog Stack Exchange Inbox Reputation and Badges relatedl sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Ask Ubuntu Questions Tags Users Badges Unanswered Ask Question Ask Ubuntu is a question and answer site for Ubuntu users and developers Join them it only

gdb error codes

Gdb Error Codes table id toc tbody tr td div id toctitle Contents div ul li a href Gdb Reload Executable a li li a href Gdb Restart Program a li li a href Gdb Tutorial a li ul td tr tbody table p option g -g -o gdbprog gdbprog cc Load executable into gdb gdb gdbprog GDB is free software and you are welcome to distribute copies of relatedl it under certain conditions type show copying to see the gdb where command conditions There is absolutely no warranty for GDB type show warranty for details GDB p h id

gdb error 5

Gdb Error p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this relatedl site About Us Learn more about Stack Overflow the company Business gdb error creating process error Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation starting debugger failed code blocks Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of million programmers just like you helping each other Join them it only takes a minute Sign