Skip to main content

Python module for operating with freeRTOS-kernel objects in GDB

Project description

Freertos-gdb

Python module for user-friendly view freeRTOS-kernel objects in GDB

Requirements

GDB must built with python 3.6+ support

Check your GDB with command:

gdb -q -ex "python print('OK' if sys.version_info.major==3 and sys.version_info.minor>=6 else 'NOT SUPPORTED')" -ex "quit"

develop

sudo python setup.py develop

publish

python setup.py sdist bdist_wheel
twine upload dist/*

Install

  1. Install the distro using pip
pip install wqtool_gdb

Run

Start GDB and run the command

python import wqtool_gdb

Also, you could just update .gdbinit with this command

Possible problems and solutions

ModuleNotFoundError

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'freertos_gdb'
Error while executing Python code.

Solution

Check your sys.path inside GDB shell

python import sys; print(sys.path)

Append sys.path with a path to directory which contains freertos_gdb module. Or execute GDB with right PYTHONPATH env variable

Commands

You have freertos command with subcommands inside:

(gdb) freertos 
"freertos" must be followed by the name of a subcommand.
List of freertos subcommands:

freertos heap -- Generate a print out of the current heap info.
freertos queue --  Generate a print out of the current queues info.
freertos semaphore --  Generate a print out of the current semaphores info.
freertos task --  Generate a print out of the current tasks and their states.
freertos timer --  Generate a print out of the current timers info.
....

Examples

Tasks

(gdb) freertos task
CPU	 - Processing on CPU number
ID	 - TCB_t task memory address
PRI	 - Task priority
B_PRI	 - Base priority.
SS	 - Stack size.
SL	 - Stack limit (available space left).

CPU    ID          NAME       STATUS       PRI    B_PRI    MUTEXES_HELD    SS    SL
-----  ----------  ---------  ---------  -----  -------  --------------  ----  ----
CPU0   0x3ffb6674  IDLE       ready          0        0               0  1104   428
       0x3ffb6dd4  IDLE       ready          0        0               0  1104   428
CPU1   0x3ffbb724  SEM_RECUR  ready          6        6               1  1680   364
       0x3ffafd14  ipc0       suspended     24       24               0   564   456
       0x3ffb4db4  esp_timer  suspended     22       22               0  3648   444
       0x3ffb3c54  ipc1       suspended     24       24               0   592   428
       0x3ffb7734  Tmr Svc    delayed_1      1        1               0  1584   460
       0x3ffaf83c  SENDER1    delayed_1      6        6               0  1600   444
       0x3ffaf998  SENDER2    delayed_1      6        6               0  1548   496
       0x3ffb909c  READER1    delayed_1      6        6               0  1608   436
       0x3ffb99fc  READER2    delayed_1      6        6               0  1608   436
       0x3ffba35c  SEM_BIN1   delayed_1      6        6               0  1624   420
       0x3ffbacbc  SEM_BIN2   delayed_1      6        6               0  1592   452

Queues, Semafores (and mutexes)

To watch queues you must add them to registry via vQueueAddToRegistry

(gdb) freertos queue 
COUNT	 - Number of items currently in the queue.
I_LEN	 - Length of the queue (number of items could hold, not the number of bytes).
I_SIZE	 - Size of each item that the queue will hold.
TASKS_WAITING_TO_SEND	 - Tasks that are blocked waiting to post onto this queue.
TASKS_WAITING_TO_RECEIVE	 - Tasks that are blocked waiting to read from this queue.
RX_LCK	 - Number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked.
TX_LCK	 - Number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked.

NAME    COUNT    I_LEN    I_SIZE    TASKS_WAITING_TO_SEND    TASKS_WAITING_TO_RECEIVE    RX_LCK    TX_LCK
------  -------  -------  --------  -----------------------  --------------------------  --------  --------
TmrQ    0        10       16                                 0x3ffb7734 Tmr Svc          -1        -1
queue1  10       10       4         0x3ffaf83c SENDER1                                   -1        -1
                                    0x3ffaf998 SENDER2
queue2  0        10       4                                  0x3ffb909c READER1          -1        -1
                                                             0x3ffb99fc READER2
(gdb) freertos semaphore 
COUNT	 - Number of items currently in the queue.
I_LEN	 - Length of the queue (number of items could hold, not the number of bytes).
MUTEX_HOLDER	 - The handle of the task that holds the lock.
RCALLCOUNT	 - Number of times a recursive mutex has been recursively "taken".
TASKS_WAITING_TO_GIVE	 - Tasks that are blocked waiting to release a lock.
TASKS_WAITING_TO_TAKE	 - Tasks that are blocked waiting to take a lock.

NAME             COUNT    I_LEN    MUTEX_HOLDER          RCALLCOUNT    TASKS_WAITING_TO_GIVE    TASKS_WAITING_TO_TAKE
---------------  -------  -------  --------------------  ------------  -----------------------  -----------------------
BINARY           0        1                                                                     0x3ffba35c SEM_BIN1
                                                                                                0x3ffbacbc SEM_BIN2
COUNTING         5        10
MUTEX            1        1                              0
RECURSIVE_MUTEX  0        1        0x3ffbb724 SEM_RECUR  1628326

Timers

(gdb) freertos timer 
TIMER_ID	 - An ID to identify the timer.
OVERFLOW	 - True if timer has been overflow
PERIOD_IN_TICKS	 - How quickly and often the timer expires.
STATUS	 - Holds bits to say if the timer was statically allocated or not, and if it is active or not.

TIMER_ID    NAME      OVERFLOW    PERIOD_IN_TICKS    STATUS  CALLBACK_FN
----------  ------  ----------  -----------------  --------  ---------------------------
0x2         TIMER3           0                400         5  0x400d490c <vTimerCallback>
0x3         TIMER2           0                300         5  0x400d490c <vTimerCallback>
0x5         TIMER1           0                200         5  0x400d490c <vTimerCallback>
0x2         TIMER4           0                500         5  0x400d490c <vTimerCallback>

Heap

(gdb) freertos heap 
{pxNextFreeBlock = 0x2013238, xBlockSize = 32}
{pxNextFreeBlock = 0x2013278, xBlockSize = 32}
{pxNextFreeBlock = 0x2013368, xBlockSize = 32}
{pxNextFreeBlock = 0x2013670, xBlockSize = 56}
{pxNextFreeBlock = 0x20136f8, xBlockSize = 16}
{pxNextFreeBlock = 0x2013820, xBlockSize = 264}
{pxNextFreeBlock = 0x2013df0, xBlockSize = 760}
{pxNextFreeBlock = 0x2028f98, xBlockSize = 1168}
{pxNextFreeBlock = 0x2029188, xBlockSize = 232}
{pxNextFreeBlock = 0x2034258, xBlockSize = 32}
{pxNextFreeBlock = 0x20342f0, xBlockSize = 32}
{pxNextFreeBlock = 0x2034338, xBlockSize = 24}
{pxNextFreeBlock = 0x20491f8, xBlockSize = 32}
{pxNextFreeBlock = 0x2049448, xBlockSize = 32}
{pxNextFreeBlock = 0x204a940, xBlockSize = 24}
{pxNextFreeBlock = 0x204aa38, xBlockSize = 24}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wqtool_gdb-1.0.0.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wqtool_gdb-1.0.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file wqtool_gdb-1.0.0.tar.gz.

File metadata

  • Download URL: wqtool_gdb-1.0.0.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for wqtool_gdb-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3b9f6cfece4abff9e6dbc8615cc46aa7e09e454320d337521bc9d5419b872d5d
MD5 c936a8fdb3177803e378e55298de6217
BLAKE2b-256 023453c7aebdc18ef3653bc659462b6e0a5b7f1e0bc36d8a4e07e31f898092b5

See more details on using hashes here.

File details

Details for the file wqtool_gdb-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: wqtool_gdb-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for wqtool_gdb-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 910e97adeea7a0703c09631ae12ec59cfd9685028e52a68ee1afdfd1a91228b7
MD5 cf23cfcfc5187754c45337ff70783ee2
BLAKE2b-256 c409fb9dc6829f39fd487efea2afd8189bd44fe1fdfeb5015d2d2db07e69e540

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page