Code Monkey home page Code Monkey logo

Comments (6)

adamgreen avatar adamgreen commented on August 18, 2024 1

This is like the thread awareness debugging. We just finish NuttX thread awareness debugging, can we reuse that code?

I wouldn't be surprised if it is similar.

from mri.

xiaoxiang781216 avatar xiaoxiang781216 commented on August 18, 2024 1

Got the answer, let's close now.

from mri.

adamgreen avatar adamgreen commented on August 18, 2024

Normally MRI is meant to be used as a kernel debugger. It can debug and step through almost all code in the system and it does this by running at the highest priority level in the system.

In the case of Arduino, we wanted to use the USB stack as the communication channel which meant keeping most of the RTOS running while MRI was debugging. This means that MRI is actually being run in ARM's thread mode at the lowest priority level and can only debug other 'user' mode threads. It can't debug any ISRs which run in 'handler' mode so no device or kernel debugging is possible. Arduino's ThreadDebug Library

Those MRI_THREAD_MRI sections are there because in that case, that work isn't done by the MRI core but must be done from the user mode portion. I don't really expect others to use that model so I don't really document it. It seems to work in the Arduino code base but I am not 100% confident in the implementation yet.

from mri.

xiaoxiang781216 avatar xiaoxiang781216 commented on August 18, 2024

Thanks, this information is very useful to support the complex transport(USB/WiFi) other than UART.

from mri.

adamgreen avatar adamgreen commented on August 18, 2024

Yes it is good for that, at the cost of not being able to debug things which run at the same priority level as the USB/WiFi stack or higher.

On my current robot, I use the BLE stack as the communication channel back to GDB. To allow the BLE stack to run while MRI has a program halted for debugging, I need to run MRI at a priority level of 6 on a Cortex-M4F where priority level 7 is the lowest priority. This means that I can only debug ISRs running at that lowest level (level 7). Any ISR running at a higher priority will not be debuggable by MRI. In this scenario I am running MRI at a priority level lower than 0 but still not in thread mode so I don't need to set MRI_THREAD_MRI macro to a non-zero value though.

The big thing that changes when you set MRI_THREAD_MRI is that you will need to write code which can fetch the register context from wherever NuttX has stored it when it was halted for debugging. In the Arduino case, I freeze the halted thread in the RTX RTOS (and usually most of the other threads as well) and then manually probe RTX's data structures to find the register context and use it to build up the context record required by MRI before calling mriDebugException().

from mri.

xiaoxiang781216 avatar xiaoxiang781216 commented on August 18, 2024

Yes it is good for that, at the cost of not being able to debug things which run at the same priority level as the USB/WiFi stack or higher.

On my current robot, I use the BLE stack as the communication channel back to GDB. To allow the BLE stack to run while MRI has a program halted for debugging, I need to run MRI at a priority level of 6 on a Cortex-M4F where priority level 7 is the lowest priority. This means that I can only debug ISRs running at that lowest level (level 7). Any ISR running at a higher priority will not be debuggable by MRI. In this scenario I am running MRI at a priority level lower than 0 but still not in thread mode so I don't need to set MRI_THREAD_MRI macro to a non-zero value though.

The big thing that changes when you set MRI_THREAD_MRI is that you will need to write code which can fetch the register context from wherever NuttX has stored it when it was halted for debugging. In the Arduino case, I freeze the halted thread in the RTX RTOS (and usually most of the other threads as well) and then manually probe RTX's data structures to find the register context and use it to build up the context record required by MRI before calling mriDebugException().

This is like the thread awareness debugging. We just finish NuttX thread awareness debugging, can we reuse that code?

from mri.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.