Jump to content
Sign in to follow this  
Neutral General

Debugging multiple DLLs simultaneously

Recommended Posts

Hello,

 

I've got an application which dynamically loads multiple DLLs from my project group.

All those DLLs are exposing a small API they use to communicate with each other (and the exe).

Debugging what happens inside a DLL isn't a problem. I can just attach the debugger to the process and it works.

But what do I do if I'm in a debugging session in foo.dll with a break point on an API function calling code in bar.dll

I would like to step into this function but I don't really know how I could do that. 

My first plan was to stop at a breakpoint on the call, detach the debugger, switch projects and reattach it to bar.dll so I can debug the inside of the call.

But as soon as I detach the debugger, the process just continues execution. 

 

Does anyone know a good solution to this?

Edited by Neutral General

Share this post


Link to post

Brute force method: Add a MessageBox call instead of a breakpoint, so the program will stop and wait for you to attach.

Share this post


Link to post
2 hours ago, Neutral General said:

That's not the reply I was hoping for but I guess there's no better way to do it 😞

There might be a better way, I just don't know it.

Share this post


Link to post
program Project1;

{$APPTYPE CONSOLE}

{$R *.res}


uses
  System.SysUtils,
  Winapi.Windows;

procedure Main;
var
  I: Integer;
begin
  Writeln('Start');

  while not IsDebuggerPresent do
  begin
    Writeln('I''m waiting for you!');
    Sleep(100);
  end;

  for I := 1 to 1000 do
    Writeln(' I:', I);

  Writeln('End');
end;

begin
  try
    Main;
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;

end.

Try the good old While-Not-IsDebuggerPresent-Trick! 

Edited by TiGü
  • Like 1
  • Thanks 1

Share this post


Link to post
14 hours ago, David Heffernan said:

Build a monolithic executable and then the problems disappear. 

I guess it will have a good reason/requirement why he needs to use an application with multiple DLLs. :classic_huh:

Share this post


Link to post
14 hours ago, David Heffernan said:

Build a monolithic executable and then the problems disappear.  

Considering you'll have to compile all the DLLs with every new release anyway in order to avoid at least part of DLL-Hell I fullheartedly agree. Furthermore DLLs are quite a security issue:
https://www.youtube.com/watch?v=HVigruKph74

 

Share this post


Link to post
17 minutes ago, Sherlock said:

Considering you'll have to compile all the DLLs with every new release anyway in order to avoid at least part of DLL-Hell I fullheartedly agree. Furthermore DLLs are quite a security issue:
https://www.youtube.com/watch?v=HVigruKph74

 

I've got an application (windows service) that (in the best case) shouldn't be shutdown ever. But there are going to be updates to the application. So in order to not have to shut down the whole service, the service is modular and can just temporary unload a DLL, update and then reload it. That's not really doable with a monolithic application.

Share this post


Link to post
40 minutes ago, Neutral General said:

But there are going to be updates to the application. So in order to not have to shut down the whole service, the service is modular and can just temporary unload a DLL, update and then reload it.

It is always good to try and be better than the hosting OS, and if the service is that vital, I'm sure you made risk assessments leading to counter measures for DLL-injection and the overall adverse effects of DLL-Hell. If you did it just because you could...I strongly advise to reconsider.

 

But we are drifting away from the topic. Sorry for that.

Share this post


Link to post
4 hours ago, Neutral General said:

I've got an application (windows service) that (in the best case) shouldn't be shutdown ever. But there are going to be updates to the application. So in order to not have to shut down the whole service, the service is modular and can just temporary unload a DLL, update and then reload it. That's not really doable with a monolithic application.

It will be shutdown when the OS updates. Also, if you want to make it hot upgradeable, make a monlotihic DLL hosted in a thin executable. 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×