Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Extending CDT so that "Details" variable format is the default format.

I looked around a lot, even with CDT itself running under a debugger.
The key code seems to be in the function:
FormattedValueRetriever#doUpdateWithAvailableFormats

Where there is the code:

  String preferredFormat = FormattedValueVMUtil.
getPreferredFormat(update.getPresentationContext());
  if (update.getProperties().
contains(IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE)) {
    update.setProperty(
IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE, preferredFormat);
  }

  final String activeFormat = calcActiveFormat(update, preferredFormat, availableFormatsMap, elementFormatMap);


I tried to see if I could extend FormattedValueRetriever with my own modifications, but couldn't find any clean extension point. That's why I also tried to extend around GdbVariableVMProvider or GdbViewModelAdapter.

Another possibility I considered was to try to affect getPreferredFormat(update.
getPresentationContext()); by means of setting the preferred format on the IPresentationContext. But I couldn't get hold of it, the IPresentationContext is created internally by VariablesView. Also if I set a property there it would affect every CDT launch in the IDE, not just my own, so it wouldn't even be a proper solution.

The best (and only) point of extension I could find was to copy all of CDT's org.eclipse.cdt.dsf.gdb.internal.ui.GdbAdapterFactory code and supply that adapter factory for my own launches. This way I can provide my own GdbViewModelAdapter. It is not a very clean solution. It duplicates some (change sensitive?) CDT code, (and uses some internal API).
But I guess this might be the way to go (and the duplication/internal issues could be addressed in the future).


On Tue, Apr 8, 2014 at 5:37 PM, Marc Khouzam <marc.khouzam@xxxxxxxxxxxx> wrote:

I’m not 100% of the best way, but look at how the constants defined in IDebugVMConstants are used.

There should be an easy way for you to set those to the setting you want.

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Bruno Medeiros
Sent: Tuesday, April 08, 2014 12:17 PM
To: cdt-dev@xxxxxxxxxxx
Subject: [cdt-dev] Extending CDT so that "Details" variable format is the default format.

 

Hello. I'm having another go at improving the CDT debugger integration in both a D and Go IDE.

 

I want to make it so that the default _expression_/variable format in the Variables view (and in the debug editor hover) is the "Details" format. (org.eclipse.cdt.dsf.mi.service.MIExpressions.DETAILS_FORMAT )

The reason for this is that in these languages there are several variables/types that when debugged in GDB, show meaningful values under the "Details" format, but non-meaningful or less useful values in other formats. See for example this screenshot:
http://i.imgur.com/EoHJloH.png

Here we have a variable declared like this:
  string[3] staticArray = [ "one", "two", "three" ];

The details show up as: {"one", "two", "three"} , but the default format shows just the address of the variable.

A similar thing happens the "var" variable, for which the default is the useless {...} , but details is "blah" which is the contents of the var.

 

I tried to find a way to change this behavior but couldn't find any. I was looking at
https://wiki.eclipse.org/CDT/cdt-debug-dsf-gdb-extensibility

and while extending GdbLaunchDelegate eventually allows to customize most core debug behavior, I couldn't find a way to easily customize UI related behavior.

Particularly, I looked at these classes/entry-points in the CDT code, to try to see if I could extend/customize them, but didn't find a way:
org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.GdbViewModelAdapter
org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.GdbVariableVMProvider
org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueRetriever#doUpdateWithAvailableFormats

Any ideas? Did I miss something or is this not supported?


--
Bruno Medeiros


_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev




--
Bruno Medeiros

Back to the top