Solved

C++ Debugging question VS.NET

Posted on 2004-08-02
10
326 Views
Last Modified: 2006-11-17
I can't tell where my program is hanging.  Is there a way to let the program run and then ask it to move to the line it is currently executing?  I am making a bunch of calls to download messages, and some of the calls are not returning.  However, I can't easily but break points in because there are about 2000 messages it could be.  I just am trying to determine the call that is not returning.  
0
Comment
Question by:jjacksn
  • 6
  • 4
10 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 11698233
Go to the task manager, pick the 'Processes' tab, select your process, right-click and choose 'Debug', this will take you straigt to the debugger. There, all you have to do is selecting 'Break' from the debug menu.
0
 
LVL 86

Expert Comment

by:jkr
ID: 11698245
BTW, under 'Build' menu, there should also be a 'Debug' subment that has the option "Attach to Process"...
0
 
LVL 5

Author Comment

by:jjacksn
ID: 11699798
That worked, the breaker is putting the green triangle at the GetProps line as the first call in the USER DEFINED code.  

      CComPtr<IMAPITable>      tablePtr;

            //Get the message da\ta
            ULONG recipientType = 1; //if we can't read the recipient type, assume its of type 1.
            ULONG pcount; SPropValue *props=0;
            string sender_name, sender_email;
---->            hr = imsg->GetProps((SPropTagArray*)m_pSenderProps,0,&pcount,&props);
            if(SUCCEEDED(hr))
            {
                  //check in here for message class if we want to, but we already did with the folders.
                  if(props[1].ulPropTag==PR_SENDER_NAME) sender_name = props[1].Value.lpszA;
                  if(props[2].ulPropTag==PR_SENDER_EMAIL_ADDRESS) sender_email = props[2].Value.lpszA;


However, when I first call break, it is breaking into xsting file at the  _Traits line.

void _Eos(size_type _Newsize)
      {      // set new length and null terminator
            _Traits::assign(_Myptr()[_Mysize = _Newsize], _Elem());
            }
Where _Newsize is 254228212.  (is that large?)

any idea what might be causing the hang?  

Does the green triangle represent the NEXT line to be executed (meaning its hanging on the string def line?), or the line that is CURRENTLY executed.  I don't really understand how the string defs could be doing anything wrong.  but, I also don't understand why it is breaking into the xstring file.  
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 86

Expert Comment

by:jkr
ID: 11699863
>>Does the green triangle represent the NEXT line to be executed (meaning its hanging on the
>>string def line?), or the line that is CURRENTLY executed

That is the next line. Go up in the call stack to see whether this function is called in a loop. BTW, that you are 'breaking' the program while executing a library function is not unusual.
0
 
LVL 5

Author Comment

by:jjacksn
ID: 11707188
the call stack looks liks:

       ntdll.dll!77f5c524()       
       kernel32.dll!77e75ee0()       
       user32.dll!77d463eb()       
       user32.dll!77d46466()       
       PSTPRX32.DLL!35618dbd()       
       PSTPRX32.DLL!35619a06()       
       PSTPRX32.DLL!356027be()       
       PSTPRX32.DLL!355fc92c()       
       PSTPRX32.DLL!355fb8ae()       
>      msvcp71d.dll!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Eos(unsigned int _Newsize=253376380)  Line 1475 + 0x22      C++
       PSTPRX32.DLL!355f9f7c()       
       IOutlook.dll!CCoOutlookExtractor::ProcessIncomingMessageData(IMessage * imsg=0x0f1a36ac, std::basic_string<char,std::char_traits<char>,std::allocator<char> > * subject=0x0012eb0c, _FILETIME * date=0x0012ea00)  Line 1522 + 0x1f      C++
       IOutlook.dll!CCoOutlookExtractor::ParseMessageFolder(short * ptProgress=0x0012ee48, unsigned long stepSize=50)  Line 1219      C++
       IOutlook.dll!CCoOutlookExtractor::ParseActiveFolder(short * ptrProgress=0x0012ee48, unsigned long stepSize=50)  Line 873 + 0x10      C++
       rpcrt4.dll!780038f7()       
       rpcrt4.dll!780791a5()       
       mscorwks.dll!791fac97()       
       System.Windows.Forms.dll!7b8227c3()       
       System.Windows.Forms.dll!7b8227a4()       
       mscorwks.dll!791b51db()       
       mscorwks.dll!791fd6a8()       
       mscorwks.dll!791fd603()       
       mscorwks.dll!791fd603()       
       mscorwks.dll!791fec1d()       
       mscorwks.dll!791feb95()       
       mscorwks.dll!791febaa()       
       mscorwks.dll!791febaa()       
       mscorwks.dll!791fea17()       
       mscorwks.dll!791f92c9()       
       System.Windows.Forms.dll!7b825880()       
       System.Windows.Forms.dll!7b8257ac()       
       System.Windows.Forms.dll!7b81ca86()       
.............

The line number 1522 is the GetProps method line.  What does the + 0x1f mean?
0
 
LVL 86

Expert Comment

by:jkr
ID: 11707225
>>What does the + 0x1f mean?

That's the offset into the function in the binary image. Are there any lengthy loops in 'ParseMessageFolder()' or 'ParseActiveFolder()'?
0
 
LVL 5

Author Comment

by:jjacksn
ID: 11707373
ParseMessageFolder takes 50 messages at a time, and loops over them, calling ParseIncomingMessage on each message.  ParseActiveFolder just calls ParseMessageFolder.  

The code hangs about 3/4s of the way through my inbox when it gets to my first IMAP header message that is not fully downloaded.  It is parsing about 10,000 messages.  

so since 1522 corresponds to the GetProps method, can I assume that is the method that is not returning?  
0
 
LVL 86

Expert Comment

by:jkr
ID: 11707437
That's what I would assume also.
0
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 11707611
BTW, to diagnose that better, I'd suggest to use

          string sender_name, sender_email;
          OutputDebugString ( "BEFORE GetProps()\n");
          hr = imsg->GetProps((SPropTagArray*)m_pSenderProps,0,&pcount,&props);
          OutputDebugString ( "AFTER GetProps()\n");
         if(SUCCEEDED(hr))
         {

and watch the output with a Debug Viewer like e.g. http://www.sysinternals.com/ntw2k/freeware/debugview.shtml
0
 
LVL 5

Author Comment

by:jjacksn
ID: 11707826
yep, that's it, the last line in the output window is before get Props, thanks.  Now i need to figure out why that's hanging
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

777 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