Skip to content

Refactoring the TRAP logParser#7263

Open
varghese-bibin wants to merge 7 commits intoSamsung:masterfrom
varghese-bibin:master
Open

Refactoring the TRAP logParser#7263
varghese-bibin wants to merge 7 commits intoSamsung:masterfrom
varghese-bibin:master

Conversation

@varghese-bibin
Copy link
Copy Markdown

@varghese-bibin varghese-bibin commented Apr 13, 2026

Restructure log analysis into logAnalyser package with:

  • logPreprocessor.py: log formatting and binary discovery
  • logUtils.py: shared utility functions
  • log_parser/: specialized parsing modules (crashPoint, assertInfo, tcbInfo, heapNode)

Output of the tool :

Executing: trap.py -t /root/tizenrt/os/../tools/trap/file1 -e tinyara.axf


log_file : /root/tizenrt/os/../tools/trap/file1
Number of binaries : 3 [kernel + apps]
"kernel" elf_file : ../../../build/output/bin/tinyara.axf
"common" elf_file : ../../../build/output/bin/common_dbg
"app1" elf_file : ../../../build/output/bin/app1_dbg



result ------ 0x1219d88f
??
??:0

result ------ 0x1219d88f
??
??:0

  1. Crash Binary : NA

  2. Crash type : hard fault
    Crash log

    • print_assert_detail: Assertion failed at file:armv8-m/up_hardfault.c line: 215 task: Idle Task
  3. Crash point (PC or LR)

    • PC & LR values not in any text range! No probable crash point detected.
  4. Code asserted in:

    • Code asserted in normal thread.
  5. Call stack of last run thread
    Stack_address Symbol_address Symbol location Symbol_name File_name
    User stack
    User stack
    User stack
    User stack
    User stack
    User stack
    User stack
    User stack
    User stack
    User stack
    User stack
    User stack
    User stack

h. Heap Region information:

!!!! NO HEAP CORRUPTION DETECTED !!!!

Checking kernel heap for corruption
Checking corruption (0x70004e00 - 0x703ffff0) : Heap NOT corrupted
No Kernel heap corruption detected.

Checking kernel heap for corruption
Checking corruption (0x70004e00 - 0x703ffff0) : Heap NOT corrupted
No Kernel heap corruption detected.

Checking kernel heap for corruption
Checking corruption (0x70004e00 - 0x703ffff0) : Heap NOT corrupted
No Kernel heap corruption detected.

Checking kernel heap for corruption
Checking corruption (0x70004e00 - 0x703ffff0) : Heap NOT corrupted
No Kernel heap corruption detected.

Checking kernel heap for corruption
Checking corruption (0x70004e00 - 0x703ffff0) : Heap NOT corrupted
No Kernel heap corruption detected.

Checking kernel heap for corruption
Checking corruption (0x70004e00 - 0x703ffff0) : Heap NOT corrupted
No Kernel heap corruption detected.

Checking kernel heap for corruption
Checking corruption (0x70004e00 - 0x703ffff0) : Heap NOT corrupted
No Kernel heap corruption detected.

Checking kernel heap for corruption
Checking corruption (0x70004e00 - 0x703ffff0) : Heap NOT corrupted
No Kernel heap corruption detected.

Checking kernel heap for corruption
Checking corruption (0x70004e00 - 0x703ffff0) : Heap NOT corrupted
No Kernel heap corruption detected.

Checking kernel heap for corruption
Checking corruption (0x70004e00 - 0x703ffff0) : Heap NOT corrupted
No Kernel heap corruption detected.

Checking kernel heap for corruption
Checking corruption (0x70004e00 - 0x703ffff0) : Heap NOT corrupted
No Kernel heap corruption detected.

Checking kernel heap for corruption
Checking corruption (0x70004e00 - 0x703ffff0) : Heap NOT corrupted
No Kernel heap corruption detected.

Checking kernel heap for corruption
Checking corruption (0x70004e00 - 0x703ffff0) : Heap NOT corrupted
No Kernel heap corruption detected.

t. Asserted TCB info:

State : Running
Flags : 6 - Kernel Thread - Non-cancellable Pthread
Lock count : 1
Timeslice : 0
Waitdog : 0
WaitSem : 0
MsgwaitQ : 0
Sigdeliver : 0
Nsyscalls : 0

x. Miscellaneous information:

List of all tasks in the system:

NAME | PID | PRI | USED / TOTAL STACK | STACK ALLOC ADDR | TCB ADDR | TASK STATE

Idle Task | 0 | 0 | 8184 / 8192 | 0x38062000 | 0x70003210 | Running

List of all tasks in the system:

NAME | PID | PRI | USED / TOTAL STACK | STACK ALLOC ADDR | TCB ADDR | TASK STATE

Idle Task | 0 | 0 | 8184 / 8192 | 0x38062000 | 0x70003210 | Running

List of all tasks in the system:

NAME | PID | PRI | USED / TOTAL STACK | STACK ALLOC ADDR | TCB ADDR | TASK STATE

Idle Task | 0 | 0 | 8184 / 8192 | 0x38062000 | 0x70003210 | Running

List of all tasks in the system:

NAME | PID | PRI | USED / TOTAL STACK | STACK ALLOC ADDR | TCB ADDR | TASK STATE

Idle Task | 0 | 0 | 8184 / 8192 | 0x38062000 | 0x70003210 | Running

