cancel
Showing results for 
Search instead for 
Did you mean: 

How to monitor a structure pointer in live expression window?

ledi7
Associate III

Hi,

i want to monitor the following statement (the value of p_Payload[]) during debugging process in the Live Expression Window of CubeIDE:

 

if(p_Notification->DataTransfered.p_Payload[0] == 0x02)

 

I added the following statement to the Live Expression Window

2024-11-13_10h06_50.png 

and tried a few other variations, but without succes.

Can somebody help?

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @ledi7 

Live Expressions can only evaluate variables that are currently in scope.  p_Notification is a local variable of a function that has exited 

void OTA_Notification(OTA_NotificationEvt_t *p_Notification);

 its memory may no longer be valid, leading to evaluation failures. Ensure you are trying to access the variable while still within the function where it is defined.

or  consider using global variables for debugging purposes, as they tend to be more stable in Live Expressions

View solution in original post

7 REPLIES 7
Ghofrane GSOURI
ST Employee

Hello @ledi7 

To monitor the actual values in p_Payload , you should use the correct syntax based on what you want to see:

To see the first element of the payload:

p_Notification->DataTransfered.p_Payload[0]

To see the entire array (if you know its size), you can use:

p_Notification->DataTransfered.p_Payload[0] // for first element
p_Notification->DataTransfered.p_Payload[1] // for second element, etc.

If you want to dereference and see a single value:

*(p_Notification->DataTransfered.p_Payload)

 

Hello @Ghofrane GSOURI ,

thank's for your reply. That works in "Expression Window"

2024-11-13_10h57_44.png

but not in "Live Expression Window" as you can see here:

2024-11-13_11h00_27.png

Ghofrane GSOURI
ST Employee

Hello @ledi7 

Try  to remove the expression and re-add it.

Please check this post , it could help you solve the issue.

I will be waiting for your feedback.

THX

Ghofrane

Hello @Ghofrane GSOURI 

as mentioned in the post you suggested, i changed debugging and optimization level for the compiler.I tried to set the optimization level in the Build Settings to level "Optimize for Debug (-Og)" and "None (-O0)".

Then i removed and re-added the entries in the "Live Expression Window". But nothing has changed, same result as bevore.

I am working with CubeIDE1.16.1 and using the BLE example "BLE_p2pServer_ota" with the NUCLEO-WBA55 board. Here, most of .c and .h files from the firmware package are linked. Could this triggers the issue?

 

Hello @ledi7 

Could you please verify that the Live Expressions is enabled in your configuration.

To do that please follow those steps:

1- right-clicking on your project in the Project Explorer and selecting Debug as-->1 STM32 C/C++ application

GhofraneGSOURI_0-1731590323402.png

Go to Debugger and make sure that the live expression option is tick then press OK

GhofraneGSOURI_1-1731590368875.png

 

.

Hello @Ghofrane GSOURI 

yes, live expression is activated.

2024-11-14_14h29_12.png

And for example, the variable "ledState" which is defined as "extern uint8_t ledState = 0;" is working in the Live Expressions window:

2024-11-14_14h34_11.png

 

Hello @ledi7 

Live Expressions can only evaluate variables that are currently in scope.  p_Notification is a local variable of a function that has exited 

void OTA_Notification(OTA_NotificationEvt_t *p_Notification);

 its memory may no longer be valid, leading to evaluation failures. Ensure you are trying to access the variable while still within the function where it is defined.

or  consider using global variables for debugging purposes, as they tend to be more stable in Live Expressions