Makefile need debug option

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joseph

    Makefile need debug option

    Hi gurus,

    Can someone quickly remind me how I can add a -g (to generate the
    debug table inside the core file) so I can run it against GDB and find
    out whats happening. I tried to put it in the right after the $(CC)
    as in $(CC) -g .... But it didn't work. The core file shows no
    stack in GDB
    By the way, I am compiling on a Linux box. This is a makefile from a
    piece of code that i need to maintain. TIA




    =============== =========== THE MAKEFILE FOLLOWS =============== =====

    I=$(CUST)/src/include
    MAKEINCDIR=$(I)/Makefiles
    DIRNAME=SendFti r
    CATALOG=SendFti r_text.t
    CDEBUGFLAGS=-g

    include $(MAKEINCDIR)/$(shell uname)/vets.variables
    include $(MAKEINCDIR)/$(shell uname)/ANSI.compiler
    include $(MAKEINCDIR)/vets.rules
    include $(MAKEINCDIR)/NLS.rules


    all: catalogs progs

    LIBS=\
    $(LIB)/libvets.a \
    $(LIB)/libphrases.a \
    $(LIB)/libftir.a \
    $(LIB)/libio.a \
    $(LIB)/libinifile.a \
    $(LIB)/libstr.a \
    $(LIB)/libXXX.a

    SYSLIB= $(SYSNLSLIB)

    # --------------------------------------------------------------------
    # CATALOGS
    #
    include $(MAKEINCDIR)/catalogs.progs



    # --------------------------------------------------------------------
    # PROGS
    #
    ..PHONY progs: SendFtir

    SENDFTIR=\
    $(OBJDIR)GetDat a.o \
    $(OBJDIR)PrintD ata.o \
    $(OBJDIR)SendFt ir.o

    SendFtir: $(BIN)/SendFtir6k
    $(BIN)/SendFtir6k: $(SENDFTIR) $(LIBS)
    $(CC) $(LDFLAGS) -o $(@F) $(SENDFTIR) $(LIBS) $(SYSLIB)
    $(INSTALL)
    $(CLEANUP)



    # --------------------------------------------------------------------
    include $(MAKEINCDIR)/clean.rules

    #
    # Include file dependencies
    #


    include $(addprefix depends/,$(SENDFTIR:.o= .d))
    include $(addprefix depends/,$(CATALOG:.t=. d))

  • Keith Thompson

    #2
    Re: Makefile need debug option

    Joseph <spmok2@canada. comwrites:
    Can someone quickly remind me how I can add a -g (to generate the
    debug table inside the core file) so I can run it against GDB and find
    out whats happening. I tried to put it in the right after the $(CC)
    as in $(CC) -g .... But it didn't work. The core file shows no
    stack in GDB
    By the way, I am compiling on a Linux box. This is a makefile from a
    piece of code that i need to maintain. TIA
    [snip]

    This isn't a C question. comp.unix.progr ammer is probably your best
    bet, or possibly one of the Linux groups.

    --
    Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

    Comment

    • Kenny McCormack

      #3
      Re: Makefile need debug option

      In article <lnfy0jx4sb.fsf @nuthaus.mib.or g>,
      Keith Thompson <kst-u@mib.orgwrote:
      >Joseph <spmok2@canada. comwrites:
      >Can someone quickly remind me how I can add a -g (to generate the
      >debug table inside the core file) so I can run it against GDB and find
      >out whats happening. I tried to put it in the right after the $(CC)
      >as in $(CC) -g .... But it didn't work. The core file shows no
      >stack in GDB
      >By the way, I am compiling on a Linux box. This is a makefile from a
      >piece of code that i need to maintain. TIA
      >[snip]
      >
      >This isn't a C question. comp.unix.progr ammer is probably your best
      >bet, or possibly one of the Linux groups.
      IOW:

      Off topic. Not portable. Cant discuss it here. Blah, blah, blah.

      --
      Useful clc-related links:





      Comment

      • Richard Tobin

        #4
        Re: Makefile need debug option

        In article <1191970199.392 827.103870@19g2 000hsx.googlegr oups.com>,
        Joseph <spmok2@canada. comwrote:
        >Can someone quickly remind me how I can add a -g (to generate the
        >debug table inside the core file) so I can run it against GDB and find
        >out whats happening.
        Try setting CFLAGS to -g in your makefile.
        >I tried to put it in the right after the $(CC)
        >as in $(CC) -g
        That should work.
        >The core file shows no stack in GDB
        Do you really mean it shows no stack? Or just that it doesn't show
        the names of functions on the stack? If there's no stack, it probably
        means that the bug has completely screwed up the stack pointer.

        -- Richard
        --
        "Considerat ion shall be given to the need for as many as 32 characters
        in some alphabets" - X3.4, 1963.

        Comment

        • karthikbalaguru

          #5
          Re: Makefile need debug option

          On Oct 10, 3:49 am, Joseph <spm...@canada. comwrote:
          Hi gurus,
          >
          Can someone quickly remind me how I can add a -g (to generate the
          debug table inside the core file) so I can run it against GDB and find
          out whats happening. I tried to put it in the right after the $(CC)
          as in $(CC) -g .... But it didn't work. The core file shows no
          stack in GDB
          By the way, I am compiling on a Linux box. This is a makefile from a
          piece of code that i need to maintain. TIA
          >
          =============== =========== THE MAKEFILE FOLLOWS =============== =====
          >
          I=$(CUST)/src/include
          MAKEINCDIR=$(I)/Makefiles
          DIRNAME=SendFti r
          CATALOG=SendFti r_text.t
          CDEBUGFLAGS=-g
          >
          include $(MAKEINCDIR)/$(shell uname)/vets.variables
          include $(MAKEINCDIR)/$(shell uname)/ANSI.compiler
          include $(MAKEINCDIR)/vets.rules
          include $(MAKEINCDIR)/NLS.rules
          >
          all: catalogs progs
          >
          LIBS=\
          $(LIB)/libvets.a \
          $(LIB)/libphrases.a \
          $(LIB)/libftir.a \
          $(LIB)/libio.a \
          $(LIB)/libinifile.a \
          $(LIB)/libstr.a \
          $(LIB)/libXXX.a
          >
          SYSLIB= $(SYSNLSLIB)
          >
          # --------------------------------------------------------------------
          # CATALOGS
          #
          include $(MAKEINCDIR)/catalogs.progs
          >
          # --------------------------------------------------------------------
          # PROGS
          #
          .PHONY progs: SendFtir
          >
          SENDFTIR=\
          $(OBJDIR)GetDat a.o \
          $(OBJDIR)PrintD ata.o \
          $(OBJDIR)SendFt ir.o
          >
          SendFtir: $(BIN)/SendFtir6k
          $(BIN)/SendFtir6k: $(SENDFTIR) $(LIBS)
          $(CC) $(LDFLAGS) -o $(@F) $(SENDFTIR) $(LIBS) $(SYSLIB)
          $(INSTALL)
          $(CLEANUP)
          >
          # --------------------------------------------------------------------
          include $(MAKEINCDIR)/clean.rules
          >
          #
          # Include file dependencies
          #
          >
          include $(addprefix depends/,$(SENDFTIR:.o= .d))
          include $(addprefix depends/,$(CATALOG:.t=. d))

          Try:
          CFLAGS = $(CDEBUGFLAGS)
          CDEBUGFLAGS = -g

          I think, you have not linked the CFLAGS with CDEBUGFLAGS. Did you
          cross-check that .
          Else, try directly the CFLAGS = -g in the makefile.

          The -g option should make it work .

          Karthik Balaguru

          Comment

          Working...