Debugging or logging extensions

I’m trying to debug an extension I am writing and I have done something that is completely stopping the extension from being recognised by GP4 at start-up. Is there any form of logging or debugging possible for the moment when GP scans the extensions in the folder and requests the XML description from the .dll file?

I guess only @dhj can answer this. I end up constantly building as I go, so always know what it was that caused an issue.

Although my ‘issues’ are usually crashing GP rather than the extension not being recognised.

In terms of basics:

  • Does it show up in the options window and is activated/deactivated?
  • I assume you don’t have recent versions to roll back to?

No, it doesn’t appear in the Extensions menu.

I’ve pretty much narrowed it down to when I add in a new class that references the Ultralight library (back to working on using a Web based UI), but can’t for the life of me see why that would stop the extension being recognised since the GetProductDescription() call is still there in LibMain with a valid XMLProductDescription string to return.

Do you still have the LibMain class defined?

All of mine start with:

class LibMain : public gigperformer::sdk::GigPerformerAPI
{
protected:
    int GetPanelCount() override;
    std::string GetPanelName(int index) override;
    std::string GetPanelXML(int index) override;
etc.

This is assuming c++ code.

Yes, mine is more or less the same:

#pragma once

#include "gigperformer/sdk/GPMidiMessages.h"
#include "gigperformer/sdk/GPUtils.h"
#include "gigperformer/sdk/GigPerformerAPI.h"
#include "gigperformer/sdk/types.h"

#include "SongSelector.h"

class LibMain : public gigperformer::sdk::GigPerformerAPI
{
  protected:
    int GetPanelCount() override;
    std::string GetPanelName(int index) override;
    std::string GetPanelXML(int index) override;

    // These are for creating menu items in Gig Performer that can be used to
    // trigger external functions provided by the extension developer
    int GetMenuCount() override;
    std::string GetMenuName(int index) override;
    void InvokeMenu(int itemIndex) override;

  public:
    // These must be here but no need to do anything unless you want extra behavior
    explicit LibMain(LibraryHandle handle) : GigPerformerAPI(handle)
    {
    }

my issue being when I include my SongSelector.h header file which brings in references to a UI library… without that it works as per the example extension from GitHub that it is based upon.

I believe that @simon may have an answer :slight_smile:

Thanks, @npudar! :slight_smile: I have a few pointers:

  • You cannot debug public Gig Performer builds in a classical sense as these have a mechanism in place that crashes
    Gig Performer if a debugger (or at least a program halt initiated by a debugger) is detected.
  • You can still send data to stdout (“printf-style” or in the case of C++ cout-style debugging :smile:).
    To see these messages, you need to have stdout attached to a terminal. On macOS, you can do this by opening the Gig
    Performer executable (as opposed to the app bundle directly in the terminal), like so:
    $ /Applications/GigPerformer4.app/Contents/MacOS/GigPerformer4
    
    You can tell that stdout is attached to your terminal by the fact that you do not see a new prompt.
    The terminal remains “blocked” until Gig Performer is closed.
    On Windows, you can probably do the same thing and open the exe from the command prompt, but I have not tested
    it there. If you’re on windows and this does not work, you could still try writing to a file.
  • I would probably start by putting a log message in the constructor of LibMain. If you do not even see that one,
    check if you have any static variables. The initialization of static variables will happen even before LibMain
    is initialized (and if you initialize objects with constructors, actual code will be executed of course).
  • If you do not find anything there with either approach, you can still go a level deeper by digging into the C++
    SDK code. If you get to that point, I can give you some hints, if you want :slight_smile:

I hope that helps :raised_hands:

2 Likes

Thank you, @simon , that very much does help.

I’ve managed to work out the issue is the class I am building to contain the code that is specific to my extension as opposed to the standard stuff in LibMain. It is likely failing in some way and that is causing it to not be able to be queried by GP.

I’m slowly commenting stuff out of it to see which element is the culprit.

OK, I have zeroed in on the culprit and it is as soon as I try to bind in the UI library. I am trying to use Ultralight (https://ultralig.ht/) for UI duties (as opposed to JUCE) as the HTML/JS/CS/jQuery based UI better suits the application of the extension I’m trying to write (plus I’ve already got most of it written in a fully-fledged in-browser app).

I am including a class with the following code (via #include "SongSelector.h" in LibMain.h):

SongSelector.h:

#pragma once

#include <AppCore/AppCore.h>
#include <JavaScriptCore/JavaScript.h>
#include <Ultralight/Ultralight.h>

using namespace ultralight;

class SongSelector : public WindowListener, public ViewListener
{
  private:
    RefPtr<App> app_;
    RefPtr<Window> window_;
    RefPtr<Overlay> overlay_;

  public:
    SongSelector();
    void showSelector();
};

SongSelector.cpp:

#include "SongSelector.h"

 
const char *htmlString()
    {
    return R"(
    <html>
      <head>
      </head>
      <body>
        <div>
          <h1>Hello World!</h1>
          <p>Welcome to Ultralight!</p>
        </div>
      </body>
    </html>
    )";
};


SongSelector::SongSelector()
{
    showSelector();
}

void SongSelector::showSelector()
{
/*
    app_ = App::Create();
	window_ = Window::Create(app_->main_monitor(), 900, 600, false, kWindowFlags_Titled);
	window_->SetTitle("Ultralight Sample 2 - Basic App");
	overlay_ = Overlay::Create(window_, window_->width(), window_->height(), 0, 0);
	overlay_->view()->LoadHTML(htmlString());
	window_->set_listener(this);
	overlay_->view()->set_view_listener(this);    
*/
}

Even with the const char *htmlString() declaration and the code in SongSelector::showSelector commented out in the .cpp file, just the Ultralight includes and references in the .h file are enough to stop the extension from registering.

The Ultralight related code is pulled straight from one of their C++ examples. I realise the issue is most likely to be within Ultralight, but can anyone, off the top of their head, see anything amiss with my general declaration of the SongSelector class?

You mean apart from the use of Javascript? :stuck_out_tongue:

1 Like

Strong-typing is for the unadventurous :stuck_out_tongue_winking_eye:

…says the guy with the bug :heart_eyes::innocent:

1 Like

:laughing: touché

1 Like