Solved

Debug

Posted on 2011-03-08
20
685 Views
Last Modified: 2012-05-11
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
Comment
Question by:jr_barros_jr
  • 11
  • 9
20 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 35072258
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
 

Author Comment

by:jr_barros_jr
ID: 35072733
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
 
LVL 86

Expert Comment

by:jkr
ID: 35072768
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
 

Author Comment

by:jr_barros_jr
ID: 35072960
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
 
LVL 86

Expert Comment

by:jkr
ID: 35073130
Hm, what are the available configurations? Could you post the makefile?
0
 

Author Comment

by:jr_barros_jr
ID: 35073246
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
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 35073347
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
 

Author Comment

by:jr_barros_jr
ID: 35073868
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
 
LVL 86

Expert Comment

by:jkr
ID: 35074073
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
 

Author Comment

by:jr_barros_jr
ID: 35074353
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:jr_barros_jr
ID: 35074658
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
 
LVL 86

Expert Comment

by:jkr
ID: 35074848
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
 

Author Comment

by:jr_barros_jr
ID: 35074892
How can I build in Debug my exe? with the same options (/Zi /Yd)? If so, yes I am doing that.
0
 
LVL 86

Expert Comment

by:jkr
ID: 35075003
Yes, the same options. Do you get a .pdb file without '/Yd'?
0
 

Author Comment

by:jr_barros_jr
ID: 35075069
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
 
LVL 86

Expert Comment

by:jkr
ID: 35075250
Do you have the compiler and linker output?
0
 

Author Comment

by:jr_barros_jr
ID: 35083024
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
 
LVL 86

Expert Comment

by:jkr
ID: 35085508
*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
 

Author Comment

by:jr_barros_jr
ID: 35086847
No.

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

 Message
0
 

Author Comment

by:jr_barros_jr
ID: 35087829
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now