Avatar of jr_barros_jr
jr_barros_jr
 asked on

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?
Visual C++.NETC++C

Avatar of undefined
Last Comment
jr_barros_jr

8/22/2022 - Mon
jkr

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

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

ASKER
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?
jkr

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.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
jr_barros_jr

ASKER
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
jkr

Hm, what are the available configurations? Could you post the makefile?
jr_barros_jr

ASKER
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)
   

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
jkr

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
jr_barros_jr

ASKER
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.
jkr

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.
jr_barros_jr

ASKER
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.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
jr_barros_jr

ASKER
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.
jkr

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.
jr_barros_jr

ASKER
How can I build in Debug my exe? with the same options (/Zi /Yd)? If so, yes I am doing that.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
jkr

Yes, the same options. Do you get a .pdb file without '/Yd'?
jr_barros_jr

ASKER
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....

jkr

Do you have the compiler and linker output?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
jr_barros_jr

ASKER
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                                                                                            
                                                                                                                       
jkr

*scratchinghead* - does VS complain about "symbols not found" when attaching to the process? Do you get any message when you select "Go to source..."?
jr_barros_jr

ASKER
No.

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

 Message
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
jr_barros_jr

ASKER
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.