0

I can't step into a printf function with gdb. I'm using CLion, everytime I hit "step into", "step over" or "force step into", the same line returns, eventually exiting the program.

I have compiled the program with minimal optimisations:

CC=gcc
CFLAGS=-Wall -ggdb -O0 -g3
OBJECTS=main.c

permute: $(OBJECTS)
    $(CC) $(CFLAGS) $(OBJECTS) -o permute

clean:
    rm $(OBJECTS) permute

I've also used stepi on the console. What is the problem?

EDIT:

I get the following messages when starting gdb:

>>>>>Function "__cxa_throw" not defined.
warning: Could not open OSO archive file "/BinaryCache/corecrypto/corecrypto-233.1.2~26/Symbols/BuiltProducts/libcorecrypto_static.a"
warning: `/BinaryCache/coreTLS/coreTLS-35.20.2~10/Objects/coretls.build/coretls.build/Objects-normal/x86_64/system_coretls_vers.o': can't open to read symbols: No such file or directory.
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.20.2~10/Symbols/BuiltProducts/libcoretls_ciphersuites.a"
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.20.2~10/Symbols/BuiltProducts/libcoretls_handshake.a"
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.20.2~10/Symbols/BuiltProducts/libcoretls_record.a"
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.20.2~10/Symbols/BuiltProducts/libcoretls_stream_parser.a"

Full code:

#include <stdio.h>


/* Function to swap values at two pointers */
void swap (char *x, char *y)
{
    char temp;
    temp = *x;
    *x = *y;
    *y = temp;
}

/* Function to print permutations of string
    This function takes three parameters:
    1. String
    2. Starting index of the string
    3. Ending index of the string. */
void permute(char *a, int i, int n)
{
    int j;
    if (i == n)
        printf("%s\n", a);
    else
    {
        for (j = i; j <= n; j++)
        {
            swap((a+i), (a+j));
            permute(a, i+1, n);
            swap((a+i), (a+j)); //backtrack
        }
    }
}

/* Driver program to test above functions */
int main()
{
    char a[] = "ABC";
    permute(a, 0, 2);
    getchar();
    return 0;
}
Tony54
  • 265
  • 1
  • 4
  • 9
  • no, it's not a duplicate. It doesn't answer my question. The answer given was to use "stepi". i've noted in my question that i've tried that and it doesn't work. – Tony54 Sep 09 '15 at 13:45
  • printf is part of the standard library, your compilation flags will not affect already compiled libraries. Does gdb complain about missing symbols at startup? – fsaintjacques Sep 09 '15 at 13:50
  • Try to install libc debug symbols. This can be done by yum or apt-get, depending on your distribution. – ks1322 Sep 09 '15 at 13:54
  • 2
    Why do you want to step into `printf(3)`? Just so you know, having a crash with a stacktrace ending inside `printf(3)` does not mean it's a libc bug. It's probably your code. – Filipe Gonçalves Sep 09 '15 at 13:57
  • @FilipeGonçalves it's not my code – Tony54 Sep 09 '15 at 14:03

0 Answers0