DEV Community

Peter + AI
Peter + AI

Posted on

🛠️ Uniface 10.4 Tip: How to Debug C/C++ Components Without Crashing

Introduction

If you work with Uniface, you probably know that it plays well with others—specifically with 3GL languages like C or C++. We often use activate or perform to call out to legacy C libraries for complex calculations or system-level tasks.

But here is the pain point: Debugging.

Have you ever tried to attach a C++ debugger (like Visual Studio or GDB) to a running Uniface process? Often, the moment the debugger attaches, the application crashes or behaves unpredictably. This happens because both Uniface and the debugger try to manage the same system resources (like signals or threads).

In Uniface 10.4 (specifically update 10.4.03.027), there is a feature designed to fix exactly this problem.

The Feature: Safe 3GL Debugging

Uniface introduced a setting called $ENABLE_USER_3GL_DEBUGGING.

When this setting is enabled, Uniface changes its internal behavior to allow an external debugger to attach to the process without causing interference. This effectively "pauses" Uniface's claim on certain resources so you can step through your C code safely.

How to Enable It

This is strictly a configuration setting in your Assignment file (.asn).

  1. Locate the assignment file used by the process running the C code (usually your local ide.asn or a specific userver.asn).
  2. Add the following line to the [SETTINGS] section:

    [SETTINGS]
    $ENABLE_USER_3GL_DEBUGGING = TRUE
    

Once this is set, you can start your Uniface application, attach your C debugger to the uniface.exe (or userver.exe) process, and set breakpoints in your C code. When Uniface calls the component, the debugger will hit the breakpoint, and the application won't crash.

⚠️ Crucial Warnings (Read This!)

While this feature is a lifesaver, it comes with two major caveats that you need to know before using it.

1. Development Only

Never use this in production. It alters the stability and performance of the Uniface runtime. It is designed strictly for a developer's local environment.

2. The Pathscrambler Conflict

This is the one that trips people up: When this setting is active, Uniface disables Pathscrambler decryption.

If your assignment file uses encrypted strings (generated by pathscrambler.exe) for database passwords or network paths, Uniface will fail to read them. It will try to read the encrypted string as if it were plain text.

The Symptom: You enable debugging, and suddenly your database connection fails with a logon error.

The Fix: For the duration of your debug session, you must replace encrypted passwords in your .asn file with clear text (ASCII) values.

Summary

Debugging legacy integrations doesn't have to be a guessing game. By using $ENABLE_USER_3GL_DEBUGGING, you can inspect your C/C++ extensions directly. Just remember to revert your assignment file (and remove those clear-text passwords!) when you are done.

Happy coding! 🚀

Sources & References

Note: This article was created with the assistance of AI to summarize technical documentation for the developer community.

Top comments (0)