Can C macros be expanded in gdb when the program was compiled using clang?

tlehman

I have a macro that fetch's the J-th bit of an integer:

#define TWO_TO_THE(POWER) (1 << POWER)

#define JTH_BIT(BITS, J)  ((TWO_TO_THE((J-1)) & BITS) != 0)

However, I can't use it from gdb by issuing the command print JTH_BIT(i,j), can macros in C even be used while debugging?

alk

Macros are handled by the pre-processor. The compiler doesn't even know about them.

However, if lucky, GCC's option -g3 would do the job and generate code allowing gdb to expand a macro.

From the gdb documentation (emphasis by me):

-glevel

[...] Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use -g3.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Can C macros be expanded in gdb when the program was compiled using clang?

From Dev

Is it possible to debug a gcc-compiled program using lldb, or debug a clang-compiled program using gdb?

From Dev

C++ program can not be compiled

From Dev

Getting a clang error when compiling a simple C program using GCC

From Dev

lldb can't debug string when compiled by clang++

From Dev

How is this string in an array represented in assembly when a C program is compiled using the gcc -S option?

From Java

Can gdb print expanded preprocessor/macro results?

From Dev

How can i link my c++ program statically with libstdc++ on osx using clang?

From Dev

if 0 is compiled in c program

From Dev

rename() not working in a C program compiled using Dev C++

From Dev

How can a single compiled C program run on multiple architectures?

From Dev

How can i detect "out of bound error" in C program with GDB?

From Dev

C - Program fails to get file descriptor only when running with GDB

From Dev

clang++ only compiles C++11 program using boost::format when -std=c++11 option is dropped

From Dev

Can you access other program's memory using program compiled with mingw?

From Dev

Debug program compiled in MS VC++ 2010 Express with gdb

From Dev

scala self type can it really be compiled when using `extends`?

From Dev

Is there an equivalent of GDB for GCC for debugging when compiling with CLANG?

From Dev

Expanded from macro 'num' while printing it using printf by Clang compiler

From Dev

C enum using macros

From Dev

C enum using macros

From Dev

C array of structs initialization issues when using macros

From Dev

C array of structs initialization issues when using macros

From Dev

SBT 0.13.0 - can't expand macros compiled by previous versions of Scala

From Dev

C Program Works in GDB But Not Normally

From Dev

Can I use Visual C++ for an assignment that will be compiled using gcc?

From Dev

Can't get stacktrace when SIGSEGV using gdb

From Dev

When is {a,b,c} expanded in bash, when is it not?

From Dev

How can Windows Portable Device (WPD) API be used by a program compiled using MingW?

Related Related

  1. 1

    Can C macros be expanded in gdb when the program was compiled using clang?

  2. 2

    Is it possible to debug a gcc-compiled program using lldb, or debug a clang-compiled program using gdb?

  3. 3

    C++ program can not be compiled

  4. 4

    Getting a clang error when compiling a simple C program using GCC

  5. 5

    lldb can't debug string when compiled by clang++

  6. 6

    How is this string in an array represented in assembly when a C program is compiled using the gcc -S option?

  7. 7

    Can gdb print expanded preprocessor/macro results?

  8. 8

    How can i link my c++ program statically with libstdc++ on osx using clang?

  9. 9

    if 0 is compiled in c program

  10. 10

    rename() not working in a C program compiled using Dev C++

  11. 11

    How can a single compiled C program run on multiple architectures?

  12. 12

    How can i detect "out of bound error" in C program with GDB?

  13. 13

    C - Program fails to get file descriptor only when running with GDB

  14. 14

    clang++ only compiles C++11 program using boost::format when -std=c++11 option is dropped

  15. 15

    Can you access other program's memory using program compiled with mingw?

  16. 16

    Debug program compiled in MS VC++ 2010 Express with gdb

  17. 17

    scala self type can it really be compiled when using `extends`?

  18. 18

    Is there an equivalent of GDB for GCC for debugging when compiling with CLANG?

  19. 19

    Expanded from macro 'num' while printing it using printf by Clang compiler

  20. 20

    C enum using macros

  21. 21

    C enum using macros

  22. 22

    C array of structs initialization issues when using macros

  23. 23

    C array of structs initialization issues when using macros

  24. 24

    SBT 0.13.0 - can't expand macros compiled by previous versions of Scala

  25. 25

    C Program Works in GDB But Not Normally

  26. 26

    Can I use Visual C++ for an assignment that will be compiled using gcc?

  27. 27

    Can't get stacktrace when SIGSEGV using gdb

  28. 28

    When is {a,b,c} expanded in bash, when is it not?

  29. 29

    How can Windows Portable Device (WPD) API be used by a program compiled using MingW?

HotTag

Archive