[haiku-commits] haiku: hrev49449 - in src/apps/debugger: user_interface/gui/utility_windows user_interface/gui/team_window jobs value/value_handlers user_interface/gui/value

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 24 Jul 2015 23:10:13 +0200 (CEST)

hrev49449 adds 7 changesets to branch 'master'
old head: 2303600a81b4bccf048a73954a4c8380c55830fd
new head: d88d941c90bb26795b81a9bb676abeb1e628df8d
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=d88d941c90bb+%5E2303600a81b4

----------------------------------------------------------------------------

1f8d1f68ce08: Debugger: Slight tweak to text control editor.

- Trigger a caller update on modification as well.

1f3db0d0d68a: Debugger: Flesh out option-based value editors.

TableCellOptionPopUpEditor:
- Add virtual hook for retrieving the final selected value. Implement
accordingly in Bool and Enumeration editor subclasses.
- Implement calling the edit completion hook upon value changes.

55d4f9ff18d6: Debugger: Implement value editor hook for more handlers.

{Bool,Enumeration}ValueHandler:
- Implement GetTableCellValueEditor() hook.

9b0d97576d41: Debugger: Add variable editing utility window.

VariableEditWindow:
- Implement container window for variable value editors. While
not as ideal as initially intended, this will handle presenting value
editing to the user until more work is done on the table cell editing
aspect of things.

7d25ab995d15: Debugger: Add hook for variable value writing.

WriteValueNodeJob:
- Implement async job that creates a ValueWriter to update a variable
value on request.

UserInterfaceListener:
- Add hook for requesting that a node be updated with a new value.
Implement in TeamDebugger by scheduling a WriteValueNodeJob.

473b2c6ac95c: Debugger: Add VariablesView listener hook.

VariablesView::Listener:
- Add hook for requesting value node value updates.

TeamWindow:
- Implement VariablesView listener hook and forward accordingly to
TeamDebugger.

d88d941c90bb: Debugger: Finish variable edit support.

VariablesView:
- Intercept table node invocations. If the invocation corresponds to
a writable variable, request a corresponding editor and bring up a
an edit window for it.
- Handle requests from the edit window to write the final updated value
of the variable.

This implements the last missing piece for ticket #9708, except for an
editor for floats.

[ Rene Gollent <rene@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

24 files changed, 643 insertions(+), 8 deletions(-)
src/apps/debugger/Jamfile | 2 +
src/apps/debugger/MessageCodes.h | 3 +
src/apps/debugger/controllers/TeamDebugger.cpp | 20 +-
src/apps/debugger/controllers/TeamDebugger.h | 3 +
src/apps/debugger/jobs/Jobs.h | 27 +++
src/apps/debugger/jobs/WriteValueNodeJob.cpp | 80 ++++++++
src/apps/debugger/user_interface/UserInterface.h | 6 +-
.../gui/team_window/TeamWindow.cpp | 8 +
.../user_interface/gui/team_window/TeamWindow.h | 2 +
.../gui/team_window/VariablesView.cpp | 114 ++++++++++++
.../gui/team_window/VariablesView.h | 14 +-
.../gui/utility_windows/VariableEditWindow.cpp | 185 +++++++++++++++++++
.../gui/utility_windows/VariableEditWindow.h | 59 ++++++
.../gui/value/TableCellBoolEditor.cpp | 15 ++
.../gui/value/TableCellBoolEditor.h | 2 +
.../gui/value/TableCellEnumerationEditor.cpp | 20 ++
.../gui/value/TableCellEnumerationEditor.h | 2 +
.../gui/value/TableCellOptionPopUpEditor.cpp | 8 +-
.../gui/value/TableCellOptionPopUpEditor.h | 2 +
.../gui/value/TableCellTextControlEditor.cpp | 3 +-
.../value/value_handlers/BoolValueHandler.cpp | 33 +++-
.../value/value_handlers/BoolValueHandler.h | 3 +
.../value_handlers/EnumerationValueHandler.cpp | 37 ++++
.../value_handlers/EnumerationValueHandler.h | 3 +

############################################################################

Commit: 1f8d1f68ce08625123718ff286d3827bab88c361
URL: http://cgit.haiku-os.org/haiku/commit/?id=1f8d1f68ce08
Author: Rene Gollent <rene@xxxxxxxxxxx>
Date: Fri Jul 24 21:06:58 2015 UTC

Debugger: Slight tweak to text control editor.

- Trigger a caller update on modification as well.

----------------------------------------------------------------------------

diff --git
a/src/apps/debugger/user_interface/gui/value/TableCellTextControlEditor.cpp
b/src/apps/debugger/user_interface/gui/value/TableCellTextControlEditor.cpp
index 2c9a999..79a3106 100644
--- a/src/apps/debugger/user_interface/gui/value/TableCellTextControlEditor.cpp
+++ b/src/apps/debugger/user_interface/gui/value/TableCellTextControlEditor.cpp
@@ -80,7 +80,8 @@ TableCellTextControlEditor::MessageReceived(BMessage* message)
{
// TODO: highlight the input view in some way to show
// invalid inputs
- break;
+
+ // fall through
}
case MSG_INPUT_VALIDATION_NEEDED:
{

############################################################################

Commit: 1f3db0d0d68a411559e58a3b76e982153e1d6a13
URL: http://cgit.haiku-os.org/haiku/commit/?id=1f3db0d0d68a
Author: Rene Gollent <rene@xxxxxxxxxxx>
Date: Wed Jul 22 02:24:38 2015 UTC

Debugger: Flesh out option-based value editors.

TableCellOptionPopUpEditor:
- Add virtual hook for retrieving the final selected value. Implement
accordingly in Bool and Enumeration editor subclasses.
- Implement calling the edit completion hook upon value changes.

----------------------------------------------------------------------------

diff --git a/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.cpp
b/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.cpp
index 5a5b7af..7a0ed75 100644
--- a/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.cpp
+++ b/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.cpp
@@ -38,3 +38,18 @@ TableCellBoolEditor::ConfigureOptions()

return SelectOptionFor(initialValue->GetValue());
}
+
+
+status_t
+TableCellBoolEditor::GetSelectedValue(::Value*& _value) const
+{
+ const char* name = NULL;
+ int32 selectedValue = 0;
+ SelectedOption(&name, &selectedValue);
+ BoolValue* value = new(std::nothrow) BoolValue((bool)selectedValue);
+ if (value == NULL)
+ return B_NO_MEMORY;
+
+ _value = value;
+ return B_OK;
+}
diff --git a/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.h
b/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.h
index b8fd828..7b02830 100644
--- a/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.h
+++ b/src/apps/debugger/user_interface/gui/value/TableCellBoolEditor.h
@@ -18,6 +18,8 @@ public:

virtual status_t ConfigureOptions();

+protected:
+ virtual status_t GetSelectedValue(::Value*&
_value) const;
};

