locked
Debug Engine: How can I get the path to a source file the user opened using the find source dialog? RRS feed

  • Question

  • Hi,

    I have a debug engine implementation for c/c++ programs, and I cannot find a way to get the path to files which the user browsed to using the find source dialog box.

    We have some situations where the filepath in our debug info does not correspond to one on the users local machine. When we return a document context to the SDM containing this path, it displays the find source dialog and the user browses to a path.

    Can anyone help me find out what the path is that was chosen in the dialog?

    We are targeting VS 2008 and 2010 at the moment.

    Thanks in advance,

    alex

    Thursday, October 13, 2011 8:45 AM

Answers

  • Hi Alex,

    I spent some time diving through the debugger sources, and there doesn't appear to be any extensibility access points here. The debugger has an internal cache of files/paths that I can't find any hooks into. The only thing I noticed that comes close would be trying to leverage the solution properties for that Debug Source Files page. I noticed that this does get additional paths, but these paths don't exactly sync up with that internal cache I mentioned. For example, if you were to manually remove said path from that property page, the path isn't removed from that internal cache.

    Sincerely,


    Ed Dore
    Tuesday, November 15, 2011 1:15 AM

All replies

  • Hello ,

    Thank you for your question.

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Thank you for your understanding and support.

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, October 17, 2011 9:20 AM
  • Thanks for the update.

    alex

    Thursday, October 20, 2011 8:01 AM
  • I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Hi,

    Have you had any update from second level support?

    Do you have an estimate how long a response might take?

    Thanks.

    Friday, October 28, 2011 1:37 PM
  • Hi Apostlethwaite,

    Thank you for your updating. We are still looking into this issue, we will update this thread as soon as possible.

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, October 31, 2011 7:53 AM
  • okay, thank you.

    alex

    Monday, October 31, 2011 8:32 PM
  • Hi Alex,

    What kind of debug engine it is? Are you developing code yourself?

    And you mentioned "We have some situations where the filepath in our debug info does not correspond to one on the users local machine", does the issue occur randomly or with specific scenario? Any way we can have a local repro to test?

     

    Thanks & Regards,

    Leon


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Thursday, November 3, 2011 5:37 AM
    Answerer
  • Hi Leon,

    Yes I am one of the developers of the engine. It is for debugging processes on an embedded device.

    It is written in C++, our starting point was the ATL COM Debug Engine on MSDN (http://msdn.microsoft.com/en-us/library/bb145934.aspx).

    One example of this scenario is if an executable is built by a continuous integration server.

    If the build server gets the code from source control to c:\svn, the executable file may contain debug info such as:

    c:\svn\project1\main.cpp

    Later, a developer fetches this executable from the build server, loads it on the device, and starts debugging.

    On his machine, the source is located at

    d:\myworkspace\project1\main.cpp

    When the debug engine returns the file path from the debug info, it is not found on the local machine.

    The dialog box that is then shown to the user allows them to find the file on their local machine.

     

    My question is how can we get that filepath that they browsed for, so we can recognise that

    c:\svn\project1\main.cpp really means d:\myworkspace\project1\main.cpp

    for the duration of this debug session.

     

    You can reproduce this situation by using a C++ Win32 application, building it on machine A, then debugging it on machine B, with the source files in different places. The PDB file will contain paths that make sense on machine A, so browsing for source on machine B should be required.

    The native debug engine in Visual Studio appears to handle this quite well.

    Thanks,

    Alex

    Thursday, November 3, 2011 2:13 PM
  • Hi Alex,

    Are you using Visual Studio for remote debugging with the embedded device or using your own debugger for that? I mean which software will show the dialog box to ask for the file path for the source code? I just created a smart device project in VS2005 on one of my computers and tried to debug it on another computer, but unfortunately there is no such kind of dialog box displayed, only disassembly is displayed in the code window. Which kind of feature are you requesting for?

     

    Best Regards,

    Jimmy Zhu


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Monday, November 7, 2011 3:08 AM
    Answerer
  • Hi,

    We have implemented a Port Supplier and Debug Engine, and register them with Visual Studio in the AD7Metrics section of registry.

    We also have a VS add-in, which allows debugging to be initialized using this engine/port suppllier by calling IVsDebugger.LaunchDebugTargets.

    The dialog box in question is shown by Visual Studio:

    I got here by doing the following:

    • Create new, empty Win32 C++ Console Application
    • Create main.cpp, with minimal main function.
    • Build the project.
    • Rename main.cpp to something else (_main.cpp)
    • Start Debugging with F10/ Step Into command
    • If you are prompted to rebuild the project, say No. This means the pdb file contains debug info pointing at main.cpp not your renamed file.
    • You should be presented with the browse dialog.

    I have recorded these steps using the Win 7 problem steps recorder, see: http://dl.dropbox.com/u/186235/missing_source.zip

    Thanks,

    Alex

    Monday, November 7, 2011 9:58 AM
  • Hi,

    Was the information I provided useful? Do you need anything else to continue this thread?

    Thanks,

    Alex

    Monday, November 14, 2011 8:49 AM
  • Hi Alex,

    I spent some time diving through the debugger sources, and there doesn't appear to be any extensibility access points here. The debugger has an internal cache of files/paths that I can't find any hooks into. The only thing I noticed that comes close would be trying to leverage the solution properties for that Debug Source Files page. I noticed that this does get additional paths, but these paths don't exactly sync up with that internal cache I mentioned. For example, if you were to manually remove said path from that property page, the path isn't removed from that internal cache.

    Sincerely,


    Ed Dore
    Tuesday, November 15, 2011 1:15 AM
  • Hi Ed,

    Thanks for the update.

    We do have a VS Package as part of toolset, so I will consider the solution file lists you have mentioned.

    Thanks to all for your time.

    alex

    Tuesday, November 15, 2011 3:14 PM
  • Hi Alex,

    Wish I had a better answer for you :-).

    One other thought though. If you have a package, and simply looking to keep track of what locations these files were originally opened from; you could implement your own cache, by implementing IVsRunningDocTableEvents.OnAfterFirstDocumentLock, or IVsRunningDocTableEvents.OnBeforeDocumentWindowShow, and save away the path.

    Just a thought.

    Ed...


    Ed Dore
    Tuesday, November 15, 2011 11:41 PM
  • Hi Ed,

    Thanks for the follow up.

    I'll take a look at the running doc table and see what info I can get.

    From reading MSDN that sounds like it'll give me the path to the document (exactly what I'm after), then I can hand that information over to the debug engine and go from there.

    I'll see how it goes.

    Cheers,

    alex

    Wednesday, November 16, 2011 10:25 PM