Hi,

i have few programs which i have compiled using "make all". When i debug the main program, during debugging i get the following message :

****Stepping over inlined function code.***

As a result i am unable to debug the program line by line. The debugging is random. I am using gdb to debug

As an example :

I debug line 100 and then wish to debug the next line 101 by pressing "n", i am unable to do so. Because i get the above message and it debugs the line 300 instead of 101.

I have not defined any function as inline.
Please help
Thanks

Dani AI

Generated

Short answer: that GDB message means the compiler inlined or optimized the call you tried to step over, so there is no one-to-one machine instruction for the next source line and GDB jumps to whatever address corresponds to the next available debug info. As noted, modern GCC will inline aggressively; as pointed out, debugging is most reliable when optimization is reduced; and as reminded, a clean rebuild is required after changing flags. See the GDB notes on inlined functions for details and how GDB represents them () and the GCC docs on optimization and inlining (GCC Optimize Options).

Practical fixes to apply now:

  • Rebuild just the translation units you need for interactive debugging with debug-friendly settings (keep debug info, reduce aggressive optimizations, and turn off inlining for those files). With GNU make you can add target-specific flags so only selected .o files get different options; for example:
    
    # compile only these objects with debug-friendly flags
    debug_objs := module1.o module2.o

$(debug_objs): CXXFLAGS += -g -Og -fno-inline -fno-omit-frame-pointer

Then run a clean build so stale objects are not reused. See the GNU make guide on target-specific variables ([GNU make manual](https://www.gnu.org/software/make/manual/html_node/Target_002dspecific.html)).

If you cannot recompile immediately, use GDB techniques to work around inlining:

inside gdb

info inline
disassemble my_function
break myfile.cpp:123


`info inline` shows which calls were inlined; setting breakpoints by file:line avoids single-step surprises. For long-term fixes, move non-trivial functions out of headers (or mark them not-inline) when you need line-by-line stepping in development builds.

Recommended Answers

All 6 Replies

Inline can be done if the compiler deems it necessary. What level of debugging / optimization do you have it set to?

I have -03 level of optimization. Some of the functions are defined as inline functions in the header file for some programs. And since i am compiling them with -ggdb option i am getting the error. Could that be the problem?

I have one more question. Following is my partial make file.

------------------------------------------------------------------------------

HEADERS =binary_base.h binary_clsgen.h binary_header.h

LIB_SRCS = binary_utils.cpp \
bianry_solver.cpp\
binary_base.cpp \
binary_dbase.cpp \
binary_c_wrapper.cpp \
binary_cpp_wrapper.cpp \

LIB_OBJS = $(LIB_SRCS:.cpp=.o)

$(LIB_OBJS): $(HEADERS) Makefile

.cpp.o:
$(CC) $(CFLAGS) $(MFLAGS) -c $< -ggdb
--------------------------------------------------------------------------

My question is if i wish to compile say 5 programs out of total 10 programs using -ggdb option and the remaining 5 programs without ggdb option how can i do that.

Thanks

Ideally, you should debug with every optimisation turned off.
Then you get to see the code do pretty much what you wrote it to do.

Ideally, you should debug with every optimisation turned off.
Then you get to see the code do pretty much what you wrote it to do.

*Nods*

i tried with optimization -o also but still i am not able to debug

Following are my flags :

CC = g++ -Wall
CFLAGS = -O

Try CC = g++ and CFLAGS = -Wall -g BUT once you have changed them is it 100% essentual to do a make clean before your make all . Otherwise you will fail to implement the change.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.