SlideShare a Scribd company logo
Submit Search
Upload
Login
Signup
Kernel Debugging & Profiling
Report
Anil Kumar Pugalia
Follow
Linux Geek and Open Source Hardware & Software Freak, Corporate Trainer, Entrepreneur in Automation
Aug. 23, 2019
•
0 likes
•
5,918 views
1
of
14
Kernel Debugging & Profiling
Aug. 23, 2019
•
0 likes
•
5,918 views
Report
Technology
Kernel Debugging & Profiling
Anil Kumar Pugalia
Follow
Linux Geek and Open Source Hardware & Software Freak, Corporate Trainer, Entrepreneur in Automation
Recommended
Architecture Porting
Anil Kumar Pugalia
5K views
•
12 slides
Introduction to Linux
Anil Kumar Pugalia
4K views
•
33 slides
Bootloaders
Anil Kumar Pugalia
9.8K views
•
19 slides
Kernel Debugging & Profiling
Anil Kumar Pugalia
18.8K views
•
14 slides
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
3.9K views
•
27 slides
Embedded Storage Management
Anil Kumar Pugalia
4.1K views
•
16 slides
More Related Content
What's hot
Real Time Systems
Anil Kumar Pugalia
17.5K views
•
41 slides
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
4.6K views
•
24 slides
Toolchain
Anil Kumar Pugalia
15K views
•
21 slides
Signals
Anil Kumar Pugalia
9.8K views
•
15 slides
PCI Drivers
Anil Kumar Pugalia
44.2K views
•
16 slides
Shell Scripting
Anil Kumar Pugalia
6.2K views
•
27 slides
What's hot
(20)
Real Time Systems
Anil Kumar Pugalia
•
17.5K views
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
•
4.6K views
Toolchain
Anil Kumar Pugalia
•
15K views
Signals
Anil Kumar Pugalia
•
9.8K views
PCI Drivers
Anil Kumar Pugalia
•
44.2K views
Shell Scripting
Anil Kumar Pugalia
•
6.2K views
Linux Network Management
Anil Kumar Pugalia
•
11.2K views
Character Drivers
Anil Kumar Pugalia
•
56.5K views
BeagleBone Black Booting Process
SysPlay eLearning Academy for You
•
18.2K views
Linux User Space Debugging & Profiling
Anil Kumar Pugalia
•
6.5K views
BeagleBoard-xM Booting Process
SysPlay eLearning Academy for You
•
3.8K views
Linux DMA Engine
SysPlay eLearning Academy for You
•
6K views
Kernel Programming
Anil Kumar Pugalia
•
24.3K views
Introduction to Linux Drivers
Anil Kumar Pugalia
•
64.4K views
BeagleBoard-xM Bootloaders
SysPlay eLearning Academy for You
•
7.2K views
SPI Drivers
SysPlay eLearning Academy for You
•
10K views
Embedded Software Design
Anil Kumar Pugalia
•
6.9K views
System Calls
Anil Kumar Pugalia
•
9.7K views
Kernel Timing Management
SysPlay eLearning Academy for You
•
3K views
Video Drivers
Anil Kumar Pugalia
•
23.2K views
Similar to Kernel Debugging & Profiling
Android Boot Time Optimization
Kan-Ru Chen
13K views
•
59 slides
OSMC 2014: Server Hardware Monitoring done right | Werner Fischer
NETWAYS
643 views
•
85 slides
Mod06 new development tools
Peter Haase
402 views
•
30 slides
Embedded Android
晓东 杜
241 views
•
66 slides
Virtual platform
sean chen
756 views
•
27 slides
HKG18-TR14 - Postmortem Debugging with Coresight
Linaro
549 views
•
19 slides
Similar to Kernel Debugging & Profiling
(20)
Android Boot Time Optimization
Kan-Ru Chen
•
13K views
OSMC 2014: Server Hardware Monitoring done right | Werner Fischer
NETWAYS
•
643 views
Mod06 new development tools
Peter Haase
•
402 views
Embedded Android
晓东 杜
•
241 views
Virtual platform
sean chen
•
756 views
HKG18-TR14 - Postmortem Debugging with Coresight
Linaro
•
549 views
QEMU - Binary Translation
Jiann-Fuh Liaw
•
16.6K views
Study on Android Emulator
Samael Wang
•
6.7K views
[2009 CodeEngn Conference 03] koheung - 윈도우 커널 악성코드에 대한 분석 및 방법
GangSeok Lee
•
2.5K views
Network Drivers
Anil Kumar Pugalia
•
39.1K views
Mobile Hacking using Linux Drivers
Anil Kumar Pugalia
•
6K views
There is more to C
Juraj Michálek
•
2K views
DEF CON 27 - HUBER AND ROSKOSCH - im on your phone listening attacking voip c...
Felipe Prado
•
145 views
Linux on System z debugging with Valgrind
IBM India Smarter Computing
•
1.6K views
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
Paris Open Source Summit
•
710 views
Character drivers
pradeep_tewani
•
138 views
Solaris Kernel Debugging V1.0
Jarod Wang
•
3.8K views
SR-IOV Introduce
Lingfei Kong
•
4.2K views
Linux kernel debugging
Hao-Ran Liu
•
1.3K views
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
DefCamp
•
1.6K views
More from Anil Kumar Pugalia
File System Modules
Anil Kumar Pugalia
20.7K views
•
37 slides
Processes
Anil Kumar Pugalia
7K views
•
33 slides
System Calls
Anil Kumar Pugalia
4.1K views
•
17 slides
Embedded C
Anil Kumar Pugalia
25.6K views
•
20 slides
Playing with R L C Circuits
Anil Kumar Pugalia
2.8K views
•
17 slides
Audio Drivers
Anil Kumar Pugalia
20.6K views
•
11 slides
More from Anil Kumar Pugalia
(20)
File System Modules
Anil Kumar Pugalia
•
20.7K views
Processes
Anil Kumar Pugalia
•
7K views
System Calls
Anil Kumar Pugalia
•
4.1K views
Embedded C
Anil Kumar Pugalia
•
25.6K views
Playing with R L C Circuits
Anil Kumar Pugalia
•
2.8K views
Audio Drivers
Anil Kumar Pugalia
•
20.6K views
References
Anil Kumar Pugalia
•
21.7K views
Functional Programming with LISP
Anil Kumar Pugalia
•
6.1K views
Power of vi
Anil Kumar Pugalia
•
3K views
gcc and friends
Anil Kumar Pugalia
•
14.2K views
"make" system
Anil Kumar Pugalia
•
4.2K views
Hardware Design for Software Hackers
Anil Kumar Pugalia
•
1.7K views
RPM Building
Anil Kumar Pugalia
•
4K views
Timers
Anil Kumar Pugalia
•
6.5K views
Threads
Anil Kumar Pugalia
•
10.1K views
Synchronization
Anil Kumar Pugalia
•
9K views
Processes
Anil Kumar Pugalia
•
7.5K views
Linux Memory Management
Anil Kumar Pugalia
•
27.5K views
Linux File System
Anil Kumar Pugalia
•
24.4K views
Inter Process Communication
Anil Kumar Pugalia
•
44K views
Recently uploaded
Demystifying ML/AI
Matthew Reynolds
22 views
•
30 slides
How to Manage Your Offshore Software Development Team Efficiently
Capital Numbers
23 views
•
15 slides
Improve Employee Experiences on Cisco RoomOS Devices, Webex, and Microsoft Te...
ThousandEyes
89 views
•
26 slides
Announcing InfluxDB Clustered
InfluxData
47 views
•
30 slides
Die ultimative Anleitung für HCL Nomad Web Administratoren
panagenda
53 views
•
71 slides
who we are - values.pptx
LauraGarceran
30 views
•
5 slides
Recently uploaded
(20)
Demystifying ML/AI
Matthew Reynolds
•
22 views
How to Manage Your Offshore Software Development Team Efficiently
Capital Numbers
•
23 views
Improve Employee Experiences on Cisco RoomOS Devices, Webex, and Microsoft Te...
ThousandEyes
•
89 views
Announcing InfluxDB Clustered
InfluxData
•
47 views
Die ultimative Anleitung für HCL Nomad Web Administratoren
panagenda
•
53 views
who we are - values.pptx
LauraGarceran
•
30 views
Scaling out with WordPress
Konstantin Kovshenin
•
50 views
Elevate Your Enterprise with FME 23.1
Safe Software
•
235 views
DWeb and Civil Society: An Introduction For Makers
TechSoup
•
47 views
Improving Employee Experiences on Cisco RoomOS Devices, Webex, and Microsoft ...
ThousandEyes
•
56 views
MapInfo Pro v2023: The Next Dimension in Spatial Analytics
Precisely
•
38 views
UiPath Tips and Techniques for Error Handling - Session 2
DianaGray10
•
20 views
Smart Contracts - The Blockchain Beyond Bitcoin
Jim McKeeth
•
36 views
Jino Clone: Develop a Car Wash Mobile App with Limited Resources
eSiteWorld TechnoLabs Pvt. Ltd.
•
28 views
Regulating Generative AI - LLMOps pipelines with Transparency
Debmalya Biswas
•
42 views
Microsoft Azure New - Sep 2023
Daniel Toomey
•
32 views
Accelerating Data Science through Feature Platform, Transformers, and GenAI
FeatureByte
•
125 views
Metadata & Discovery Group Conference 2023 - Day 1 Programme
CILIP MDG
•
21 views
Experts Live Europe 2023 - Ensure your compliance in Microsoft Teams with Mic...
Jasper Oosterveld
•
30 views
Inclusivity and AI: opportunity or threat
Alan Dix
•
34 views
Kernel Debugging & Profiling
1.
© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Kernel Debugging & Profiling
2.
2© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. What to Expect? Kernel Debugging Tools & Techniques Kernel Profiling Tools & Mechanism Kernel Testing Ways
3.
3© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Debugging by Printing printk & dmesg int klogctl(int cmd, char *bufp, int len); syslogd #include <syslog.h> void openlog(char *ident, int option, int facility); void syslog ( int priority, char *format, …); void closelog( void ); ident – typically short program name option - LOG_CONS, LOG_PERROR, LOG_PID, … facility - LOG_AUTHPRIV, LOG_CRON, LOG_DAEMON, LOG_USER, ... priority - LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG klogd – bridge between kernel ring buffer and syslogd
4.
4© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Debugging by Querying Through Kernel Windows /proc Process related stuff General system information: cpuinfo, meminfo, … Drivers related info: devices, iomem, interrupts, ... /sys (Utilities: sysfsutils, sysdiag) Buses, Classes, Devices, ... Using ioctl Through specific drivers Using custom commands
5.
5© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Crash Dumping & Analysis Oops Analysis CONFIG_BUG, CONFIG_KALLSYMS Call Trace cat /proc/kallsyms objdump -d | -S <obj | exe> Crash Dumping (using 2 kernel images – could be same) System Kernel: CONFIG_KEXEC, CONFIG_DEBUG_INFO Dump-capture Kernel: CONFIG_CRASH_DUMP, CONFIG_PROC_VMCORE, Other Architecture specific CONFIG_s Boot System Kernel with crashkernel=size@offset, or crashkernel=range:size Overlay Dump-capture Kernel using kexec After Crash (Simulated using SysRq+c, Or real) System reboots w/ Dump-capture Kernel Collect the dump using kdump, Or simply cp /proc/vmcore <dump file> Analyse using <gdb | crash> vmlinux <dump file>
6.
6© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Kernel Hacking Related Options CONFIG_DEBUG_INFO (gcc -g) CONFIG_DEBUG_FS CONFIG_DYNAMIC_DEBUG CONFIG_DEBUG_STACKOVERFLOW CONFIG_KMEMCHECK CONFIG_DEBUG_KMEMLEAK, CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE, ... CONFIG_LOCKUP_DETECTOR CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_MUTEXES, ... CONFIG_MAGIC_SYSRQ CONFIG_EARLY_PRINTK CONFIG_DEBUG_SLAB, CONFIG_DEBUG_VM, ... CONFIG_DEBUG_STACK_USAGE CONFIG_PANIC_ON_OOPS CONFIG_PANIC_ON_OOPS_VALUE
7.
7© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Kernel Debuggers Kernel Debugger (Frontend): kdb CONFIG_DEBUG_INFO, CONFIG_MAGIC_SYSRQ CONFIG_KGDB, CONFIG_KGDB_KDB, CONFIG_KGDB_SERIAL_CONSOLE Basic Operations over Serial Console Remote Debugging using kgdb (Kernel Debug Server) Remote connection & debug through gdb vmlinux gdb <kernel src>/vmlinux /proc/kcore Only to gather current kernel debug information
8.
8© 2010-16 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Miscellaneous Tools & Techniques Early Init Debugs CONFIG_SERIAL_EARLYCON CONFIG_EARLY_PRINTK (direct on h/w) Light & Sound JTAG Hardware Protocol Debug Hardware Protocol Analyzers Network Debugging Driver level: ethtool [options] <dev i/f> Packet level: tcpdump [options, e.g. -vv] -i <dev i/f>
9.
9© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Kernel Probes kprobes → CONFIG_KPROBES jprobes → Specialized Kprobes For probing function entry points kretprobes → Return Kprobes For probing function exit points
10.
10© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Tracing Single Process Tracing using strace Traces the system calls made by an application Command: strace [options] <application> Excellent options to tune to get only desired output Linux Trace Toolkit Patch @ http://www.opersys.com/LTT Core Module Code using Trace Services Daemon: tracedaemon Utilities: tracereader, tracevisualizer Function Tracer CONFIG_FUNCTION_TRACER & co /sys/kernel/debug/tracing
11.
11© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Profiling & Code Coverage System Profiling From /proc using LTTng Kernel Profiling: Oprofile CONFIG_PROFILING, CONFIG_OPROFILE, CONFIG_APIC Daemon: oprofiled Utilities: opcontrol, opreport, op_help, ... Kernel Performance Profiling using perf CONFIG_PERF_EVENTS & co stat, list, top, record, report, ... Kernel Code Coverage: CONFIG_GCOV_KERNEL, CONFIG_GCOV_PROFILE_ALL
12.
12© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Testing Possibilities Linux Test Project (LTP) Hosted @ http://ltp.sourceforge.net Suite of around 3000 tests Exercises various parts of the Kernel Mostly automated, except net & storage ones Command: runltp -p -l logfile User Mode Linux (UML) Hosted @ http://user-mode-linux.sourceforge.net A Kernel Instance as a User Mode Process Kernel Debugging without “oops”ing Good for testing & experimenting with unstable kernels
13.
13© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. What all have we learnt? Kernel Debugging Tools & Techniques Debugging by Printing & Querying Crash Dumping & Analysis Kernel Hacking Options Kernel Debuggers Miscellaneous Tools & Techniques Kernel Probes Tracing Kernel Profiling Tools & Mechanism Kernel Testing Ways
14.
14© 2010-19 SysPlay
Workshops <workshop@sysplay.in> All Rights Reserved. Any Queries?