locked
Breakpoint::get_FunctionLineOffset() always return 1 for VS2012 RRS feed

  • Question

  • When breakpoint is hit, I get the Breakpoint object by calling Debugger::get_BreakpointLastHit(), then I try to get the function line offset from the acquired object by calling Breakpoint::get_FunctionLineOffset(). To my surprise, the result is always 1 even the breakpoint was hit in the middle of a function.  This happens only in Visual Studio 2012. I have verified Breakpoint::get_File() and Breakpoint::get_FunctionName() work fine.

    Does anyone has experienced similar problem? Is any workaround for this problem?

    Thanks!

    Wednesday, May 29, 2013 8:32 AM

Answers

  • According to some debugger folks this functionality was apparently cut in 2012.
    • Marked as answer by YangmeiGe Thursday, May 30, 2013 11:27 PM
    Thursday, May 30, 2013 7:38 PM

All replies

  • Useful information you have omitted:

    1:  What language is this?

    2:  Do you have a stand alone repro?

    It looks like the debugger, internally simply does this:

    *pOffset = m_pBP->GetNamedLocationLine() + 1; // Internally we're 0-based, externally, we're 1-based.

    So it seems GetNamedLocationLine is always returning 0 in your case.
    Wednesday, May 29, 2013 5:37 PM
  • The language is C++. I have created a stand alone repro in C#(the result is quite same as the C++ code). The code is shown below:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Runtime.InteropServices;
    using EnvDTE;
    using EnvDTE80;
    
    namespace DebuggerExample
    {
        class Program
        {
            static void Main(string[] args)
            {
                EnvDTE.DTE dte = (EnvDTE.DTE)Marshal.GetActiveObject(@"VisualStudio.DTE.11.0");
    
                Debugger debugger = dte.Debugger;
                Breakpoint bp = debugger.BreakpointLastHit;
                Console.WriteLine("File = {0}", bp.File);
                Console.WriteLine("File Line = {0}", bp.FileLine);
                Console.WriteLine("function = {0}", bp.FunctionName);
                Console.WriteLine("function line offset  = {0}", bp.FunctionLineOffset);
            }
         }
    }
    

    The steps to reproduce is:

    1. Bring up Visual Studio 2012 and let it attach to the process to be debugged.

    2. Set up a breakpoint in the middle of a class member, run the program and let the breakpont hit.

    3. run the stand alone application, it will show the "function line offset = 1" even the breakpoint was hit in the middle of a class member function.

    If I bring up Visual Studio 2010 and change the active object to DTE.10.0, the result is as expected.

    I understand that I can change to use the FileLine as it returned correct results for both Visual Studios.

    Thanks!

    Thursday, May 30, 2013 2:10 AM
  • According to some debugger folks this functionality was apparently cut in 2012.
    • Marked as answer by YangmeiGe Thursday, May 30, 2013 11:27 PM
    Thursday, May 30, 2013 7:38 PM