Bug 389424 - [Wish] Give a hint to the debugger how you want to view a variable and custom views
Summary: [Wish] Give a hint to the debugger how you want to view a variable and custom...
Status: REPORTED
Alias: None
Product: kdevelop
Classification: Applications
Component: CPP Debugger (show other bugs)
Version: 5.2.1
Platform: Gentoo Packages Linux
: NOR wishlist
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-25 18:42 UTC by Staffan Palmroos
Modified: 2018-01-25 18:42 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Staffan Palmroos 2018-01-25 18:42:29 UTC
I think it would be useful if I could put a hint in my code how I want to view a variable in the debugger instead of having to manually change it every time I debug.

Something like:

int func() {
    // Show this variable as 'hex' by default
    /// kdbg(format:hex)
    int a1 = 0x20;

    // Show this variable as 'binary' by default, filling the left side with 0's
    /// kdbg(format:bin,fill:'0')
    int a2 = 127;

    // Show this float variable with no exponent but with 9 significant digits
    /// kdbg(notation:noexp,digits:9)
    float a3 = 0.000004;

    ...
}

I've added a couple other bits of functionality here too such as 0-filling and different formats for float variables. This can be ignored of course.

Expanding this a bit more, I would like to be able to write custom views of variables in the debugger, for example being able to view matrices in an actual matrix view. Then this notification mechanism could be used to tell the debugger when to use this custom view. Example:


#include <glm/glm.h>

void render() {

    /// kdbg(format:glm-matrix4)
    glm::mat4 projection = GetProjectionMatrix();

    /// kdbg(format:glm-vec3)
    glm::vec3 direction = GetDirection();

    ...
}