#endif // TABLE_CELL_BOOL_EDITOR_H
diff --git
a/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.cpp
b/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.cpp
index fdae22a..0ab8ef5 100644
--- a/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.cpp
+++ b/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.cpp
@@ -46,3 +46,23 @@ TableCellEnumerationEditor::ConfigureOptions()

return SelectOptionFor(integerValue.ToInt32());
}
+
+
+status_t
+TableCellEnumerationEditor::GetSelectedValue(::Value*& _value) const
+{
+ EnumerationValue* initialValue = dynamic_cast<EnumerationValue*>(
+ InitialValue());
+ EnumerationType* type = initialValue->GetType();
+ const char* name = NULL;
+ int32 selectedValue = 0;
+ SelectedOption(&name, &selectedValue);
+
+ EnumerationValue* value = new(std::nothrow) EnumerationValue(type,
+ BVariant(selectedValue));
+ if (value == NULL)
+ return B_NO_MEMORY;
+
+ _value = value;
+ return B_OK;
+}
diff --git
a/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.h
b/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.h
index 4a26e34..94808a4 100644
--- a/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.h
+++ b/src/apps/debugger/user_interface/gui/value/TableCellEnumerationEditor.h
@@ -19,6 +19,8 @@ public:

virtual status_t ConfigureOptions();

+protected:
+ virtual status_t GetSelectedValue(::Value*&
_value) const;
};

#endif // TABLE_CELL_ENUMERATION_EDITOR_H
diff --git
a/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.cpp
b/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.cpp
index 4fa432d..2eef714 100644
--- a/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.cpp
+++ b/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.cpp
@@ -65,7 +65,13 @@ TableCellOptionPopUpEditor::MessageReceived(BMessage*
message)
switch (message->what) {
case MSG_SELECTED_OPTION_CHANGED:
{
- // TODO: implement
+ ::Value* value = NULL;
+ if (GetSelectedValue(value) == B_OK) {
+ BReference< ::Value> valueReference(value,
true);
+ NotifyEditCompleted(value);
+ } else
+ NotifyEditCancelled();
+
break;
}
default:
diff --git
a/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.h
b/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.h
index e9f3d9e..d65d971 100644
--- a/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.h
+++ b/src/apps/debugger/user_interface/gui/value/TableCellOptionPopUpEditor.h
@@ -27,6 +27,8 @@ public:
virtual status_t ConfigureOptions() = 0;

protected:
+ virtual status_t GetSelectedValue(::Value*&
_value) const = 0;
+
virtual void AttachedToWindow();
virtual void MessageReceived(BMessage*
message);
};

############################################################################

Commit: 55d4f9ff18d61bde20dfdf9889c6022a7eb844d3
URL: http://cgit.haiku-os.org/haiku/commit/?id=55d4f9ff18d6
Author: Rene Gollent <rene@xxxxxxxxxxx>
Date: Wed Jul 22 01:47:11 2015 UTC

Debugger: Implement value editor hook for more handlers.

{Bool,Enumeration}ValueHandler:
- Implement GetTableCellValueEditor() hook.

----------------------------------------------------------------------------

diff --git a/src/apps/debugger/value/value_handlers/BoolValueHandler.cpp
b/src/apps/debugger/value/value_handlers/BoolValueHandler.cpp
index bfba420..06223d7 100644
--- a/src/apps/debugger/value/value_handlers/BoolValueHandler.cpp
+++ b/src/apps/debugger/value/value_handlers/BoolValueHandler.cpp
@@ -11,6 +11,7 @@

#include "BoolValue.h"
#include "BoolValueFormatter.h"
+#include "TableCellBoolEditor.h"
#include "TableCellFormattedValueRenderer.h"


