Dll debug question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vadym Stetsyak

    #1

    Dll debug question

    Hello!

    When I am debugging, I call the app, which loads the dll and then I can
    trace the dll. In this scenario everything is ok. But when my dll calls an
    app which loads another dll, that then lods mine, - I am not able to trace
    my dll.

    In short, the scheme looks like this: App -> SomeDLL -> MyDll.

    How can I trace my dll?
    --
    Vadym Stetsyak
    PDS



  • Jochen Kalmbach

    #2
    Re: Dll debug question

    Vadym Stetsyak wrote:
    [color=blue]
    > In short, the scheme looks like this: App -> SomeDLL -> MyDll.
    >
    > How can I trace my dll?[/color]

    It should be possible if you debug "App" (or start with App)


    --
    Greetings
    Jochen

    Do you need a memory-leak finder ?

    Comment

    • William DePalo [MVP VC++ ]

      #3
      Re: Dll debug question

      "Vadym Stetsyak" <vadym_s@ukr.ne t> wrote in message
      news:OpLUjWnXDH A.1640@TK2MSFTN GP10.phx.gbl...[color=blue]
      > When I am debugging, I call the app, which loads the dll and then I can
      > trace the dll. In this scenario everything is ok. But when my dll calls an
      > app which loads another dll, that then lods mine, - I am not able to trace
      > my dll.[/color]

      Debuggers like the one VC++ uses can debug a single process at a time. If
      another process loads your DLL you need another instance of the debugger.

      I see that Nishant has already pointed out that you can instrument your code
      with an

      _asm int 3

      to force a JIT debugger to attach at runtime. DebugBreak() does the same
      thing.

      Regards.
      Will



      Comment

      • Carl Daniel [VC++ MVP]

        #4
        Re: Dll debug question

        William DePalo [MVP VC++ ] wrote:[color=blue]
        > "Vadym Stetsyak" <vadym_s@ukr.ne t> wrote in message
        > news:OpLUjWnXDH A.1640@TK2MSFTN GP10.phx.gbl...[color=green]
        >> When I am debugging, I call the app, which loads the dll and then I
        >> can trace the dll. In this scenario everything is ok. But when my
        >> dll calls an app which loads another dll, that then lods mine, - I
        >> am not able to trace my dll.[/color]
        >
        > Debuggers like the one VC++ uses can debug a single process at a
        > time. If another process loads your DLL you need another instance of
        > the debugger.[/color]

        VC7 and above, as well as the system debuggers (WinDbg, ntsd, cdb) can
        attach to multiple processes at once, just in case you do need to debug two
        processes both using your DLL at the same time.

        -cd


        Comment

        • William DePalo [MVP VC++ ]

          #5
          Re: Dll debug question

          "Carl Daniel [VC++ MVP]" <cpdaniel@nospa m.mvps.org> wrote in message
          news:ex77U7nXDH A.3444@tk2msftn gp13.phx.gbl...[color=blue]
          > VC7 and above, as well as the system debuggers (WinDbg, ntsd, cdb) can
          > attach to multiple processes at once, just in case you do need to debug[/color]
          two[color=blue]
          > processes both using your DLL at the same time.[/color]

          Thanks for that.

          I thought such shenanigans were the province of windbag and co. and
          SoftIce. Guess I should spend more time with VC7. :-)

          Regards,
          Will



          Comment

          • Vadym Stetsyak

            #6
            Re: Dll debug question

            I already have 1 process. Maybe the trouble is that the real picture looks
            like this:

            Managed App -> ManagedDll(Some P/Invoke method) -> C-style Dll

            When the scheme is ManagedApp -> C-style Dll everything is ok - I can trace
            C_Dll.

            "William DePalo [MVP VC++ ]" <willd.no.spam@ mvps.org> wrote in message
            news:uBkUU2nXDH A.2528@TK2MSFTN GP09.phx.gbl...[color=blue]
            > "Vadym Stetsyak" <vadym_s@ukr.ne t> wrote in message
            > news:OpLUjWnXDH A.1640@TK2MSFTN GP10.phx.gbl...[color=green]
            > > When I am debugging, I call the app, which loads the dll and then I can
            > > trace the dll. In this scenario everything is ok. But when my dll calls[/color][/color]
            an[color=blue][color=green]
            > > app which loads another dll, that then lods mine, - I am not able to[/color][/color]
            trace[color=blue][color=green]
            > > my dll.[/color]
            >
            > Debuggers like the one VC++ uses can debug a single process at a time. If
            > another process loads your DLL you need another instance of the debugger.
            >
            > I see that Nishant has already pointed out that you can instrument your[/color]
            code[color=blue]
            > with an
            >
            > _asm int 3
            >
            > to force a JIT debugger to attach at runtime. DebugBreak() does the same
            > thing.
            >
            > Regards.
            > Will
            >
            >
            >[/color]


            Comment

            • Jochen Kalmbach

              #7
              Re: Dll debug question

              Vadym Stetsyak wrote:
              [color=blue]
              > I already have 1 process. Maybe the trouble is that the real picture
              > looks like this:
              >
              > Managed App -> ManagedDll(Some P/Invoke method) -> C-style Dll
              >
              > When the scheme is ManagedApp -> C-style Dll everything is ok - I can
              > trace C_Dll.[/color]

              Maybe you can start the app and then attach to the app with the debugger
              and then you HAVE TO select "nativ" and "managed" (optional) to debug your
              DLL.

              You also could try to start the app from the debugger, but you have to
              choose somehow to debug also nativ code.

              --
              Greetings
              Jochen

              Do you need a memory-leak finder ?

              Comment

              Working...