Thread: Code debugging services

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    43

    Code debugging services

    Hi,

    Is there any company or companies in existence which will debug my C++ WINAPI code for money? I have this really annoying bug which I have been trying to track down for months, and I'm almost at my wits end with it! It seems completely inexplicable but there must be some reasonable explanation for it. However I am at the stage where no-one really wants to look at my code but I am prepared to pay someone some money if they can tell me what the hell is going on!
    Windows XP Professional SP2, Code::Blocks Studio 1.0rc2, GCC/G++ 3.4.2 (20040916-1), mingw32-make 3.80.0-3, GDB 5.2.1-1, W32API 3.6

    MingW Runtime 3.9, BinUitls 2.15.91 (20040904-1), MingW Utilities 0.3, Tcl/Tk 8.4.1-1

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by kidburla View Post
    Hi,

    Is there any company or companies in existence which will debug my C++ WINAPI code for money? I have this really annoying bug which I have been trying to track down for months, and I'm almost at my wits end with it! It seems completely inexplicable but there must be some reasonable explanation for it. However I am at the stage where no-one really wants to look at my code but I am prepared to pay someone some money if they can tell me what the hell is going on!
    If you are ready to pay money maybe you should firstly try some programs like PCLint for static code checking and BoundsChecker - for dynamic code checking?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    This kind of thing makes me sad.
    Debugging is part of what you do as a programmer you know, finding out why the things you have written don't work. Otherwise it'll happen again and again, each time you'll have to go running to someone else's solution to sort yourself out.

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    43
    Quote Originally Posted by SMurf View Post
    This kind of thing makes me sad.
    Debugging is part of what you do as a programmer you know, finding out why the things you have written don't work. Otherwise it'll happen again and again, each time you'll have to go running to someone else's solution to sort yourself out.
    Normally I would agree with you. But with this particular problem I feel like I have tried *everything* and like I said, I have worked on it for months. I literally can't find anything else to try. Maybe this means I am a bad programmer. But I have been programming for 6 years, and I have never asked for help in this way before. It's just that a solution to this particular problem completely eludes me. So what I'm trying to say is, it makes ME sad too. But I have run out of other options.

    Surely there must be a company which offers this kind of service? I will try the programs you mentioned but I am not very hopeful.
    Windows XP Professional SP2, Code::Blocks Studio 1.0rc2, GCC/G++ 3.4.2 (20040916-1), mingw32-make 3.80.0-3, GDB 5.2.1-1, W32API 3.6

    MingW Runtime 3.9, BinUitls 2.15.91 (20040904-1), MingW Utilities 0.3, Tcl/Tk 8.4.1-1

  5. #5
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    What specifically is the bug?

  6. #6
    Registered User
    Join Date
    Oct 2005
    Posts
    43
    Quote Originally Posted by abachler View Post
    What specifically is the bug?
    Okay, I wasn't going to post the actual bug in here because it's kinda weird, but here goes anyway...

    My program draws fractals from actual mathematical functions. Because of this I have an inbuilt function parser which is contained within a class called TMathFunction. If I run these functions at the start of the program, they work fine. In my program I have a trackbar which updates a text box when it is dragged backwards and forwards, and this works fine too. However, if I don't run the methods in the TMathFunction class at the beginning of the program, then the trackbar does not report back its values properly. Specifically, if I have created a window when I run the TMathFunction methods, then it causes the trackbar to not work. There is no reference within the TMathFunction methods to the trackbar or anything else to do with the Windows API.

    So I leave the functions at the start and they work fine. However, if I so much as create a new pop-up messagebox just before running the methods, it causes the trackbar to not work.

    This is a problem because I want the TMathFunction methods to work on user input, not just from the hard-coded test functions I have put in. Otherwise, what is the point of having a parser? But as soon as I have popped up a window to let the user enter the math functions to parse, it creates a situation where I can't run the TMathFunction methods, or the trackbar will cease to work.
    Windows XP Professional SP2, Code::Blocks Studio 1.0rc2, GCC/G++ 3.4.2 (20040916-1), mingw32-make 3.80.0-3, GDB 5.2.1-1, W32API 3.6

    MingW Runtime 3.9, BinUitls 2.15.91 (20040904-1), MingW Utilities 0.3, Tcl/Tk 8.4.1-1

  7. #7
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    OK, the problem might be with the trackbar code. can you post the function declaration and the line from your code where you call it?

  8. #8
    Registered User
    Join Date
    Oct 2005
    Posts
    43
    Quote Originally Posted by abachler View Post
    OK, the problem might be with the trackbar code. can you post the function declaration and the line from your code where you call it?
    The thing is though that the trackbar does work when the TMathFunction methods are called before window creation. Here is most of the relevant code (most of the file is missed out as it is irrelevant and otherwise it would be too long).

    Code:
    #include <iomanip>
    #include <sstream>
    #include <cstdlib>
    #include "windows.h"
    #include "commctrl.h"
    #include "ifschooserwindow.hpp"
    
    #include "debug.hpp"
    
    using namespace std;
    
    void TIFSChooserWindow::ConstructIFSEntryWindow()
    {
     //...
     
     //Create the trackbar
     ProbabilityTrackbar = CreateProbabilityTrackbar();
     
     //...
    
     ProbabilityEditBox = CreateIFSEntryWindowEditBox(ENTRYCHILD_PROBABILITYEDITBOX, 5, IFSEntryWindowHeight - 110, 50, false);
    
     //...
    
     return;
    }
    
    //...
    
    HWND TIFSChooserWindow::CreateProbabilityTrackbar()
    {
     return CreateWindowEx(
     (DWORD) NULL,
     TRACKBAR_CLASS,
     "Probability",
     (WS_CHILD | WS_VISIBLE | TBS_HORZ),
     5,
     IFSEntryWindowHeight - 85,
     IFSEntryWindowWidth - 10,
     30,
     IFSEntryWindow,
     (HMENU) ENTRYCHILD_PROBABILITYTRACKBAR,
     AppInst,
     NULL
     );	
    }
    
    //...
    
    HWND TIFSChooserWindow::CreateIFSEntryWindowEditBox(int ID, int x, int y, int Width, bool PartOfTabs)
    {
    	if (PartOfTabs)
    	{
      return CreateWindowEx(
      (DWORD) NULL,
      "EDIT",
      NULL,
      (WS_CHILD | WS_BORDER),
      x,
      y,
      Width,
      20,
      IFSEntryWindow,
      (HMENU) ID,
      AppInst,
      (LPVOID) NULL
      );
    	}
     else
     {
      return CreateWindowEx(
      (DWORD) NULL,
      "EDIT",
      NULL,
      (WS_CHILD | WS_VISIBLE | WS_BORDER),
      x,
      y,
      Width,
      20,
      IFSEntryWindow,
      (HMENU) ID,
      AppInst,
      (LPVOID) NULL
      );
     }
    }
    
    LRESULT CALLBACK TIFSChooserWindow::EntryWndProc(HWND hwnd, UINT MsgIdent, WPARAM wParam, LPARAM lParam)
    {
     switch(MsgIdent)
     {
      //...
      if (HIWORD(wParam) == EN_CHANGE)
      {
      	if (LOWORD(wParam) == ENTRYCHILD_PROBABILITYEDITBOX)
      	{
      		UpdateProbabilityTrackbar();
      	}
      }
      break;
      //...
      case WM_HSCROLL:
      UpdateProbabilityEditBox();
      break;
      //...
      default:
      return DefWindowProc(hwnd, MsgIdent, wParam, lParam);
      break;
     }
    
     return 0;
    }
    
    LRESULT CALLBACK TIFSChooserWindow::GlobalEntryWndProc(HWND hwnd, UINT MsgIdent, WPARAM wParam, LPARAM lParam)
    {
     TIFSChooserWindow *self;
    
     switch(MsgIdent)
     {
      case WM_CREATE:
      self = (TIFSChooserWindow *) ((CREATESTRUCT *) lParam)->lpCreateParams;
      SetWindowLongPtr(hwnd, GWLP_USERDATA, ((LONG_PTR) self));
      return self->EntryWndProc(hwnd, MsgIdent, wParam, lParam);
      break;
      default:
      self = (TIFSChooserWindow *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
      return self->EntryWndProc(hwnd, MsgIdent, wParam, lParam);
      break;
     }
    
     return 0;
    }
    
    //...
    
    void TIFSChooserWindow::UpdateProbabilityTrackbar()
    {
    	float CurrentProb;
    	TCHAR *s = new TCHAR[5];
    	
    	s[0] = (TCHAR) 5; //Required by the EM_GETLINE message.
    	
    	SendMessage(ProbabilityEditBox, EM_GETLINE, (WPARAM) 0, (LPARAM) s);
    	CurrentProb = strtod(s, NULL); //Returns 0.0 if invalid.
    	SendMessage(ProbabilityTrackbar, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) (int) (CurrentProb * 100));
    	
    	delete s;
    	
    	return;
    }
    
    void TIFSChooserWindow::UpdateProbabilityEditBox()
    {
    	float CurrentProb;
    	stringstream ss;
    	
    	CurrentProb = ((float) SendMessage(ProbabilityTrackbar, TBM_GETPOS, 0, 0)) / 100;
    	
    	ss << setprecision(3) << CurrentProb;
    	SendMessage(ProbabilityEditBox, WM_SETTEXT, 0, (LPARAM) ss.str().c_str());
    	
    	return;
    }
    
    //...
    Windows XP Professional SP2, Code::Blocks Studio 1.0rc2, GCC/G++ 3.4.2 (20040916-1), mingw32-make 3.80.0-3, GDB 5.2.1-1, W32API 3.6

    MingW Runtime 3.9, BinUitls 2.15.91 (20040904-1), MingW Utilities 0.3, Tcl/Tk 8.4.1-1

  9. #9
    Registered User pronecracker's Avatar
    Join Date
    Oct 2006
    Location
    netherlands
    Posts
    158
    Not to be obvious, but let me say such problems lie always in the code you consider irrelevant.

  10. #10
    Registered User
    Join Date
    Oct 2005
    Posts
    43
    Quote Originally Posted by pronecracker View Post
    Not to be obvious, but let me say such problems lie always in the code you consider irrelevant.
    Obviously I could post my entire 2500-line program here. However, I do not think that all the code which manages the other controls in this window, such as creating buttons and tabs, is relevant to this example, where the original poster abachler simply asked me to "post the function declaration and the line from your code where you call it".
    Windows XP Professional SP2, Code::Blocks Studio 1.0rc2, GCC/G++ 3.4.2 (20040916-1), mingw32-make 3.80.0-3, GDB 5.2.1-1, W32API 3.6

    MingW Runtime 3.9, BinUitls 2.15.91 (20040904-1), MingW Utilities 0.3, Tcl/Tk 8.4.1-1

  11. #11
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    well, obviously everything you have thought of doesnt work, so if you want our help thats fine, we are happy to oblige, but dont vent your frustration on us, as its not our fault that your code is buggy.

    The reason I asked for just the declaration and the line where you call it is I strongly suspect you are using pointers to local variables that may be going out of focus before the function processes them.
    Last edited by abachler; 05-29-2007 at 12:10 PM.

  12. #12
    Registered User
    Join Date
    Oct 2005
    Posts
    43
    Quote Originally Posted by abachler View Post
    well, obviously everything you have thought of doesnt work, so if you want our help thats fine, we are happy to oblige, but dont vent your frustration on us, as its not our fault that your code is buggy.

    The reason I asked for just the declaration and the line where you call it is I strongly suspect you are using pointers to local variables that may be going out of focus before the function processes them.
    I am not venting my frustration. I was merely illustrating my reasoning for not posting my entire program, but only the sections which I considered relevant, with good reason I think. If you think that there was some other way that I should have responded to the comment by pronecracker then please tell me what that is. If you want me to post my entire program then I will. I just don't think most people will be bothered to read it. They will probably ask "that code is 2500 lines long! where is the section to do with the trackbar?"

    I have posted the declaration and the line where I called it. I presume that by declaration you mean the declaration of the window procedure which processes the messages for the trackbar. If some other declaration is required then please tell me.
    Last edited by kidburla; 05-29-2007 at 04:51 PM.
    Windows XP Professional SP2, Code::Blocks Studio 1.0rc2, GCC/G++ 3.4.2 (20040916-1), mingw32-make 3.80.0-3, GDB 5.2.1-1, W32API 3.6

    MingW Runtime 3.9, BinUitls 2.15.91 (20040904-1), MingW Utilities 0.3, Tcl/Tk 8.4.1-1

  13. #13
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Where are you calculating the dimensions? ie IFSEntryWindowHeight/width

    Is is possible these are too small/large?

    Are you checking the returns from the Create functions to ensure that the windows all have valid HWNDs.

    One possibility is that the window is first created small and then maximised (this is standard to all apps). Your math functions may slow the app down long enough for the main window to be maximised (WM_SIZE msg has time to be processed) before the TrackBar is created.

    Check/add a WM_SIZE handler and see if that makes any difference.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. backward debugging in Visual Studio??
    By George2 in forum Tech Board
    Replies: 12
    Last Post: 11-05-2006, 02:17 AM
  2. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  3. Replies: 8
    Last Post: 04-28-2003, 07:29 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Debugging leads to buggy code and longer hours?
    By no-one in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 01-28-2002, 11:14 AM