Results 1 to 26 of 26

Thread: Debugging

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    8

    Debugging

    I am stuck with our program, it freezes and for some reason - exits the main thread of the application and quits calling DoEvents. We run a loop in our application and is a server. Does anyone know how we can debug this?

  2. #2
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Debugging

    Helladen,

    I think we need a bit more information, and probably an example of some of your code before we can be of much help. From what you've said, I just don't feel like I have any idea what your problem is.

    My first thought, is to execute your program in the IDE, and see which line of code fails. If you can't reproduce the error in the IDE, then you're reduced to sprinkling Msgbox statements around in your code (with some location identifying message in the Msgbox statements), and see if you can figure out where it's crashing. As an alternative to the Msgbox approach, you might open up a text file on your desktop, and dump (append) pertinent information to that file to figure out where it's failing.

    Once you zero in on some code that's causing the problem, the answer might become obvious. If not, post some of the code here, and I'm sure several of us would be willing to stare at it and try to help out. Also, please post you code between the [code][/code] tags when posting code. These code tags can be easily inserted with the # button on the VBForums toolbar.

    Best Of Luck,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  3. #3
    gibra
    Guest

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    8

    Re: Debugging

    The problem is our codebase is at-least 50,000 to 100,000 lines of code. The crash causes the IDE to hang. Is there anyway to debug a hang application?

    We have had this bug for awhile now, it is based off of Mirage Source which was written in Visual Basic 6 in the early 2000s. We're looking to move away from Visual Basic eventually though.

    I need a way to debug it if possible, in a better environment. I've tried putting logs in the code, but it is hard to find the root culprit.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Debugging

    If DoEvents is being called, then it is likely in a loop, correct? If not, we will need a lot more information.

    Ok, if it's in a loop, then to exit the loop some condition must be met: loop naturally ends or some tracking variable's value was set, i.e., If m_Terminating = True Then Exit Do.

    So, you say your app is no longer calling DoEvents. I'm going to assume you know that to be a fact. In that case, then you need to log/monitor where you are setting your tracking variable that allows exiting to loop. A simple project-wide search for that variable offers places to add logging.

    Long story short, I don't think there is nearly enough info provided to help you, at this point. Anything we offer will be guesses.

    Edited: In your last post, you mentioned crashes. Is the crash caused by the loop exiting unexpectedly or is the crash caused somehow by DoEvents not triggering? You didn't mention crashing (did mention freezing) in your first post.

    And do note... A freezing app does not necessarily mean DoEvents stopped being called. It could very well mean that a synchronous function call (or API call like SendMessage) hadn't returned yet. Make sure you are traveling down the correct rabbit hole.

    Again, verify your DoEvents loop is/isn't exiting in this case... place a log entry immediately after the "End Loop/While" or "For/Next" statement. If log entry was written, then the loop ended. Otherwise, you may have a hung app because somewhere it's waiting for a function call that isn't returning as expected. If that's the case, we can suggest other possibilities, like it's your Mirage Source that is hanging your app, using SendMessageTimeOut instead of SendMessage, etc.
    Last edited by LaVolpe; Jul 28th, 2018 at 11:17 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    416

    Re: Debugging

    I've recently used GlowCode profiler to solve two tricky issues like this. It is a performance profiling tool but you can also use it for other things, one of which is to generate a sequential listing of all of the code routines being run so you can see exactly where the app crashes or hangs. It's a bit pricey but man it saved me tons of time. I had spent weeks trying to manually track down the cause before finding this tool.

  7. #7

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    8

    Re: Debugging

    I am trying out GlowCode profiler.

    The crash is related to the loop not executing anymore. I have tried placing code below the loop to see if it executes, but it does not. We also use multi-threaded approach in Visual Basic 6, which uses the network thread to call the main loop if it is doing a large task. We organize the loop using timers. This is not causing the crash though, but both threads quit working at the same time when this crash happens.

  8. #8
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Debugging

    Please see my edited reply regarding potential of being hung because of waiting on a function call.

    Also, when you are talking about multi-threading, are you using some homegrown code for that? some DLL? Is this application an ActiveX EXE?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  9. #9
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Debugging

    Helladen,

    That's not a huge codebase. My primary project (not counting ActiveX DLL files) is over 300 modules. I don't have an easy way to estimate lines-per-module, but 500 lines-per-module is almost certainly a very low estimate. That multiplies out to 150,000 lines of code, and I know that's an extremely conservative estimate.

    And, even if it is crashing in the IDE, you should still be able to find it. In fact, the fact that it crashes in the IDE is a good thing (as opposed to just compiled).

    I know it's a bit painful, but you've got to start putting in Msgbox statements (with location identifying information) until you can figure out where it's crashing. Through the years, I've gone down that path many times. If it's not a simple runtime error, that's just what you've got to do. (Or alternatively, as stated previously, open a file for Append on your desktop and write your location in that file, until you sort out where it's crashing.)

    This is reminiscent of the old DOS PDS-BASIC days before we had nice IDE debuggers. Sometimes, we're just thrown back to that. Hellanden, this is the way we all used to debug, once upon a time. It's a skill you should have.

    Good Luck,
    Elroy

    p.s. I know you'd like to think one of us has some "magic answer" but we don't.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  10. #10
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: Debugging

    Quote Originally Posted by Elroy View Post
    that's an extremely conservative estimate.
    You don't need to estimate. Install MZ-Tools and count how many lines your program has. It can take two minutes (to install and run).

  11. #11
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Debugging

    Quote Originally Posted by Eduardo- View Post
    You don't need to estimate. Install MZ-Tools and count how many lines your program has. It can take two minutes (to install and run).
    When you load the project group it's in the main menu Tools->MZ-Tools->Other utilities->Statistics and then you can copy/paste from the listview
    Code:
    File        File Type       Code Lines      Comment Lines   Total Lines Procedures  Controls
    Dreem15.vbg Project Group   524'635 (72%)   199'759 (27%)   724'394     26'673      8'386
    ...
    cheers,
    </wqw>

  12. #12
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    740

    Re: Debugging

    Hi, Helladen!

    I didn't completely understand your problem.
    If it's right and you can't find concrete line in your code that causes crash, you can compile your app with option "Project => Properties => Compile => v Create symbolic debug info".
    And see the piece of problematic code with WinDBG. Details here.

    Or, if it's too hard for you, just give me your app.pdb file (created after compilation) and crash dump, and I'll try to give you important info.
    Warning: app.pdb can contain private info, like process list, part of source code.
    Malware analyst, VirusNet developer, HiJackThis+ author || my CodeBank works

  13. #13
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Debugging

    Quote Originally Posted by Eduardo- View Post
    You don't need to estimate. Install MZ-Tools and count how many lines your program has. It can take two minutes (to install and run).
    Ohhh, I'll probably soon write my own add-in to do this. I'm not a huge fan of all-encompassing add-ins. And I've gotten into a mode lately of writing specific-purpose add-ins. When the mood strikes me, I'll write this one, and also post it to the codebank when I do.

    Best Regards,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  14. #14

  15. #15
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    740

    Re: Debugging

    hmm, also decided to capture a video. Sorry, no hard-rock

    Malware analyst, VirusNet developer, HiJackThis+ author || my CodeBank works

  16. #16
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: Debugging

    Quote Originally Posted by Elroy View Post
    Ohhh, I'll probably soon write my own add-in to do this. I'm not a huge fan of all-encompassing add-ins. And I've gotten into a mode lately of writing specific-purpose add-ins. When the mood strikes me, I'll write this one, and also post it to the codebank when I do.

    Best Regards,
    Elroy
    Lately, I have it normally not loaded, or even not installed. I install (and /or) load it only when I want to do something with it.

  17. #17
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: Debugging

    Quote Originally Posted by wqweto View Post
    When you load the project group it's in the main menu Tools->MZ-Tools->Other utilities->Statistics and then you can copy/paste from the listview
    Code:
    File        File Type       Code Lines      Comment Lines   Total Lines Procedures  Controls
    Dreem15.vbg Project Group   524'635 (72%)   199'759 (27%)   724'394     26'673      8'386
    ...
    cheers,
    </wqw>
    724394 lines? That's a huge project. How many years have you been writing it?

    I have a program (two programs in fact) that I started in 2011 and it has about 180K lines.
    Let's suppose that I worked 6 years, that's 30000 lines/year.

    Code:
    File        File Type       Code Lines      Comment Lines   Total Lines Procedures  Controls
    Grupo1.vbg  Project Group   169.571 (91%)   15.758 8%)      185.329     9.099       2.410

  18. #18

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    8

    Re: Debugging

    I've tried to use .PDB debug before, but the VB Runtime wasn't able to be debugged using symbol server. I tried WinDBG and Visual Studio PDB debugging. But it fails to find the symbol server .PDB for the VB6 Runtime. I have found the .DBG symbols, but they don't work inside Visual Studio.

    I will try again though. The main problem now is that the app won't crash. It just hangs, becomes unresponsive. It's just the server.

    Code:
    File	File Type	Files	Total Lines	Code Lines	Comment Lines	Blank Lines	% Code Lines	% Comment Lines	% Blank Lines	Classes	Modules	Methods	Properties	Interfaces	Structures	Enums
    NinOnline	Project	47	89,946	57,891	6,291	25,764	64%	7%	29%	26	21	2,275	27	0	129	44
      
    File	File Type	Files	Total Lines	Code Lines	Comment Lines	Blank Lines	% Code Lines	% Comment Lines	% Blank Lines	Classes	Modules	Methods	Properties	Interfaces	Structures	Enums
    NinServer	Project	18	44,416	30,137	2,514	11,765	68%	6%	26%	2	16	888	0	0	68	1
    Last edited by Helladen; Jul 30th, 2018 at 12:36 AM.

  19. #19
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Debugging

    Quote Originally Posted by Eduardo- View Post
    How many years have you been writing it?
    It's a team effort but something close to 15 years in development.

    cheers,
    </wqw>

  20. #20

  21. #21
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: Debugging

    Quote Originally Posted by Helladen View Post
    I am stuck with our program, it freezes and for some reason - exits the main thread of the application and quits calling DoEvents. We run a loop in our application and is a server. Does anyone know how we can debug this?
    If you can't find a better way, then api OutputDebugString might be a worthwhile approach, especially for server-side debugging.

    Code:
    Private Declare Sub OutputDebugString Lib "kernel32.dll" Alias "OutputDebugStringA" (ByVal lpOutputString As String)

  22. #22
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    740

    Re: Debugging

    In addition to dreammanor's post, you can use Sysinternals DebugView to catch such msgs.
    Malware analyst, VirusNet developer, HiJackThis+ author || my CodeBank works

  23. #23
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Debugging

    Okay, I loaded MZ-Tools for you guys, just for grin. 188,278 lines of code, not counting the ActiveX DLLs (and just loading the main VBP, and not the overall VBG). It doesn't look like I compete with wqweto, but it's still up there. I'm a bit amazed at how close my rough estimate was.

    Y'all Take Care,
    Elroy

    p.s. I'm immediately unloading and deleting MZ-Tools. That thing is a beast.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  24. #24
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Debugging

    You mentioned multi-threading the app. If there is any chance you blocked the main thread, then that could explain everything. Main thread blocked results in frozen GUI and the other threads "stopped" because they are waiting for a state change on your mutex (or whatever).

    Those more familiar with multi-threading (if it applies) may be able to offer free apps that can peek at those threads and give their current status/states.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  25. #25
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: Debugging

    Quote Originally Posted by Elroy View Post
    p.s. I'm immediately unloading and deleting MZ-Tools. That thing is a beast.
    LOL! It is useful for finding dead code for example.
    But I agree, I don't like to have add-ins loaded either. So in case that I have a crash or some IDE problem I don't have something to suspect.

    PS: done with the off topic.

  26. #26

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    8

    Re: Debugging

    I noticed the server has lasted 18 hours now and still going instead of 5-10 average as before.

    The multi-threading is basically calling the main loop if it hangs for more than 25ms. It uses the TCP packet thread, to process. I queue the loop with timers, so it basically would sometimes lag for a long time causing lag spikes. I disabled the multi-threading seems to been causing server instability.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width