[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 716
  • Last Modified:

Debug

Hi,

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?
0
jr_barros_jr
Asked:
jr_barros_jr
  • 11
  • 9
1 Solution
 
jkrCommented:
You'll need to intruct nmake to use the Debug configuration for building, i.e.

nmake.exe /f myproject.mak CFG="myproject - Win32 Debug"
0
 
jr_barros_jrAuthor Commented:
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?
0
 
jkrCommented:
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.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
jr_barros_jrAuthor Commented:
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?

 Attach to Process window
0
 
jkrCommented:
Hm, what are the available configurations? Could you post the makefile?
0
 
jr_barros_jrAuthor Commented:
I remove some information, at least the repetitions parts, of the make file. The essential information is still there:

EXECPATH = $(HOME)/run
EXECNAME = $(EXECPATH)/$(EXEC)$(SUFFIX)_sim_$(NAME_SUFFIX)
DLL = $(EXECPATH)/$(MODEL_EXEC)$(SUFFIX)_sim.dll
simulate: $(EXECNAME) $(DLL)

OBJS =       $(PATH)/input.obj
             
$(EXECNAME): $(OBJS)
      @echo Linking all modules - $(EXECNAME)
      @$(LINK) $(LFLAGS) $(LOUT_FLAG)$(EXECNAME) $(OBJS) $(WAVEFILE) $(LFLAGS)

$(DLL): $(DLL_OBJS)
       @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  


model:
      @echo Compiling - Optimization flag = $(DFLAGS)
      @$(MAKE_ENV) $(MODEL_MAKE) -D $(COND_FLAG) $(OPTIONS) -f $(MODEL_MAKE_FILE) $(MAKE_ARGS) OPTIMIZATION_FLAGS="$(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\
              $(INCLUDES)

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

      @echo "    Compiling sim.c --> sim.o" $(OUTPUT)
      @$(CC) $(CFLAGS) -DDISCRETE $(WAVEFLAG) $(WAVELOG) \
               $(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)
   

0
 
jkrCommented:
Ah, I see - that is a regular makefile, not a nmake-specific one, so 'CFG=' won't work. If you add '/Zi' to 'CFLAGS', you'll get a debug build with symbol information. For VC++ versions older than VS 2005, make that '/Zi /Yd'.
0
 
jr_barros_jrAuthor Commented:
I deleted all .obj files, I included

CFLAGS2=$(CFLAGS) /Zi /Yd

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.
0
 
jkrCommented:
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.
0
 
jr_barros_jrAuthor Commented:
jkr,

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.
0
 
jr_barros_jrAuthor Commented:
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.
0
 
jkrCommented:
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.
0
 
jr_barros_jrAuthor Commented:
How can I build in Debug my exe? with the same options (/Zi /Yd)? If so, yes I am doing that.
0
 
jkrCommented:
Yes, the same options. Do you get a .pdb file without '/Yd'?
0
 
jr_barros_jrAuthor Commented:
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....

0
 
jkrCommented:
Do you have the compiler and linker output?
0
 
jr_barros_jrAuthor Commented:
jkr,

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"
 FLYDYN_ONLY_SUFFIX=_                                                                                            
"********************************************************************************"                                      
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\mkvc_lnk.pl 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
tdyn_ref.rsp                                                                                                            
Microsoft (R) Library Manager Version 7.10.3077                                                                        
Copyright (C) Microsoft Corporation.  All rights reserved.                                                              
                                                                                                                       
Top.obj                                                                                                    
Top_capi.obj                                                                                                
Top_data.obj                                                                                                
Top_mdlapi.obj                                                                                              
rt_logging_mmi.obj                                                                                                      
rtw_modelmap_utils.obj                                                                                                  
ert_main.obj                                                                                                            
..\slprj\BA\mr\mr_rtwlib.lib                                                                    
..\slprj\BA\Engine_mr\Engine_mr_rtwlib.lib                                                                    
..\slprj\BA\Loads_mr\Loads_mr_rtwlib.lib                                                                      
### Created static library Top_lib.lib - win32                                                              
"****************************************"                                                                              
Compiling source files                                                                                                  
"****************************************"                                                                              
init_mdlapi.c                                                                                                          
main.c                                                                                                                                                                                                          
ASCIIsave.c                                                                                                            
        1 file(s) copied.                                                                                              
rev_fun_gen: Creating the T:\compile/revisions_info.c file                              
revisions_info.c                                                                                                        
partition.cpp                                                                                                    
init_partition.cpp                                                                                                      
conf_partition.cpp                                                                                                      
"****************************************"                                                                              
Linking all modules 1 -- T:\run/sim_win32.exe                              
"****************************************"                                                                              
iface.c                                                                                                          
"****************************************"                                                                              
Linking all modules 2 -- T:\run/sim.mexw32                                  
"****************************************"                                                                              
   Creating library T:\run/sim.lib and object T:\run/sim.exp                                                                                            
                                                                                                                       
0
 
jkrCommented:
*scratchinghead* - does VS complain about "symbols not found" when attaching to the process? Do you get any message when you select "Go to source..."?
0
 
jr_barros_jrAuthor Commented:
No.

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

 Message
0
 
jr_barros_jrAuthor Commented:
jkr,

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.

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 11
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now