Skip to content

Commit

Permalink
debugger connection fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Oct 3, 2021
1 parent 13ef8e4 commit b9daf89
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 23 deletions.
5 changes: 1 addition & 4 deletions src/eez/flow/components/call_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ void executeCallActionComponent(FlowState *flowState, unsigned componentIndex) {
return;
}

FlowState *actionFlowState = initActionFlowState(assets, flowIndex, flowState);

actionFlowState->parentComponent = component;
actionFlowState->parentComponentIndex = componentIndex;
FlowState *actionFlowState = initActionFlowState(assets, flowIndex, flowState, componentIndex);

if (actionFlowState->numActiveComponents == 0) {
freeFlowState(actionFlowState);
Expand Down
7 changes: 4 additions & 3 deletions src/eez/flow/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ enum MessagesToDebugger {

MESSAGE_TO_DEBUGGER_VALUE_CHANGED, // VALUE_ADDR, VALUE

MESSAGE_TO_DEBUGGER_FLOW_STATE_CREATED, // FLOW_STATE_INDEX, FLOW_INDEX, PARENT_FLOW_STATE_INDEX (0 - NO PARENT)
MESSAGE_TO_DEBUGGER_FLOW_STATE_CREATED, // FLOW_STATE_INDEX, FLOW_INDEX, PARENT_FLOW_STATE_INDEX (-1 - NO PARENT), PARENT_COMPONENT_INDEX (-1 - NO PARENT COMPONENT)
MESSAGE_TO_DEBUGGER_FLOW_STATE_DESTROYED, // FLOW_STATE_INDEX

MESSAGE_TO_DEBUGGER_LOG // LOG_ITEM_TYPE, FLOW_STATE_INDEX, COMPONENT_INDEX, MESSAGE
Expand Down Expand Up @@ -423,11 +423,12 @@ void onValueChanged(const Value *pValue) {
void onFlowStateCreated(FlowState *flowState) {
if (g_debuggerIsConnected) {
char buffer[100];
snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\n",
snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\t%d\n",
MESSAGE_TO_DEBUGGER_FLOW_STATE_CREATED,
(int)flowState->flowStateIndex,
flowState->flowIndex,
(int)(flowState->parentFlowState ? flowState->parentFlowState->flowStateIndex : 0)
(int)(flowState->parentFlowState ? flowState->parentFlowState->flowStateIndex : -1),
flowState->parentComponentIndex
);
eez::mcu::ethernet::writeDebuggerBuffer(buffer, strlen(buffer));

Expand Down
9 changes: 2 additions & 7 deletions src/eez/flow/flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ unsigned start(Assets *assets) {

onStarted(assets);

g_mainPageFlowState = initPageFlowState(assets, 0, nullptr);
g_mainPageFlowState = initPageFlowState(assets, 0, nullptr, 0);

return 1;
}
Expand Down Expand Up @@ -140,12 +140,7 @@ FlowState *getFlowState(int16_t pageId, const WidgetCursor &widgetCursor) {
layoutViewWidgetExecutionState = ObjectAllocator<LayoutViewWidgetExecutionState>::allocate(0xa570ccad);
flowState->componenentExecutionStates[layoutViewWidgetComponentIndex] = layoutViewWidgetExecutionState;

auto layoutViewFlowState = initPageFlowState(flowState->assets, pageId, flowState);

auto component = flowState->flow->components.item(flowState->assets, layoutViewWidgetComponentIndex);

layoutViewFlowState->parentComponent = component;
layoutViewFlowState->parentComponentIndex = layoutViewWidgetComponentIndex;
auto layoutViewFlowState = initPageFlowState(flowState->assets, pageId, flowState, layoutViewWidgetComponentIndex);

layoutViewWidgetExecutionState->flowState = layoutViewFlowState;
}
Expand Down
18 changes: 12 additions & 6 deletions src/eez/flow/private.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static bool pingComponent(FlowState *flowState, unsigned componentIndex, int sou
}


static FlowState *initFlowState(Assets *assets, int flowIndex, FlowState *parentFlowState) {
static FlowState *initFlowState(Assets *assets, int flowIndex, FlowState *parentFlowState, int parentComponentIndex) {
auto flowDefinition = assets->flowDefinition.ptr(assets);
auto flow = flowDefinition->flows.item(assets, flowIndex);

Expand All @@ -117,7 +117,13 @@ static FlowState *initFlowState(Assets *assets, int flowIndex, FlowState *parent
flowState->error = false;
flowState->numActiveComponents = 0;
flowState->parentFlowState = parentFlowState;
flowState->parentComponent = nullptr;
if (parentFlowState) {
flowState->parentComponentIndex = parentComponentIndex;
flowState->parentComponent = parentFlowState->flow->components.item(assets, parentComponentIndex);
} else {
flowState->parentComponentIndex = -1;
flowState->parentComponent = nullptr;
}
flowState->values = (Value *)(flowState + 1);
flowState->componenentExecutionStates = (ComponenentExecutionState **)(flowState->values + nValues);

Expand Down Expand Up @@ -148,16 +154,16 @@ static FlowState *initFlowState(Assets *assets, int flowIndex, FlowState *parent
return flowState;
}

FlowState *initActionFlowState(Assets *assets, int flowIndex, FlowState *parentFlowState) {
auto flowState = initFlowState(assets, flowIndex, parentFlowState);
FlowState *initActionFlowState(Assets *assets, int flowIndex, FlowState *parentFlowState, int parentComponentIndex) {
auto flowState = initFlowState(assets, flowIndex, parentFlowState, parentComponentIndex);
if (flowState) {
flowState->isAction = true;
}
return flowState;
}

FlowState *initPageFlowState(Assets *assets, int flowIndex, FlowState *parentFlowState) {
auto flowState = initFlowState(assets, flowIndex, parentFlowState);
FlowState *initPageFlowState(Assets *assets, int flowIndex, FlowState *parentFlowState, int parentComponentIndex) {
auto flowState = initFlowState(assets, flowIndex, parentFlowState, parentComponentIndex);
if (flowState) {
flowState->isAction = false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/eez/flow/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct FlowState {
uint32_t numActiveComponents;
FlowState *parentFlowState;
Component *parentComponent;
uint16_t parentComponentIndex;
int parentComponentIndex;
Value *values;
ComponenentExecutionState **componenentExecutionStates;
};
Expand All @@ -60,8 +60,8 @@ extern uint32_t g_lastFlowStateIndex;

void fixAssetValues(Assets *assets);

FlowState *initActionFlowState(Assets *assets, int flowIndex, FlowState *parentFlowState);
FlowState *initPageFlowState(Assets *assets, int flowIndex, FlowState *parentFlowState);
FlowState *initActionFlowState(Assets *assets, int flowIndex, FlowState *parentFlowState, int parentComponentIndex);
FlowState *initPageFlowState(Assets *assets, int flowIndex, FlowState *parentFlowState, int parentComponentIndex);

void freeFlowState(FlowState *flowState);

Expand Down

0 comments on commit b9daf89

Please sign in to comment.