@@ -62,7 +63,7 @@ BoolValueHandler::GetTableCellValueRenderer(Value* value,
return B_BAD_VALUE;

ValueFormatter* formatter = NULL;
- if (GetValueFormatter(value, formatter))
+ if (GetValueFormatter(value, formatter) != B_OK)
return B_NO_MEMORY;
BReference<ValueFormatter> formatterReference(formatter, true);

@@ -75,3 +76,33 @@ BoolValueHandler::GetTableCellValueRenderer(Value* value,
_renderer = renderer;
return B_OK;
}
+
+
+status_t
+BoolValueHandler::GetTableCellValueEditor(Value* _value, Settings* settings,
+ TableCellValueEditor*& _editor)
+{
+ BoolValue* value = dynamic_cast<BoolValue*>(_value);
+ if (value == NULL)
+ return B_BAD_VALUE;
+
+ ValueFormatter* formatter;
+ status_t error = GetValueFormatter(value, formatter);
+ if (error != B_OK)
+ return error;
+ BReference<ValueFormatter> formatterReference(formatter, true);
+
+ TableCellBoolEditor* editor = new(std::nothrow)
+ TableCellBoolEditor(value, formatter);
+ if (editor == NULL)
+ return B_NO_MEMORY;
+
+ BReference<TableCellBoolEditor> editorReference(editor, true);
+ error = editor->Init();
+ if (error != B_OK)
+ return error;
+
+ editorReference.Detach();
+ _editor = editor;
+ return B_OK;
+}
diff --git a/src/apps/debugger/value/value_handlers/BoolValueHandler.h
b/src/apps/debugger/value/value_handlers/BoolValueHandler.h
index 15acb89..0ff13f8 100644
--- a/src/apps/debugger/value/value_handlers/BoolValueHandler.h
+++ b/src/apps/debugger/value/value_handlers/BoolValueHandler.h
@@ -21,6 +21,9 @@ public:

ValueFormatter*& _formatter);
virtual status_t
GetTableCellValueRenderer(Value* value,

TableCellValueRenderer*& _renderer);
+ virtual status_t GetTableCellValueEditor(Value*
_value,
+
Settings* settings,
+
TableCellValueEditor*& _editor);
};


diff --git a/src/apps/debugger/value/value_handlers/EnumerationValueHandler.cpp
b/src/apps/debugger/value/value_handlers/EnumerationValueHandler.cpp
index 83f53a5..1f6df72 100644
--- a/src/apps/debugger/value/value_handlers/EnumerationValueHandler.cpp
+++ b/src/apps/debugger/value/value_handlers/EnumerationValueHandler.cpp
@@ -11,6 +11,7 @@

#include "EnumerationValue.h"
#include "EnumerationValueFormatter.h"
+#include "TableCellEnumerationEditor.h"
#include "TableCellFormattedValueRenderer.h"
#include "Type.h"

@@ -64,6 +65,42 @@ EnumerationValueHandler::GetValueFormatter(Value* _value,
}