List of all tasks in the system:

NAME | PID | PRI | USED / TOTAL STACK | STACK ALLOC ADDR | TCB ADDR | TASK STATE

Idle Task | 0 | 0 | 8184 / 8192 | 0x38062000 | 0x70003210 | Running

List of all tasks in the system:

NAME | PID | PRI | USED / TOTAL STACK | STACK ALLOC ADDR | TCB ADDR | TASK STATE

Idle Task | 0 | 0 | 8184 / 8192 | 0x38062000 | 0x70003210 | Running

List of all tasks in the system:

NAME | PID | PRI | USED / TOTAL STACK | STACK ALLOC ADDR | TCB ADDR | TASK STATE

Idle Task | 0 | 0 | 8184 / 8192 | 0x38062000 | 0x70003210 | Running

List of all tasks in the system:

NAME | PID | PRI | USED / TOTAL STACK | STACK ALLOC ADDR | TCB ADDR | TASK STATE

Idle Task | 0 | 0 | 8184 / 8192 | 0x38062000 | 0x70003210 | Running

List of all tasks in the system:

NAME | PID | PRI | USED / TOTAL STACK | STACK ALLOC ADDR | TCB ADDR | TASK STATE

Idle Task | 0 | 0 | 8184 / 8192 | 0x38062000 | 0x70003210 | Running

List of all tasks in the system:

NAME | PID | PRI | USED / TOTAL STACK | STACK ALLOC ADDR | TCB ADDR | TASK STATE

Idle Task | 0 | 0 | 8184 / 8192 | 0x38062000 | 0x70003210 | Running

List of all tasks in the system:

NAME | PID | PRI | USED / TOTAL STACK | STACK ALLOC ADDR | TCB ADDR | TASK STATE

Idle Task | 0 | 0 | 8184 / 8192 | 0x38062000 | 0x70003210 | Running

List of all tasks in the system:

NAME | PID | PRI | USED / TOTAL STACK | STACK ALLOC ADDR | TCB ADDR | TASK STATE

Idle Task | 0 | 0 | 8184 / 8192 | 0x38062000 | 0x70003210 | Running

List of all tasks in the system:

NAME | PID | PRI | USED / TOTAL STACK | STACK ALLOC ADDR | TCB ADDR | TASK STATE

Idle Task | 0 | 0 | 8184 / 8192 | 0x38062000 | 0x70003210 | Running

#!/usr/bin/env python
###########################################################################
#
# Copyright 2024 Samsung Electronics All Rights Reserved.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2024 -> 2026

assertInfo.parse_assert_info(self)

# It displays the debug symbols corresponding to all the addresses in the kernel and application text address range
self.parse_call_stack()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason why parse_call_stack() and parse_heap_info are in Class, but parse_tcb_info and find_crash_point are outside this Class?

format_log_file(lparser.log_file)

# Get the number of application binaries, names, text address and sizes
find_number_of_binaries(lparser) No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a extra new line.

@seokhun-eom24
Copy link
Copy Markdown
Contributor

Could you also share the test result of this refactoring in commit message and PR message.

Comment on lines +26 to +28
stack_details = "Asserted task's stack details\n"

partition_string = "==========================================================="
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we manage the strings separately?
When we change some log format in assert, then we must modify here together.
But now, each file includes necessary string for each. It's much difficult to maintain.
I want a new file which has all necessary strings (which can be changed by assert) for TRAP.

@varghese-bibin
Copy link
Copy Markdown
Author

I will check and modify.

@varghese-bibin varghese-bibin force-pushed the master branch 2 times, most recently from dcdffa9 to 20aa65c Compare April 21, 2026 04:41
a. Separated the preprocessing functions from logParser.py and kept them in a separate preProcessor.py file
b. moved logParser.py and logPreprocesser.py to logAnalyser folder, to keep the similar types of file together
c. preProcessing includes format_log_file() and find_number_of_binaries()
d. instead of calling these function trap.py call preprocessLogFile
…s module

a. created cli/logAnalyser/logUtils.py
b. moved all the independent helper functions from logParser.py to it
c. format output, print crash type, is text addr, is app adrr, convert state no
a. split up the major/lengthy functions in logParser.py and kept them in separate files
b. parse assert info -> assertInfo.py
c. find crash point -> crashPoint.py
d. parse tcb info -> tcbinfo.py
e. cli/logAnalyser/log_parser : kept all these related files in this folder
f. also moved heapNode.py to this folder, as its only called from logParser.py
a. changed Copyright 2024 -> 2026 for new files
b. added newline at the end of the files
c. kept all the strings used in cli/logAnalyser in cli/logAnalyser/logUtils.py
a. Modified `parse_assert_info()` in `cli/logAnalyser/log_parser/assertInfo.py`
b. Refactored monolithic function into modular design for improved maintainability
c. Added preprocessing stage: `format_log_file()` and `find_number_of_binaries()`
d. Split assert info parsing into dedicated handlers: `parse_assert_info()`, `get_assert_location()`, `check_IRQ_assertion()`, `memory_allocation_failure()`, `print_current_task()`
a. Modified `find_crash_point()` in `cli/logAnalyser/log_parser/crashPoint.py`
b. Refactored monolithic function into modular design for improved maintainability
c. Split crash point detection into dedicated handlers: `find_crash_point()`, `extract_crash_info()`, `check_app_crash()`, `check_kernel_crash()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants