1

I am using netbeans8.0.1 on lubuntu and I can not get past my malloc instances in the debugging environment. I just get to my build tree malloc function and the dissembly window appears saying "!Source not found, file: malloc.c, line: 2,876". I had this same code working on xcode but now that I am using linux and netbeans it will not run. By the way this is with the c programming language and the code is for a parser and automated differentiation tool. I am new to the c language but as I said before I had this very same program working on xcode but when I brought it to my laptop for further development I ran into this problem.

struct node *buildtree(){
struct node* name=(struct node*)malloc(sizeof(struct node));
name->val=0;
name->sym='\0';
return name;

};

  • 2
    You are trying to step into the function `malloc()`, which requires access to that function's source. Since you don't have that (maybe you could install it) that doesn't work. You should still be able to use and debug that code, only that you will have to treat `malloc()` as a black box. – Ulrich Eckhardt Nov 01 '14 at 14:25
  • 1
    no need to cast result of malloc in C – 4pie0 Nov 01 '14 at 14:25
  • 1
    Focus on debugging *your* code, malloc() doesn't have a bug. Practice using the debugger's Step Into, and Step Over commands. If you accidentally blunder into a function that you didn't mean to debug then use Step Out. – Hans Passant Nov 01 '14 at 14:39

1 Answers1

0

To step into function in debugger you have to posses the code of the function. It seems that you don't have access to the code of malloc, you have a binary, compiled version, but no source code. Your program can be still run because for this to happen the binary code is necessary and not the source files. You should install/download correct file or step over this function while in debug. A minor hint: no need to cast the result of mallloc in C.

Community
  • 1
  • 1
4pie0
  • 29,204
  • 9
  • 82
  • 118
  • I do not know if this is related but when I step over the malloc within the build tree function I end up with the right parse tree but after the function that forms the parse tree returns my postorder print function gets a segmentation fault because the parse tree that was built earlier gets lost. On xcode I was not having this problem and I do not understand why the malloc function will not work in the debugger. What file would I need to download to have the source file and how would I configure it into netbeans? –  Nov 01 '14 at 15:03
  • you have to get right version based on a compiler you use – 4pie0 Nov 01 '14 at 15:20