0

I'm debugging a program right now that has a few files: arr.h is the header file for a list class, which creates an array of linked lists (generated randomly). Howard.cpp is the implementation file, and main.cpp is where I put the main function that calls functions on objects of the list class. it includes list.h. I'm getting a seg fault for one of my functions (implemented within Howard.cpp). I entered GDB. When the seg fault occurs, I know to enter "where" or "list" to get the function calls that led up to the seg fault. In this case, when I get to the function where the seg fault occurred (frame 0), I want to see the variables and what their values are in that function. However, when I try to step into that specific function, or type "info locals," I get the message that there is "No symbol table info available." I know this is not true, but I cannot figure out how to be able to see the line where it failed. Additionally, any line information regarding that function/file will not display. I think it has something to do with the error being in a function in a file that is not the executable one; but what can I do about this? If this question is confusing at all, feel free to ask me for clarification. I'm pretty new at all this.

This is on a linux terminal environment that was created by the professor of my class and meant for practicing linked lists and recursion.

Ok, I'm going to include an example here:

I have a function that recursively copies an array of linked lists in reverse. The recursive function is called table::reverse_table(node *&,node *,node *). I have debugged it to the point where I know that there is no problem with the stopping point. When the program segfaults, I'll enter "where," and it will output:

#0  0x0000000000400e6e in table::reverse_table(node*&, node*, node*) ()
#1  0x0000000000400df1 in table::reverse_table(node*&, node*, node*) ()
#2  0x0000000000400df1 in table::reverse_table(node*&, node*, node*) ()
#3  0x0000000000400df1 in table::reverse_table(node*&, node*, node*) ()
#4  0x0000000000400df1 in table::reverse_table(node*&, node*, node*) ()
#5  0x0000000000400df1 in table::reverse_table(node*&, node*, node*) ()
#6  0x0000000000400df1 in table::reverse_table(node*&, node*, node*) ()
#7  0x0000000000400df1 in table::reverse_table(node*&, node*, node*) ()
#8  0x0000000000400df1 in table::reverse_table(node*&, node*, node*) ()
#9  0x0000000000400df1 in table::reverse_table(node*&, node*, node*) ()
#10 0x0000000000400df1 in table::reverse_table(node*&, node*, node*) ()
#11 0x0000000000400df1 in table::reverse_table(node*&, node*, node*) ()
#12 0x0000000000400f87 in table::reverse_table(table&, int, int) ()
#13 0x0000000000400fe7 in table::reverse_table(table&) ()
#14 0x0000000000401087 in main ()

Then, when I type "frame 0," it displays:

#0  0x0000000000400e6e in table::reverse_table(node*&, node*, node*) ()

When I type "info locals," then "No symbol table info available" is displayed. I can't get any information about where in the function the segfault occurred, either; GDB seems to not have that information. Is there something that I need to do to include it while debugging?

2
  • You could add a SSCCE (sscce.org) - that would make it clearer. Commented May 16, 2016 at 15:38
  • added the gdb messages that I've seen while debugging. Hopefully that is enough info. I don't really want to post my code, because I don't want it to appear that I'm just trying to get a solution to my problem. I'm trying to figure out how to debug my problem myself. Commented May 16, 2016 at 15:48

1 Answer 1

3

I hope debug flag(-g) was enabled during compilaton. You are getting this message because the process has been terminated and there is no symbol table information available.You should try to run your program through gdb and when seg fault will occur; use bt (backtrace) command to check the last function which causes the segmentation fault. Run again your program by using a breakpoint on that function entry point. check with next command or info command the value of locals.

Sign up to request clarification or add additional context in comments.

2 Comments

I've been doing this; even when the program is not terminated, it will not show any symbol table information for any functions other than main, which simply calls the functions that I need to debug.
Ok, this is embarrassing, but adding -g when I compiled totally fixed it. I thought that it was included by the professor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.