Link to home
Start Free TrialLog in
Avatar of jr_barros_jr

asked on



I have a very long project done in cpp.
I DO have to use Visual C++ to compile it. The only option I have to compile it is using NMAKE.
I am needing to debug it. So, what I did:

1) Execute my .exe
2) In Visual C++, I am clicking in Debug > Attach to Process and after that I select my process and click in Attach.
3) When I include my first breakpoint, it is with an exclamation symbol and there is a message following it: "The breakpoint will not currently be hit. No symbols have been loaded for this document.

Now I have my question: How can I compile my project (remember using NMAKE as descrbed previously) and debug it with "Attach To Process" command?
Avatar of jkr
Flag of Germany image

You'll need to intruct nmake to use the Debug configuration for building, i.e.

nmake.exe /f myproject.mak CFG="myproject - Win32 Debug"
Avatar of jr_barros_jr


The original nmake call is:
nmake /nologo -f Makefile.simtool_pc TARGET_SETUP=pc_setup MODEL_SETUP=model_setup FSPATH="c:\tmp\M118" FLYDYN_ONLY_SUFFIX=_fltdyn

I changed to:
nmake /nologo -f Makefile.simtool_pc TARGET_SETUP=pc_setup MODEL_SETUP=model_setup FSPATH="c:\tmp\M118" FLYDYN_ONLY_SUFFIX=_fltdyn CFG="myproject - Win32 Debug"

And I also deleted all .obj files, but it is still NOT working, I mean, I am still having "The breakpoint will not currently be hit. No symbols have been loaded for this document." message.

Any other idea?
Stupid question - have you replaced "myproject - Win32 Debug" with the actual configuration name? Open the makefile with a text editor to see which actual configurations it contains.
The name of executable file is "m118_fltdyn_sim_win32" and it is the name of the process as well in "Attach To Process" windows (I attached the Attach to Process window image).

Considering your question, by the very good (not stupid at all), I changed my command to:
nmake /nologo -f Makefile.simtool_pc TARGET_SETUP=pc_setup MODEL_SETUP=model_setup FSPATH="c:\tmp\M118" FLYDYN_ONLY_SUFFIX=_fltdyn CFG="m118_fltdyn_sim_win32"

I also deleted my previous .obj files, But, unfortunately, I am still having the same error. I am only having acess to "disassembly".

Now it is my time to do a stupid question. What is the information I should include in CGF? Should I include the name of executable file or another information?

 User generated image
Hm, what are the available configurations? Could you post the makefile?
I remove some information, at least the repetitions parts, of the make file. The essential information is still there:

simulate: $(EXECNAME) $(DLL)

OBJS =       $(PATH)/input.obj
      @echo Linking all modules - $(EXECNAME)

       @echo Linking all modules - $(DLL)
      @$(LINK) $(LFLAGS) -dll /OUT:$(DLL) $(DLL_OBJS) $(ROOT)/extern/lib/$(ARCH)/microsoft/libmx.lib $(ROOT)/extern/lib/$(ARCH)/microsoft/libmex.lib  

      @echo Compiling - Optimization flag = $(DFLAGS)

$(PATH)/errors.o: $(COMMONPATH)/errors.c                              
      @echo "    Compiling errors.c --> errors.o" $(OUTPUT)
      @$(CC) $(CFLAGS) $(CC_OUT_FLAG)$(PATH)/errors.o -c $(COMMONPATH)/errors.c\

$(PATH)/sim.o: $(PATH)/autodefs.h \
                    $(COMMONPATH)/sim.c \

      @echo "    Compiling sim.c --> sim.o" $(OUTPUT)
               $(CC_OUT_FLAG)$(PATH)/sim.o -c $(COMMONPATH)/sim.c $(INCLUDES)

$(PATH)/iface.o:  $(COMMONPATH)/iface.c
    @echo "    Compiling iface.c --> iface.o" $(OUTPUT)
    @$(CPP) $(CPPFLAGS) -I$(ROOT)/extern/include \
              -I$(ROOT)/extern/examples/shrlib $(CC_OUT_FLAG)$(PATH)/iface.o -c $(COMMONPATH)/iface.c $(INCLUDES)

Avatar of jkr
Flag of Germany image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I deleted all .obj files, I included


and where $(CFLAGS)  was being used I replace by $(CFLAGS2).

I attached ok, like previously I was able to do, but I am still getting only "Disassembly" information.
I can see the "MicrosoftPublicSymbols" folder created but nothing else.
Do you get a .pdb file dufing the build (you should)? This should be copied to the same folder where your DLL is, so the compiler can find the symbols.

I am not creating a dll only. I am also creating an exe. I am attaching to the .exe. Inside this .exe there is a infinity looping there where I want to go.

The only pdb file was created is "vc70.pdb" and I copied it where is my .exe.

I deleted all .obj and all .pdb in my directories and recompile my project, but I am still having the same problem.
I also copied my .obj file to the same folder of my .exe, rename my pdb file to m118_sim_win32.pdb
I tried everything (native code, managed code etc).

This attach is still not working.
Are you building the .exe as 'Debug' also?  BTW,if you leave out '/Yd',  the .pdb file should have the same name as the DLL/EXE.
How can I build in Debug my exe? with the same options (/Zi /Yd)? If so, yes I am doing that.
Yes, the same options. Do you get a .pdb file without '/Yd'?
No. It was created the same one vc70.pdb.

Checking the status bar on VC, it looks only kernel32 symbols are being loading.

I tried with /Yd only. I tried with /Zi only. I also tried with /Z7 only. Nothing....

Do you have the compiler and linker output?

Here is the output with some repetions removes (.c, *.cpp and .obj)

C:\tmp\make>nmake /nologo -f Makefile.simtool_pc TARGET_SETUP=pc_setup MODEL_SETUP=model_setup FSPATH="c:\tmp"
Compiling the simulation model - Optimization flag = -Od -Oy-                                                          
### Linking ...                                                                                                        
        C:\PROGRA~1\Matlab\R2009a\sys\perl\win32\bin\perl C:\PROGRA~1\Matlab\R2009a\rtw\c\tools\ Top_flt
dyn.lnk Top.obj Top_capi.obj Top_data.obj Top_mdlapi.obj   rt_logging_mm
i.obj rtw_modelmap_utils.obj ert_main.obj                                                                              
        link -lib /OUT:Toplib.lib  ..\slprj\BA\_sharedutils\rtwshared.lib  @Top.lnk @Top_fl
Microsoft (R) Library Manager Version 7.10.3077                                                                        
Copyright (C) Microsoft Corporation.  All rights reserved.                                                              
### Created static library Top_lib.lib - win32                                                              
Compiling source files                                                                                                  
        1 file(s) copied.                                                                                              
rev_fun_gen: Creating the T:\compile/revisions_info.c file                              
Linking all modules 1 -- T:\run/sim_win32.exe                              
Linking all modules 2 -- T:\run/sim.mexw32                                  
   Creating library T:\run/sim.lib and object T:\run/sim.exp                                                                                            
*scratchinghead* - does VS complain about "symbols not found" when attaching to the process? Do you get any message when you select "Go to source..."?

The only message I am receivining is attached ("No Source Avaliable")

 User generated image

There was a overwrite to Link Flags inside makefile. So I included manually /DEBUG in link and it worked.

thank you so much for your help.