Reputation: 15806
For example, I have two projects let's say project A and project B. I have the source code of project A and project B.
Then in my project A, there are some .a
files made by project B. Project A use those .a files to compile and run.
The question is, when I run project A, I want to debug the codes in those .a
file. Is it possible? If possible, how can I do it?
I'm using Visual Studio for Mac.
Note: Project A is written in C# and Project B is written in C++.
It‘s a Xamarin project.
Upvotes: 1
Views: 1064
Reputation: 537
You can build both Debug and Release into separate preset directories in any IDE. This is a good practice for all builds - using Configuration -> Release and Debug. You may name the libraries as libname_d.lib
and libname.a
so they do not get mixed up.
Then you can link to the appropriate library (libname_d.a
) while debugging. Its a matter of choice - some may not recommend linking multiple projects into the same Solution (or Workspace), since each separate library will have a separate set of tests. These are difficult to manage in a single project.
Ideally, each library can be coded and tested separately and built into Release and Debug. This way functionality can be isolated and object-based design can be followed.
Its also important to understand the difference between .a (Linux, Mac) and .lib (Windows) - see here - What's the difference between .lib and .a files?
Upvotes: 0
Reputation: 546
If you have access to source code for both projects, I would recommend to create a solution with both projects, as you may be able to use different language projects on same solution (please check this, as an example: https://social.msdn.microsoft.com/Forums/en-US/737e2bf3-86ab-49aa-bafa-b3a3d05ce826/mixed-languages-in-visual-studio?forum=csharpgeneral).
To debug C++ code inside the C# project, check options for your current Visual Studio version, as suggested in this post: Debug c++ dll in C#
Set project A (C#) as start project, and, if references are correct, you should be able to debug .a
files referenced from project B.
Upvotes: 0
Reputation: 1104
You need to attach with Visual studio to the running process. Attaching to process with Visual Studio is done with Alt + Ctrl + P on windows.
In case the code you wish to debug is run at startup of your app, place your breakpoints and add a 30 seconds sleep (before any of your breakpoints) so you have time to attach.
When picking the process, make sure to tick the right code types to debug by clicking Select...
Upvotes: 0
Reputation: 51
If you have no source code of project B, then you can only debug in assembly mode.
If you do have source code of project B, make sure .a files reserving debug info(like dwarf) and use lldb source-map technique to perform mapping.
But, if you have .a file's source, why not just build with project B source.
Upvotes: 2