+status_t
+EnumerationValueHandler::GetTableCellValueEditor(Value* _value,
+ Settings* settings, TableCellValueEditor*& _editor)
+{
+ EnumerationValue* value = dynamic_cast<EnumerationValue*>(_value);
+ if (value == NULL)
+ return B_BAD_VALUE;
+
+ IntegerValueFormatter::Config* config = NULL;
+ status_t error = CreateIntegerFormatterConfig(value, config);
+ if (error != B_OK)
+ return error;
+ BReference<IntegerValueFormatter::Config> configReference(config, true);
+
+ ValueFormatter* formatter;
+ error = CreateValueFormatter(config, formatter);
+ if (error != B_OK)
+ return error;
+ BReference<ValueFormatter> formatterReference(formatter, true);
+
+ TableCellEnumerationEditor* editor = new(std::nothrow)
+ TableCellEnumerationEditor(value, formatter);
+ if (editor == NULL)
+ return B_NO_MEMORY;
+
+ BReference<TableCellEnumerationEditor> editorReference(editor, true);
+ error = editor->Init();
+ if (error != B_OK)
+ return error;
+
+ editorReference.Detach();
+ _editor = editor;
+ return B_OK;
+}
+
+
integer_format
EnumerationValueHandler::DefaultIntegerFormat(IntegerValue* _value)
{
diff --git a/src/apps/debugger/value/value_handlers/EnumerationValueHandler.h
b/src/apps/debugger/value/value_handlers/EnumerationValueHandler.h
index f595b8b..de45ea6 100644
--- a/src/apps/debugger/value/value_handlers/EnumerationValueHandler.h
+++ b/src/apps/debugger/value/value_handlers/EnumerationValueHandler.h
@@ -19,6 +19,9 @@ public:
virtual float SupportsValue(Value* value);
virtual status_t GetValueFormatter(Value* value,

ValueFormatter*& _formatter);
+ virtual status_t GetTableCellValueEditor(Value*
value,
+
Settings* settings,
+
TableCellValueEditor*& _editor);

protected:
virtual integer_format DefaultIntegerFormat(IntegerValue*
value);

############################################################################

Commit: 9b0d97576d41083cf9df72be49ea3c2e83683d7a
URL: http://cgit.haiku-os.org/haiku/commit/?id=9b0d97576d41
Author: Rene Gollent <rene@xxxxxxxxxxx>
Date: Thu Jul 23 02:38:18 2015 UTC

Debugger: Add variable editing utility window.

VariableEditWindow:
- Implement container window for variable value editors. While
not as ideal as initially intended, this will handle presenting value
editing to the user until more work is done on the table cell editing
aspect of things.

----------------------------------------------------------------------------

diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile
index 648b3cf..a8c60b3 100644
--- a/src/apps/debugger/Jamfile
+++ b/src/apps/debugger/Jamfile
@@ -304,6 +304,7 @@ local sources =
ExpressionPromptWindow.cpp
SignalDispositionEditWindow.cpp
StartTeamWindow.cpp
+ VariableEditWindow.cpp
WatchPromptWindow.cpp

# user_interface/gui/value
diff --git a/src/apps/debugger/MessageCodes.h b/src/apps/debugger/MessageCodes.h
index 450bade..89604a8 100644
--- a/src/apps/debugger/MessageCodes.h
+++ b/src/apps/debugger/MessageCodes.h
@@ -82,6 +82,8 @@ enum {
MSG_SHOW_EXPRESSION_PROMPT_WINDOW = 'sepw',
MSG_ADD_NEW_EXPRESSION =
'anex',
MSG_EXPRESSION_PROMPT_WINDOW_CLOSED = 'epwc',
+ MSG_SHOW_VARIABLE_EDIT_WINDOW = 'svew',
+ MSG_VARIABLE_EDIT_WINDOW_CLOSED = 'vewc',
MSG_INSPECT_ADDRESS
= 'isad',
MSG_WRITE_TARGET_MEMORY =
'wtam',
MSG_EVALUATE_EXPRESSION =
'evex',
@@ -93,6 +95,7 @@ enum {
MSG_SHOW_CONTAINER_RANGE_PROMPT = 'scrp',
MSG_SET_CONTAINER_RANGE =
'chcr',
MSG_GENERATE_DEBUG_REPORT =
'gdrp',
+ MSG_WRITE_VARIABLE_VALUE =
'wrvv',

MSG_DEBUG_INFO_NEEDS_USER_INPUT = 'dnui',
MSG_USER_INTERFACE_FILE_CHOSEN = 'uifc'
diff --git
a/src/apps/debugger/user_interface/gui/utility_windows/VariableEditWindow.cpp
b/src/apps/debugger/user_interface/gui/utility_windows/VariableEditWindow.cpp
new file mode 100644
index 0000000..da4f962
--- /dev/null
+++
b/src/apps/debugger/user_interface/gui/utility_windows/VariableEditWindow.cpp
@@ -0,0 +1,185 @@
+/*
+ * Copyright 2015, Rene Gollent, rene@xxxxxxxxxxx.
+ * Distributed under the terms of the MIT License.
+ */
+#include "VariableEditWindow.h"
+
+#include <Button.h>
+#include <LayoutBuilder.h>
+#include <String.h>
+#include <StringView.h>
+
+#include "MessageCodes.h"
+#include "TableCellValueEditor.h"
+#include "Value.h"
+#include "ValueNode.h"
+
+
+enum {
+ MSG_VARIABLE_VALUE_CHANGED = 'vavc'
+};
+
+
+VariableEditWindow::VariableEditWindow(Value* initialValue, ValueNode* node,
+ TableCellValueEditor* editor, BHandler* target)
+ :
+ BWindow(BRect(), "Edit value",
+ B_FLOATING_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS |
B_CLOSE_ON_ESCAPE),
+ fCancelButton(NULL),
+ fSaveButton(NULL),
+ fTarget(target),
+ fNode(node),
+ fInitialValue(initialValue),
+ fNewValue(NULL),
+ fEditor(editor)
+{
+ fNode->AcquireReference();
+ fInitialValue->AcquireReference();
+ fEditor->AcquireReference();
+ fEditor->AddListener(this);
+}
+
+
+VariableEditWindow::~VariableEditWindow()
+{
+ fNode->ReleaseReference();
+ fInitialValue->ReleaseReference();
+ if (fNewValue != NULL)
+ fNewValue->ReleaseReference();
+
+ fEditor->RemoveListener(this);
+ fEditor->ReleaseReference();
+}
+
+
+VariableEditWindow*
+VariableEditWindow::Create(Value* initialValue, ValueNode* node,
+ TableCellValueEditor* editor, BHandler* target)
+{
+ VariableEditWindow* self = new VariableEditWindow(initialValue, node,
+ editor, target);
+
+ try {
+ self->_Init();
+ } catch (...) {
+ delete self;
+ throw;
+ }
+
+ return self;
+
+}
+
+
+void
+VariableEditWindow::_Init()
+{
+ BString label;
+ BString initialValue;
+ fInitialValue->ToString(initialValue);
+ label.SetToFormat("Initial value for '%s': %s\n",
+ fNode->Name().String(), initialValue.String());
+
+ BLayoutBuilder::Group<>(this, B_VERTICAL)
+ .SetInsets(B_USE_DEFAULT_SPACING)
+ .AddGroup(B_HORIZONTAL, 4.0f)
+ .Add(new BStringView("initialLabel", label))
+ .End()
+ .AddGroup(B_HORIZONTAL, 4.0f)
+ .Add(new BStringView("newLabel", "New value:"))
+ .Add(fEditor->GetView())
+ .End()
+ .AddGroup(B_HORIZONTAL, 4.0f)
+ .AddGlue()
+ .Add((fCancelButton = new BButton("Cancel",
+ new BMessage(B_QUIT_REQUESTED))))
+ .Add((fSaveButton = new BButton("Save",
+ new
BMessage(MSG_WRITE_VARIABLE_VALUE))))
+ .End();
+
+ fCancelButton->SetTarget(this);
+ fSaveButton->SetTarget(this);
+ fSaveButton->MakeDefault(true);
+ fEditor->GetView()->MakeFocus(true);
+}
+
+
+void
+VariableEditWindow::Show()
+{
+ CenterOnScreen();
+ BWindow::Show();
+}
+
+
+bool
+VariableEditWindow::QuitRequested()
+{
+ fEditor->GetView()->RemoveSelf();
+
+ BMessenger messenger(fTarget);
+ messenger.SendMessage(MSG_VARIABLE_EDIT_WINDOW_CLOSED);
+
+ return BWindow::QuitRequested();
+}
+
+
+void
+VariableEditWindow::MessageReceived(BMessage* message)
+{
+ switch (message->what) {
+ case MSG_VARIABLE_VALUE_CHANGED:
+ {
+ Value* value;
+ if (message->FindPointer("value",
+ reinterpret_cast<void**>(&value)) ==
B_OK) {
+ if (fNewValue != NULL)
+ fNewValue->ReleaseReference();
+
+ fNewValue = value;
+ }
+ break;
+ }
+ case MSG_WRITE_VARIABLE_VALUE:
+ {
+ BMessage message(MSG_WRITE_VARIABLE_VALUE);
+ message.AddPointer("node", fNode);
+ message.AddPointer("value", fNewValue);
+
+ // acquire a reference on behalf of the target
+ BReference<Value> valueReference(fNewValue);
+ if (BMessenger(fTarget).SendMessage(&message) == B_OK) {
+ valueReference.Detach();
+ PostMessage(B_QUIT_REQUESTED);
+ }
+ break;
+ }
+ default:
+ BWindow::MessageReceived(message);
+ break;
+ }
+}
+
+
+void
+VariableEditWindow::TableCellEditBeginning()
+{
+}
+
+
+void
+VariableEditWindow::TableCellEditCancelled()
+{
+ PostMessage(B_QUIT_REQUESTED);
+}
+
+
+void
+VariableEditWindow::TableCellEditEnded(Value* newValue)
+{
+ BReference<Value> valueReference(newValue);
+ BMessage message(MSG_VARIABLE_VALUE_CHANGED);
+ message.AddPointer("value", newValue);
+ if (PostMessage(&message) == B_OK)
+ valueReference.Detach();
+}
diff --git
a/src/apps/debugger/user_interface/gui/utility_windows/VariableEditWindow.h
b/src/apps/debugger/user_interface/gui/utility_windows/VariableEditWindow.h
new file mode 100644
index 0000000..987c552
--- /dev/null
+++ b/src/apps/debugger/user_interface/gui/utility_windows/VariableEditWindow.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2015, Rene Gollent, rene@xxxxxxxxxxx.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef VARIABLE_EDIT_WINDOW_H
+#define VARIABLE_EDIT_WINDOW_H
+
+
+#include <Window.h>
+
+#include "TableCellValueEditor.h"
+
+
+class BButton;
+class Value;
+class ValueNode;
+
+
+class VariableEditWindow : public BWindow,
+ private TableCellValueEditor::Listener {
+public:
+
VariableEditWindow(Value* initialValue,
+
ValueNode* node,
+
TableCellValueEditor* editor,
+
BHandler* target);
+
+
~VariableEditWindow();
+
+ static VariableEditWindow* Create(Value* initialValue,
+
ValueNode* node,
+
TableCellValueEditor* editor,
+
BHandler* closeTarget);
+ //
throws
+
+
+ virtual void MessageReceived(BMessage*
message);
+
+ virtual void Show();
+ virtual bool QuitRequested();
+
+ // TableCellValueEditor::Listener
+ virtual void TableCellEditBeginning();
+ virtual void TableCellEditCancelled();
+ virtual void TableCellEditEnded(Value*
newValue);
+
+private:
+ void _Init();
+
+private:
+ BButton* fCancelButton;
+ BButton* fSaveButton;
+ BHandler* fTarget;
+ ValueNode* fNode;
+ Value* fInitialValue;
+ Value* fNewValue;
+ TableCellValueEditor* fEditor;
+};
+
+#endif // VARIABLE_EDIT_WINDOW_H

############################################################################

Commit: 7d25ab995d1578a294a7e7c9eb89fb517ae4ce9c
URL: http://cgit.haiku-os.org/haiku/commit/?id=7d25ab995d15
Author: Rene Gollent <rene@xxxxxxxxxxx>
Date: Fri Jul 24 02:47:08 2015 UTC

Debugger: Add hook for variable value writing.

WriteValueNodeJob:
- Implement async job that creates a ValueWriter to update a variable
value on request.

UserInterfaceListener:
- Add hook for requesting that a node be updated with a new value.
Implement in TeamDebugger by scheduling a WriteValueNodeJob.

----------------------------------------------------------------------------

diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile
index a8c60b3..83f10bb 100644
--- a/src/apps/debugger/Jamfile
+++ b/src/apps/debugger/Jamfile
@@ -162,6 +162,7 @@ local sources =
ResolveValueNodeJob.cpp
RetrieveMemoryBlockJob.cpp
WriteMemoryJob.cpp
+ WriteValueNodeJob.cpp

# model
AreaInfo.cpp
diff --git a/src/apps/debugger/controllers/TeamDebugger.cpp
b/src/apps/debugger/controllers/TeamDebugger.cpp
index 90f445e..e9d92bb 100644
--- a/src/apps/debugger/controllers/TeamDebugger.cpp
+++ b/src/apps/debugger/controllers/TeamDebugger.cpp
@@ -1035,13 +1035,31 @@ TeamDebugger::ValueNodeValueRequested(CpuState*
cpuState,
status_t error = fWorker->ScheduleJob(
new(std::nothrow) ResolveValueNodeValueJob(fDebuggerInterface,
fDebuggerInterface->GetArchitecture(), cpuState,
- fTeam->GetTeamTypeInformation(), container,
valueNode), this);
+ fTeam->GetTeamTypeInformation(), container,
valueNode), this);
if (error != B_OK) {
// scheduling failed -- set the value to invalid
valueNode->SetLocationAndValue(NULL, NULL, error);
}
}

+void
+TeamDebugger::ValueNodeWriteRequested(ValueNode* node, CpuState* state,
+ Value* newValue)
+{
+ // schedule the job
+ status_t error = fWorker->ScheduleJob(
+ new(std::nothrow) WriteValueNodeValueJob(fDebuggerInterface,
+ fDebuggerInterface->GetArchitecture(), state,
+ fTeam->GetTeamTypeInformation(), node, newValue), this);
+ if (error != B_OK) {
+ BString message;
+ message.SetToFormat("Request to write new value for variable %s
"
+ "failed: %s.\n", node->Name().String(),
strerror(error));
+ fUserInterface->NotifyUser("Error", message.String(),
+ USER_NOTIFICATION_ERROR);
+ }
+}
+

void
TeamDebugger::ThreadActionRequested(thread_id threadID,
diff --git a/src/apps/debugger/controllers/TeamDebugger.h
b/src/apps/debugger/controllers/TeamDebugger.h
index 377a9ea..371a0ed 100644
--- a/src/apps/debugger/controllers/TeamDebugger.h
+++ b/src/apps/debugger/controllers/TeamDebugger.h
@@ -73,6 +73,9 @@ private:
virtual void
ValueNodeValueRequested(CpuState* cpuState,

ValueNodeContainer* container,

ValueNode* valueNode);
+ virtual void
ValueNodeWriteRequested(ValueNode* node,
+
CpuState* state,
+ Value*
newValue);
virtual void ThreadActionRequested(thread_id
threadID,
uint32
action, target_addr_t address);

diff --git a/src/apps/debugger/jobs/Jobs.h b/src/apps/debugger/jobs/Jobs.h
index 9841fd5..1f6b244 100644
--- a/src/apps/debugger/jobs/Jobs.h
+++ b/src/apps/debugger/jobs/Jobs.h
@@ -51,6 +51,7 @@ enum {
JOB_TYPE_LOAD_SOURCE_CODE,
JOB_TYPE_GET_STACK_FRAME_VALUE,
JOB_TYPE_RESOLVE_VALUE_NODE_VALUE,
+ JOB_TYPE_WRITE_VALUE_NODE_VALUE,
JOB_TYPE_GET_MEMORY_BLOCK,
JOB_TYPE_WRITE_MEMORY,
JOB_TYPE_EVALUATE_EXPRESSION
@@ -216,6 +217,32 @@ private:
};


+class WriteValueNodeValueJob : public Job {
+public:
+
WriteValueNodeValueJob(
+
DebuggerInterface* debuggerInterface,
+
Architecture* architecture,
+
CpuState* cpuState,
+
TeamTypeInformation* typeInformation,
+
ValueNode* valueNode,
+ Value*
newValue);
+ virtual
~WriteValueNodeValueJob();
+
+ virtual const JobKey& Key() const;
+ virtual status_t Do();
+
+private:
+ SimpleJobKey fKey;
+ DebuggerInterface* fDebuggerInterface;
+ Architecture* fArchitecture;
+ CpuState* fCpuState;
+ TeamTypeInformation*
+
fTypeInformation;
+ ValueNode* fValueNode;
+ Value* fNewValue;
+};
+
+
class RetrieveMemoryBlockJob : public Job {
public:

RetrieveMemoryBlockJob(Team* team,
diff --git a/src/apps/debugger/jobs/WriteValueNodeJob.cpp
b/src/apps/debugger/jobs/WriteValueNodeJob.cpp
new file mode 100644
index 0000000..40c4bf0
--- /dev/null
+++ b/src/apps/debugger/jobs/WriteValueNodeJob.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2015, Rene Gollent, rene@xxxxxxxxxxx.
+ * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include "Jobs.h"
+
+#include <AutoLocker.h>
+
+#include "Architecture.h"
+#include "CpuState.h"
+#include "DebuggerInterface.h"
+#include "TeamTypeInformation.h"
+#include "Tracing.h"
+#include "Value.h"
+#include "ValueLocation.h"
+#include "ValueNode.h"
+#include "ValueNodeContainer.h"
+#include "ValueWriter.h"
+
+
+WriteValueNodeValueJob::WriteValueNodeValueJob(
+ DebuggerInterface* debuggerInterface, Architecture* architecture,
+ CpuState* cpuState, TeamTypeInformation* typeInformation,
+ ValueNode* valueNode, Value* newValue)
+ :
+ fKey(valueNode, JOB_TYPE_WRITE_VALUE_NODE_VALUE),
+ fDebuggerInterface(debuggerInterface),
+ fArchitecture(architecture),
+ fCpuState(cpuState),
+ fTypeInformation(typeInformation),
+ fValueNode(valueNode),
+ fNewValue(newValue)
+{
+ if (fCpuState != NULL)
+ fCpuState->AcquireReference();
+ fValueNode->AcquireReference();
+ fNewValue->AcquireReference();
+}
+
+
+WriteValueNodeValueJob::~WriteValueNodeValueJob()
+{
+ if (fCpuState != NULL)
+ fCpuState->ReleaseReference();
+ fValueNode->ReleaseReference();
+ fNewValue->ReleaseReference();
+}
+
+
+const JobKey&
+WriteValueNodeValueJob::Key() const
+{
+ return fKey;
+}
+
+
+status_t
+WriteValueNodeValueJob::Do()
+{
+ ValueNodeContainer* container = fValueNode->Container();
+ if (container == NULL)
+ return B_BAD_VALUE;
+
+ ValueWriter writer(fArchitecture, fDebuggerInterface,
+ fCpuState, -1);
+
+ BVariant value;
+ fNewValue->ToVariant(value);
+
+ status_t error = writer.WriteValue(fValueNode->Location(), value);
+ if (error != B_OK)
+ return error;
+
+ AutoLocker<ValueNodeContainer> containerLocker(container);
+ fValueNode->SetLocationAndValue(fValueNode->Location(), fNewValue,
B_OK);
+
+ return B_OK;
+}
diff --git a/src/apps/debugger/user_interface/UserInterface.h
b/src/apps/debugger/user_interface/UserInterface.h
index 65caaa7..b87fedf 100644
--- a/src/apps/debugger/user_interface/UserInterface.h
+++ b/src/apps/debugger/user_interface/UserInterface.h
@@ -1,6 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx.
- * Copyright 2013-2014, Rene Gollent, rene@xxxxxxxxxxx.
+ * Copyright 2013-2015, Rene Gollent, rene@xxxxxxxxxxx.
* Distributed under the terms of the MIT License.
*/
#ifndef USER_INTERFACE_H
@@ -30,9 +30,9 @@ class Thread;
class TypeComponentPath;
class UserBreakpoint;
class UserInterfaceListener;
+class Value;
class ValueNode;
class ValueNodeContainer;
-class Variable;
class Watchpoint;


@@ -101,6 +101,8 @@ public:
virtual void
ValueNodeValueRequested(CpuState* cpuState,

ValueNodeContainer* container,

ValueNode* valueNode) = 0;
+ virtual void
ValueNodeWriteRequested(ValueNode* node,
+
CpuState* state, Value* newValue) = 0;
virtual void ThreadActionRequested(thread_id
threadID,
uint32
action,

target_addr_t address = 0) = 0;

############################################################################

Commit: 473b2c6ac95c71ec791949fe7dab01668d62fe44
URL: http://cgit.haiku-os.org/haiku/commit/?id=473b2c6ac95c
Author: Rene Gollent <rene@xxxxxxxxxxx>
Date: Fri Jul 24 02:48:55 2015 UTC

Debugger: Add VariablesView listener hook.

VariablesView::Listener:
- Add hook for requesting value node value updates.

TeamWindow:
- Implement VariablesView listener hook and forward accordingly to
TeamDebugger.

----------------------------------------------------------------------------

diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
index 4a29f22..ae63b94 100644
--- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
+++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
@@ -898,6 +898,14 @@ TeamWindow::ExpressionEvaluationRequested(ExpressionInfo*
info,


void
+TeamWindow::ValueNodeWriteRequested(ValueNode* node, CpuState* state,
+ Value* newValue)
+{
+ fListener->ValueNodeWriteRequested(node, state, newValue);
+}
+
+
+void
TeamWindow::ThreadStateChanged(const Team::ThreadEvent& event)
{
BMessage message(MSG_THREAD_STATE_CHANGED);
diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h
b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h
index a75ed2c..f8d6018 100644
--- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h
+++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h
@@ -130,6 +130,8 @@ private:

ExpressionInfo* info,

StackFrame* frame,

::Thread* thread);
+ virtual void
ValueNodeWriteRequested(ValueNode* node,
+
CpuState* state, Value* value);

// Team::Listener
virtual void ThreadStateChanged(
diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.h
b/src/apps/debugger/user_interface/gui/team_window/VariablesView.h
index b19ed15..50d264e 100644
--- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.h
+++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.h
@@ -159,6 +159,12 @@ public:

ExpressionInfo* info,

StackFrame* frame,
Thread*
thread) = 0;
+
+ virtual void ValueNodeWriteRequested(
+
ValueNode* node,
+
CpuState* state,
+ Value*
newValue) = 0;
+
};



############################################################################

Revision: hrev49449
Commit: d88d941c90bb26795b81a9bb676abeb1e628df8d
URL: http://cgit.haiku-os.org/haiku/commit/?id=d88d941c90bb
Author: Rene Gollent <rene@xxxxxxxxxxx>
Date: Fri Jul 24 02:49:58 2015 UTC

Ticket: https://dev.haiku-os.org/ticket/9708

Debugger: Finish variable edit support.

VariablesView:
- Intercept table node invocations. If the invocation corresponds to
a writable variable, request a corresponding editor and bring up a
an edit window for it.
- Handle requests from the edit window to write the final updated value
of the variable.

This implements the last missing piece for ticket #9708, except for an
editor for floats.

----------------------------------------------------------------------------

diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
index a9ac19f..9e37618 100644
--- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
+++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
@@ -43,6 +43,7 @@
#include "StringUtils.h"
#include "StringValue.h"
#include "SyntheticPrimitiveType.h"
+#include "TableCellValueEditor.h"
#include "TableCellValueRenderer.h"
#include "Team.h"
#include "TeamDebugInfo.h"
@@ -59,6 +60,7 @@
#include "ValueNode.h"
#include "ValueNodeManager.h"
#include "Variable.h"
+#include "VariableEditWindow.h"
#include "VariableValueNodeChild.h"
#include "VariablesViewState.h"
#include "VariablesViewStateHistory.h"
@@ -1773,6 +1775,7 @@ VariablesView::VariablesView(Listener* listener)
fPendingTypecastInfo(NULL),
fTemporaryExpression(NULL),
fFrameClearPending(false),
+ fEditWindow(NULL),
fListener(listener)
{
SetName("Variables");
@@ -1781,6 +1784,9 @@ VariablesView::VariablesView(Listener* listener)

VariablesView::~VariablesView()
{
+ if (fEditWindow != NULL)
+ BMessenger(fEditWindow).SendMessage(B_QUIT_REQUESTED);
+
SetStackFrame(NULL, NULL);
fVariableTable->SetTreeTableModel(NULL);

@@ -1887,6 +1893,66 @@ VariablesView::MessageReceived(BMessage* message)
Looper()->PostMessage(message);
break;
}
+ case MSG_SHOW_VARIABLE_EDIT_WINDOW:
+ {
+ TableCellValueEditor* editor = NULL;
+ if (message->FindPointer("editor",
reinterpret_cast<void**>(
+ &editor)) != B_OK) {
+ break;
+ }
+ BReference<TableCellValueEditor>
editorReference(editor, true);
+ if (fEditWindow != NULL)
+ fEditWindow->Activate();
+ else {
+ ValueNode* node = NULL;
+ if (message->FindPointer("node",
reinterpret_cast<void**>(
+ &node)) != B_OK) {
+ break;
+ }
+
+ Value* value = NULL;
+ if (message->FindPointer("value",
reinterpret_cast<void**>(
+ &value)) != B_OK) {
+ break;
+ }
+
+ try {
+ fEditWindow =
VariableEditWindow::Create(value, node,
+ editor, this);
+ } catch (...) {
+ fEditWindow = NULL;
+ break;
+ }
+
+ fEditWindow->Show();
+ }
+ break;
+ }
+ case MSG_VARIABLE_EDIT_WINDOW_CLOSED:
+ {
+ fEditWindow = NULL;
+ break;
+ }
+ case MSG_WRITE_VARIABLE_VALUE:
+ {
+ Value* value = NULL;
+ if (message->FindPointer("value",
reinterpret_cast<void**>(
+ &value)) != B_OK) {
+ break;
+ }
+
+ BReference<Value> valueReference(value, true);
+
+ ValueNode* node = NULL;
+ if (message->FindPointer("node",
reinterpret_cast<void**>(
+ &node)) != B_OK) {
+ break;
+ }
+
+ fListener->ValueNodeWriteRequested(node,
+ fStackFrame->GetCpuState(), value);
+ break;
+ }
case MSG_SHOW_TYPECAST_NODE_PROMPT:
{
BMessage* promptMessage = new(std::nothrow) BMessage(
@@ -2329,6 +2395,54 @@ VariablesView::TreeTableNodeExpandedChanged(TreeTable*
table,


void
+VariablesView::TreeTableNodeInvoked(TreeTable* table,
+ const TreeTablePath& path)
+{
+ ModelNode* node = (ModelNode*)fVariableTableModel->NodeForPath(path);
+ if (node == NULL)
+ return;
+
+ ValueNodeChild* child = node->NodeChild();
+
+ if (child->LocationResolutionState() != B_OK)
+ return;
+
+ ValueLocation* location = child->Location();
+ if (!location->IsWritable())
+ return;
+
+ Value* value = node->GetValue();
+ if (value == NULL)
+ return;
+
+ // get a value handler
+ ValueHandler* valueHandler;
+ status_t error = ValueHandlerRoster::Default()->FindValueHandler(value,
+ valueHandler);
+ if (error != B_OK)
+ return;
+
+ BReference<ValueHandler> handlerReference(valueHandler, true);
+ TableCellValueRenderer* renderer = node->TableCellRenderer();
+ TableCellValueEditor* editor = NULL;
+ error = valueHandler->GetTableCellValueEditor(value,
+ renderer != NULL ? renderer->GetSettings() : NULL, editor);
+ if (error != B_OK || editor == NULL)
+ return;
+
+ BReference<TableCellValueEditor> editorReference(editor, true);
+
+ BMessage message(MSG_SHOW_VARIABLE_EDIT_WINDOW);
+ message.AddPointer("editor", editor);
+ message.AddPointer("node", node->NodeChild()->Node());
+ message.AddPointer("value", value);
+
+ if (BMessenger(this).SendMessage(&message) == B_OK)
+ editorReference.Detach();
+}
+
+
+void
VariablesView::TreeTableCellMouseDown(TreeTable* table,
const TreeTablePath& path, int32 columnIndex, BPoint screenWhere,
uint32 buttons)
diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.h
b/src/apps/debugger/user_interface/gui/team_window/VariablesView.h
index 50d264e..f515e59 100644
--- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.h
+++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.h
@@ -1,6 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx.
- * Copyright 2012-2014, Rene Gollent, rene@xxxxxxxxxxx.
+ * Copyright 2012-2015, Rene Gollent, rene@xxxxxxxxxxx.
* Distributed under the terms of the MIT License.
*/
#ifndef VARIABLES_VIEW_H
@@ -22,11 +22,13 @@ class StackFrame;
class Thread;
class Type;
class TypeComponentPath;
+class ValueLocation;
class ValueNode;
class ValueNodeChild;
class ValueNodeContainer;
class Value;
class Variable;
+class VariableEditWindow;
class VariablesViewState;
class VariablesViewStateHistory;

@@ -59,7 +61,8 @@ private:
// TreeTableListener
virtual void
TreeTableNodeExpandedChanged(TreeTable* table,
const
TreeTablePath& path, bool expanded);
-
+ virtual void TreeTableNodeInvoked(TreeTable*
table,
+ const
TreeTablePath& path);
virtual void
TreeTableCellMouseDown(TreeTable* table,
const
TreeTablePath& path,
int32
columnIndex, BPoint screenWhere,
@@ -143,6 +146,7 @@ private:
VariablesExpressionInfo* fPendingTypecastInfo;
ExpressionInfo* fTemporaryExpression;
bool fFrameClearPending;
+ VariableEditWindow* fEditWindow;
Listener* fListener;
};



Other related posts:

  • » [haiku-commits] haiku: hrev49449 - in src/apps/debugger: user_interface/gui/utility_windows user_interface/gui/team_window jobs value/value_handlers user_interface/gui/value - anevilyak