SlideShare a Scribd company logo
   FreeBSD Kernel Debugging
   Port Development
gdb                          Kdgb

DTrace              Valgrind   ktrace            ktr

                                        Kernel
         Userland
                                        Space
Kernel


Debugging            Tracking
   The process that takes a control of execution
    of another process and make step over of
    code to view the process execution, show
    relation between consecutive processes.
   Debugging mainly used to detect error or
    bugs.
Common
Strategies


 Kernel Crash

  Kernel Hang
●   dumpon(8) and savecore(8)
     –   /etc/rc.conf
●   [syrinx@tweety]/(76)% cat /etc/rc.conf | grep dump
●   dumpdev="/dev/ad4s4b"
●   dumpdir="/var/crash/"

●   Remote systems
●   options DDB_UNATTENDED

●   Virtual machines - Pros and cons
     –   Qemu
     –   VirtualBox
●   Kernel configuration

makeoptions            DEBUG=-g   #memguard(9) and redzone(9)
                                  options            DEBUG_MEMGUARD
#ktrace(1)                        options            DEBUG_REDZONE
options       KTRACE
                                  #ktr(4)
options       KDB                 options         KTR
options       KDB_TRACE           options         ALQ
options       DDB                 options         ALQ_KTR
options       GBD                 options         KTR_ENTRIES=4096
                                  options         KTR_COMPILE=KTR_INET
options       INVARIANTS          options         KTR_MASK=KTR_INET
options       INVARIANT_SUPPORT   options         KTR_CPUMASK=0x3
options       WITNESS
options       WITNESS_SKIPSPIN
options       LOCK_PROFILING
●   If kernel dies, display driver dies too
●   Do not panic the system while fsck (8) is running
●   [syrinx@tweety]/(78)% cat /etc/rc.conf | grep fsck
●   fsck_y_enable="YES"
●   background_fsck="NO"

●   Core dumps may contain sensitive information
●   # boot -s
●   # dumpon /dev/ad4s4b
●   # mount -a -art ufs
●   # /command-to-crash-the-kernel
ddb(8)        kgmon(8)
kgdb(1)       pmcstat(1)
ktr(4)        hwpmc(4)
ktr(9)        addr2line(1)
ktrdump(8)    kldstat(8)
ktrace(1)     fstat(1)
kdump(1)      iostat(8)
dmesg(8)      ipcs(1)
objdump(1)    ipmi(9)
size(1)       netstat(1)
savecore(8)   ps(1)
dumpon(8)     vmstat(8)
textdump(8)   redzone(9)
hexdump(1)    memguard(9)
              truss(1)
●   Kernel crashes usually require straighforward
    approach
●   kgdb(1) is an extention of gdb(1) that
    understands FreeBSD kernel corefiles
●   Symbol resolving
●   Scripting support
●   On-line debugging via /dev/mem
●   Remote debugging
    –         via serial line
    –          via firewire
[syrinx@tweety]/home/syrinx(92)% sudo kgdb /boot/kernel.old/kernel /var/crash/vmcore.1
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.

Unread portion of the kernel message buffer:
rum0: could not multi read MAC register: USB_ERR_NOT_CONFIGURED


Fatal trap 12: page fault while in kernel mode
cpuid = 1; apic id = 01
fault virtual address = 0x0
fault code          = supervisor read, page not present
instruction pointer = 0x20:0xc069bf24
stack pointer        = 0x28:0xe6b40c44
frame pointer        = 0x28:0xe6b40c60
code segment           = base 0x0, limit 0xfffff, type 0x1b
                 = DPL 0, pres 1, def32 1, gran 1
processor eflags       = interrupt enabled, resume, IOPL = 0
current process        = 0 (rum0 taskq)
panic: from debugger
●   NULL Pointer Dereference
●   Resource leak
●   Bad test condition, resulting in code path never executed
●   Use before test (NULL/-1)
●   Use after free
●   Buffer overflow
●   Unsafe use of returned value
●   Uninitialized value read
●   Type and allocation size mismatch
●   ddb(4) – interactive kernel   ●   Inspecting locks with ddb
    debugger                      ●   db> show lock [lockaddr]
●   Poor symbol resolving         ●   db> show turnstile [lockaddr]
    compared to kgdb(1)
                                  ●   # mutexes
●   Extensible – new commands     ●   db> show lockchain
    added at compile time -
                                  ●   # six locks, sleepqueues
●   Sources at src/sys/ddb
                                  ●   db> show sleepchain
●   Scripting support since
    FreeBSD 7.1 – ddb(8)
                                  ●   More info in manual page.
●   Enter DDB
●   #sysctl debug.kdb.enter=1
   Examination of CPU registers, variables, etc.
   Stepping over the instructions code to view
    the process execution.
   ps shows selected fields from the process
    structures. With an understanding of the
    structures, it can give a good idea of what's
    going on.
    top is like a repetitive ps: it shows the most
    active processes at regular intervals.
   vmstat shows a number of parameters,
    including virtual memory. It can also be set
    up to run at regular intervals.
    iostat is similar to vmstat, and it duplicates
    some fields, but it concentrates more on I/O
    activity.
   netstat show network information. It can also
    be set up to show transfer rates for specific
    interfaces.
   systat is a curses-based program which
    displays a large number of parameters,
    including most of the parameters displayed
    by vmstat, iostat and netstat.
[syrinx@tweety]/home/syrinx(71)% sysctl debug.ktr
debug.ktr.alq_enable: 0
debug.ktr.alq_file: /tmp/ktr.out
debug.ktr.alq_depth: 1024
debug.ktr.alq_failed: 0
debug.ktr.alq_cnt: 0
debug.ktr.alq_max: 0
debug.ktr.clear: 0
debug.ktr.version: 2
debug.ktr.entries: 1024
debug.ktr.compile: 270540806
debug.ktr.mask: 270540806
debug.ktr.cpumask: 3

●   KTR buffer accessible in DDB
db> show ktr [v]

●   read the contents of a ktr(4) file
[syrinx@tweety]/(105)% sudo ktrdump -t -o /tmp/ktr.out
●     Kernel process tracing
●     [syrinx@tweety]/home/syrinx(89)% ktrace -a -tcy -f /home/syrinx/krtace.out
      ifconfig



●     kdump(1) displays the kernel trace data
●     [syrinx@tweety]/home/syrinx(91)% kdump -f ~/krtace.out
    ...
    7490 ifconfig CALL write(0x1,0x28203000,0x38)
    7490 ifconfig GIO fd 1 wrote 56 bytes
        options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
    7490 ifconfig RET write 56/0x38
    7490 ifconfig CALL ioctl(0x3,SIOCGIFMAC,0xbfbfdfac)
    7490 ifconfig RET ioctl -1 errno 22 Invalid argument
    7490 ifconfig CALL ioctl(0x3,SIOCGIFMEDIA,0xbfbfdfa0)
    ...
   ktrace -d -i -p 0
   kdump –f ktrace.out >>myfile.txt
1.   Writing the Makefile.
2.   Writing the description files.
3.   Creating the checksum file
4.   Testing the port
5.   Checking your port with portlint
6.   Submitting the port.
# New ports collection makefile for: oneko
# Date created:     5 December 1994
# Whom:            asami
#
# $FreeBSD$
#

PORTNAME=     oneko
PORTVERSION= 1.1b
CATEGORIES= games
MASTER_SITES= ftp://ftp.cs.columbia.edu/archives/X11R5/contrib/

MAINTAINER=    asami@FreeBSD.org
COMMENT=       A cat chasing a mouse all over the screen

MAN1=     oneko.1
MANCOMPRESSED= yes
USE_IMAKE= yes

.include <bsd.port.mk>
   pkg-descr
   pkg-plist

   Refer to the pkg_create(1) manual page for
    details on the packing list.
   This is a longer description of the port. One
    to a few paragraphs concisely explaining
    what the port does is sufficient.
   Example
    This is a port of oneko, in which a cat chases a poor mouse all over
    the screen.
     :
    (etc.)

    WWW: http://www.oneko.org/
   This file lists all the files installed by the port.
   Also called the “packing list” because the package is
    generated by packing the files listed here.
   The pathnames are relative to the installation prefix
    (usually /usr/local or /usr/X11R6).
   If you are using the MANn variables (as you should be), do
    not list any manpages here. If the port creates directories
    during installation, make sure to add @dirrm lines to
    remove them when the package is deleted.
   Example:
    bin/oneko
    lib/X11/app-defaults/Oneko
    lib/X11/oneko/cat1.xpm
    lib/X11/oneko/cat2.xpm
    lib/X11/oneko/mouse.xpm
    @dirrm lib/X11/oneko
   Type make makesum. The ports make rules
    will automatically generate the file distinfo.
   pkg-plist does not contain anything not
    installed by your port
   pkg-plist contains everything that is installed
    by your port
   Your port can be installed multiple times
    using the reinstall target
   Your port cleans up after itself upon deinstall
1.   make install
2.   make package
3.   make deinstall
4.   pkg_add package-name
5.   make deinstall
6.   make reinstall
7.   make package
   http://www.FreeBSD.org/doc/en_US.ISO8859
    -1/articles/contributing/contrib-
    how.html#CONTRIB-GENERAL
   http://www.FreeBSD.org/cgi/query-pr-
    summary.cgi?category=ports
Lecture 6 Kernel Debugging + Ports Development
Lecture 6 Kernel Debugging + Ports Development

More Related Content

What's hot

Linux IO
Linux IOLinux IO
Linux IO
Liran Ben Haim
 
Linux Containers From Scratch: Makfile MicroVPS
Linux Containers From Scratch: Makfile MicroVPSLinux Containers From Scratch: Makfile MicroVPS
Linux Containers From Scratch: Makfile MicroVPS
joshuasoundcloud
 
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawn
Gábor Nyers
 
First steps on CentOs7
First steps on CentOs7First steps on CentOs7
First steps on CentOs7
Marc Cortinas Val
 
How to design a file system
How to design a file systemHow to design a file system
How to design a file system
Nikhil Anurag VN
 
unixtoolbox
unixtoolboxunixtoolbox
unixtoolbox
wensheng wei
 
Programming Embedded linux
Programming Embedded linuxProgramming Embedded linux
Programming Embedded linux
Liran Ben Haim
 
Effective service and resource management with systemd
Effective service and resource management with systemdEffective service and resource management with systemd
Effective service and resource management with systemd
David Timothy Strauss
 
Kernel init
Kernel initKernel init
Kernel init
gowell
 
KCC_Final.pdf
KCC_Final.pdfKCC_Final.pdf
KCC_Final.pdf
Oleg Sehelin
 
Linux containers-namespaces(Dec 2014)
Linux containers-namespaces(Dec 2014)Linux containers-namespaces(Dec 2014)
Linux containers-namespaces(Dec 2014)
Ralf Dannert
 
Containers and Namespaces in the Linux Kernel
Containers and Namespaces in the Linux KernelContainers and Namespaces in the Linux Kernel
Containers and Namespaces in the Linux Kernel
OpenVZ
 
Fun with FUSE
Fun with FUSEFun with FUSE
Fun with FUSE
Kernel TLV
 
Virtualization which isn't: LXC (Linux Containers)
Virtualization which isn't: LXC (Linux Containers)Virtualization which isn't: LXC (Linux Containers)
Virtualization which isn't: LXC (Linux Containers)
Dobrica Pavlinušić
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
shimosawa
 
도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템
도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템
도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템
Sam Kim
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to love
Alison Chaiken
 
Linux cgroups and namespaces
Linux cgroups and namespacesLinux cgroups and namespaces
Linux cgroups and namespaces
Locaweb
 
Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1
Susant Sahani
 
systemd
systemdsystemd
systemd
nussbauml
 

What's hot (20)

Linux IO
Linux IOLinux IO
Linux IO
 
Linux Containers From Scratch: Makfile MicroVPS
Linux Containers From Scratch: Makfile MicroVPSLinux Containers From Scratch: Makfile MicroVPS
Linux Containers From Scratch: Makfile MicroVPS
 
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawn
 
First steps on CentOs7
First steps on CentOs7First steps on CentOs7
First steps on CentOs7
 
How to design a file system
How to design a file systemHow to design a file system
How to design a file system
 
unixtoolbox
unixtoolboxunixtoolbox
unixtoolbox
 
Programming Embedded linux
Programming Embedded linuxProgramming Embedded linux
Programming Embedded linux
 
Effective service and resource management with systemd
Effective service and resource management with systemdEffective service and resource management with systemd
Effective service and resource management with systemd
 
Kernel init
Kernel initKernel init
Kernel init
 
KCC_Final.pdf
KCC_Final.pdfKCC_Final.pdf
KCC_Final.pdf
 
Linux containers-namespaces(Dec 2014)
Linux containers-namespaces(Dec 2014)Linux containers-namespaces(Dec 2014)
Linux containers-namespaces(Dec 2014)
 
Containers and Namespaces in the Linux Kernel
Containers and Namespaces in the Linux KernelContainers and Namespaces in the Linux Kernel
Containers and Namespaces in the Linux Kernel
 
Fun with FUSE
Fun with FUSEFun with FUSE
Fun with FUSE
 
Virtualization which isn't: LXC (Linux Containers)
Virtualization which isn't: LXC (Linux Containers)Virtualization which isn't: LXC (Linux Containers)
Virtualization which isn't: LXC (Linux Containers)
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템
도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템
도커 없이 컨테이너 만들기 5편 마운트 네임스페이스와 오버레이 파일시스템
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to love
 
Linux cgroups and namespaces
Linux cgroups and namespacesLinux cgroups and namespaces
Linux cgroups and namespaces
 
Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1
 
systemd
systemdsystemd
systemd
 

Viewers also liked

Soc. Unit I, Packet 2
Soc. Unit I, Packet 2Soc. Unit I, Packet 2
Soc. Unit I, Packet 2
NHSDAnderson
 
Inbooki
Inbooki Inbooki
Collaborative Assessment
Collaborative AssessmentCollaborative Assessment
Collaborative Assessment
Elizabeth Nesius
 
Dec 06, Sermon Am
Dec 06, Sermon AmDec 06, Sermon Am
Dec 06, Sermon Am
Geo Acts
 
Unit3
Unit3Unit3
Problems of the Week
Problems of the WeekProblems of the Week
Problems of the Week
Glenn Kenyon
 
Responding to student writing
Responding to student writingResponding to student writing
Responding to student writing
Elizabeth Nesius
 
The Means Of Salvation
The Means Of SalvationThe Means Of Salvation
The Means Of Salvation
Geo Acts
 
Startup Innovative Decreto Sviluppo : intervento Prof. Basenghi su Assunzioni
Startup Innovative Decreto Sviluppo : intervento Prof. Basenghi su AssunzioniStartup Innovative Decreto Sviluppo : intervento Prof. Basenghi su Assunzioni
Startup Innovative Decreto Sviluppo : intervento Prof. Basenghi su Assunzioni
Francesco Baruffi
 
Is it Hard Money or Hard to Get Money?
Is it Hard Money or Hard to Get Money? Is it Hard Money or Hard to Get Money?
Is it Hard Money or Hard to Get Money?
Joseph Andahazy
 
E learning Simplified for 8th Graders
E learning Simplified for 8th GradersE learning Simplified for 8th Graders
E learning Simplified for 8th Graders
Clint Walters
 
Comparativesquiz 3
Comparativesquiz 3Comparativesquiz 3
Comparativesquiz 3
lola guillen
 
Memories of Japan
Memories of JapanMemories of Japan
Memories of Japan
Tom Furlong, CPC
 
Catalogo di Innova Day Motor Sport Technologies 2013
Catalogo di Innova Day Motor Sport Technologies 2013Catalogo di Innova Day Motor Sport Technologies 2013
Catalogo di Innova Day Motor Sport Technologies 2013
Francesco Baruffi
 
Draft presentazione innova_day
Draft presentazione innova_dayDraft presentazione innova_day
Draft presentazione innova_dayFrancesco Baruffi
 
Bideo-Jolasak
Bideo-JolasakBideo-Jolasak
Bideo-Jolasakolatzucin
 
Les 1 Inleiding En Functioneren Van Organisaties
Les 1 Inleiding En Functioneren Van OrganisatiesLes 1 Inleiding En Functioneren Van Organisaties
Les 1 Inleiding En Functioneren Van OrganisatiesMediena Business School
 
Co jsme se naučili od spuštění Fakturoidu
Co jsme se naučili od spuštění FakturoiduCo jsme se naučili od spuštění Fakturoidu
Co jsme se naučili od spuštění Fakturoidujan korbel
 
Kenzy klauser vet speech and preso
Kenzy klauser vet speech and presoKenzy klauser vet speech and preso
Kenzy klauser vet speech and preso
David R. Klauser
 

Viewers also liked (20)

Soc. Unit I, Packet 2
Soc. Unit I, Packet 2Soc. Unit I, Packet 2
Soc. Unit I, Packet 2
 
Inbooki
Inbooki Inbooki
Inbooki
 
Collaborative Assessment
Collaborative AssessmentCollaborative Assessment
Collaborative Assessment
 
Dec 06, Sermon Am
Dec 06, Sermon AmDec 06, Sermon Am
Dec 06, Sermon Am
 
Unit3
Unit3Unit3
Unit3
 
Problems of the Week
Problems of the WeekProblems of the Week
Problems of the Week
 
Responding to student writing
Responding to student writingResponding to student writing
Responding to student writing
 
The Means Of Salvation
The Means Of SalvationThe Means Of Salvation
The Means Of Salvation
 
Startup Innovative Decreto Sviluppo : intervento Prof. Basenghi su Assunzioni
Startup Innovative Decreto Sviluppo : intervento Prof. Basenghi su AssunzioniStartup Innovative Decreto Sviluppo : intervento Prof. Basenghi su Assunzioni
Startup Innovative Decreto Sviluppo : intervento Prof. Basenghi su Assunzioni
 
Is it Hard Money or Hard to Get Money?
Is it Hard Money or Hard to Get Money? Is it Hard Money or Hard to Get Money?
Is it Hard Money or Hard to Get Money?
 
E learning Simplified for 8th Graders
E learning Simplified for 8th GradersE learning Simplified for 8th Graders
E learning Simplified for 8th Graders
 
Comparativesquiz 3
Comparativesquiz 3Comparativesquiz 3
Comparativesquiz 3
 
Memories of Japan
Memories of JapanMemories of Japan
Memories of Japan
 
Catalogo di Innova Day Motor Sport Technologies 2013
Catalogo di Innova Day Motor Sport Technologies 2013Catalogo di Innova Day Motor Sport Technologies 2013
Catalogo di Innova Day Motor Sport Technologies 2013
 
Draft presentazione innova_day
Draft presentazione innova_dayDraft presentazione innova_day
Draft presentazione innova_day
 
Bideo-Jolasak
Bideo-JolasakBideo-Jolasak
Bideo-Jolasak
 
Les 2 Informatieverzorging
Les 2 InformatieverzorgingLes 2 Informatieverzorging
Les 2 Informatieverzorging
 
Les 1 Inleiding En Functioneren Van Organisaties
Les 1 Inleiding En Functioneren Van OrganisatiesLes 1 Inleiding En Functioneren Van Organisaties
Les 1 Inleiding En Functioneren Van Organisaties
 
Co jsme se naučili od spuštění Fakturoidu
Co jsme se naučili od spuštění FakturoiduCo jsme se naučili od spuštění Fakturoidu
Co jsme se naučili od spuštění Fakturoidu
 
Kenzy klauser vet speech and preso
Kenzy klauser vet speech and presoKenzy klauser vet speech and preso
Kenzy klauser vet speech and preso
 

Similar to Lecture 6 Kernel Debugging + Ports Development

Linux Kernel Debugging
Linux Kernel DebuggingLinux Kernel Debugging
Linux Kernel Debugging
GlobalLogic Ukraine
 
ELC-E Linux Awareness
ELC-E Linux AwarenessELC-E Linux Awareness
ELC-E Linux Awareness
Peter Griffin
 
Solaris Kernel Debugging V1.0
Solaris Kernel Debugging V1.0Solaris Kernel Debugging V1.0
Solaris Kernel Debugging V1.0
Jarod Wang
 
Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloud
Andrea Righi
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
libfetion
 
LAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel AwarenessLAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel Awareness
Linaro
 
LAS16-403 - GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness LAS16-403 - GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness
Peter Griffin
 
Debug generic process
Debug generic processDebug generic process
Debug generic process
Vipin Varghese
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
Hao-Ran Liu
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource Kernels
Silvio Cesare
 
CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...
CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...
CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...
PROIDEA
 
Genode Compositions
Genode CompositionsGenode Compositions
Genode Compositions
Vasily Sartakov
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
dotCloud
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Docker, Inc.
 
Austin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectreAustin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectre
Kim Phillips
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Opersys inc.
 
Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph
Ceph Community
 
Talk 160920 @ Cat System Workshop
Talk 160920 @ Cat System WorkshopTalk 160920 @ Cat System Workshop
Talk 160920 @ Cat System Workshop
Quey-Liang Kao
 
Porting Android
Porting AndroidPorting Android
Porting Android
Opersys inc.
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)
shimosawa
 

Similar to Lecture 6 Kernel Debugging + Ports Development (20)

Linux Kernel Debugging
Linux Kernel DebuggingLinux Kernel Debugging
Linux Kernel Debugging
 
ELC-E Linux Awareness
ELC-E Linux AwarenessELC-E Linux Awareness
ELC-E Linux Awareness
 
Solaris Kernel Debugging V1.0
Solaris Kernel Debugging V1.0Solaris Kernel Debugging V1.0
Solaris Kernel Debugging V1.0
 
Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloud
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
LAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel AwarenessLAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel Awareness
 
LAS16-403 - GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness LAS16-403 - GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness
 
Debug generic process
Debug generic processDebug generic process
Debug generic process
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource Kernels
 
CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...
CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...
CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...
 
Genode Compositions
Genode CompositionsGenode Compositions
Genode Compositions
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
 
Austin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectreAustin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectre
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
 
Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph
 
Talk 160920 @ Cat System Workshop
Talk 160920 @ Cat System WorkshopTalk 160920 @ Cat System Workshop
Talk 160920 @ Cat System Workshop
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)
 

More from Mohammed Farrag

Resume for Mohamed Farag
Resume for Mohamed FaragResume for Mohamed Farag
Resume for Mohamed Farag
Mohammed Farrag
 
Mum Article Recognition for Mohamed Farag
Mum Article Recognition for Mohamed FaragMum Article Recognition for Mohamed Farag
Mum Article Recognition for Mohamed Farag
Mohammed Farrag
 
Create 2015 Event
Create 2015 EventCreate 2015 Event
Create 2015 Event
Mohammed Farrag
 
Artificial Intelligence Programming in Art by Mohamed Farag
Artificial Intelligence Programming in Art by Mohamed FaragArtificial Intelligence Programming in Art by Mohamed Farag
Artificial Intelligence Programming in Art by Mohamed Farag
Mohammed Farrag
 
The practices, challenges and opportunities of board composition and leadersh...
The practices, challenges and opportunities of board composition and leadersh...The practices, challenges and opportunities of board composition and leadersh...
The practices, challenges and opportunities of board composition and leadersh...
Mohammed Farrag
 
Confirmation letter info tech 2013(1)
Confirmation letter info tech 2013(1)Confirmation letter info tech 2013(1)
Confirmation letter info tech 2013(1)
Mohammed Farrag
 
Google APPs and APIs
Google APPs and APIsGoogle APPs and APIs
Google APPs and APIs
Mohammed Farrag
 
FreeBSD Handbook
FreeBSD HandbookFreeBSD Handbook
FreeBSD Handbook
Mohammed Farrag
 
Master resume
Master resumeMaster resume
Master resume
Mohammed Farrag
 
Mohammed Farrag Resume
Mohammed Farrag ResumeMohammed Farrag Resume
Mohammed Farrag Resume
Mohammed Farrag
 

More from Mohammed Farrag (10)

Resume for Mohamed Farag
Resume for Mohamed FaragResume for Mohamed Farag
Resume for Mohamed Farag
 
Mum Article Recognition for Mohamed Farag
Mum Article Recognition for Mohamed FaragMum Article Recognition for Mohamed Farag
Mum Article Recognition for Mohamed Farag
 
Create 2015 Event
Create 2015 EventCreate 2015 Event
Create 2015 Event
 
Artificial Intelligence Programming in Art by Mohamed Farag
Artificial Intelligence Programming in Art by Mohamed FaragArtificial Intelligence Programming in Art by Mohamed Farag
Artificial Intelligence Programming in Art by Mohamed Farag
 
The practices, challenges and opportunities of board composition and leadersh...
The practices, challenges and opportunities of board composition and leadersh...The practices, challenges and opportunities of board composition and leadersh...
The practices, challenges and opportunities of board composition and leadersh...
 
Confirmation letter info tech 2013(1)
Confirmation letter info tech 2013(1)Confirmation letter info tech 2013(1)
Confirmation letter info tech 2013(1)
 
Google APPs and APIs
Google APPs and APIsGoogle APPs and APIs
Google APPs and APIs
 
FreeBSD Handbook
FreeBSD HandbookFreeBSD Handbook
FreeBSD Handbook
 
Master resume
Master resumeMaster resume
Master resume
 
Mohammed Farrag Resume
Mohammed Farrag ResumeMohammed Farrag Resume
Mohammed Farrag Resume
 

Recently uploaded

A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDFLifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Vivekanand Anglo Vedic Academy
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
BoudhayanBhattachari
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
ssuser13ffe4
 

Recently uploaded (20)

A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDFLifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
Lifelines of National Economy chapter for Class 10 STUDY MATERIAL PDF
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
 

Lecture 6 Kernel Debugging + Ports Development

  • 1.
  • 2. FreeBSD Kernel Debugging  Port Development
  • 3. gdb Kdgb DTrace Valgrind ktrace ktr Kernel Userland Space
  • 4. Kernel Debugging Tracking
  • 5. The process that takes a control of execution of another process and make step over of code to view the process execution, show relation between consecutive processes.  Debugging mainly used to detect error or bugs.
  • 7. dumpon(8) and savecore(8) – /etc/rc.conf ● [syrinx@tweety]/(76)% cat /etc/rc.conf | grep dump ● dumpdev="/dev/ad4s4b" ● dumpdir="/var/crash/" ● Remote systems ● options DDB_UNATTENDED ● Virtual machines - Pros and cons – Qemu – VirtualBox
  • 8. Kernel configuration makeoptions DEBUG=-g #memguard(9) and redzone(9) options DEBUG_MEMGUARD #ktrace(1) options DEBUG_REDZONE options KTRACE #ktr(4) options KDB options KTR options KDB_TRACE options ALQ options DDB options ALQ_KTR options GBD options KTR_ENTRIES=4096 options KTR_COMPILE=KTR_INET options INVARIANTS options KTR_MASK=KTR_INET options INVARIANT_SUPPORT options KTR_CPUMASK=0x3 options WITNESS options WITNESS_SKIPSPIN options LOCK_PROFILING
  • 9. If kernel dies, display driver dies too ● Do not panic the system while fsck (8) is running ● [syrinx@tweety]/(78)% cat /etc/rc.conf | grep fsck ● fsck_y_enable="YES" ● background_fsck="NO" ● Core dumps may contain sensitive information ● # boot -s ● # dumpon /dev/ad4s4b ● # mount -a -art ufs ● # /command-to-crash-the-kernel
  • 10. ddb(8) kgmon(8) kgdb(1) pmcstat(1) ktr(4) hwpmc(4) ktr(9) addr2line(1) ktrdump(8) kldstat(8) ktrace(1) fstat(1) kdump(1) iostat(8) dmesg(8) ipcs(1) objdump(1) ipmi(9) size(1) netstat(1) savecore(8) ps(1) dumpon(8) vmstat(8) textdump(8) redzone(9) hexdump(1) memguard(9) truss(1)
  • 11. Kernel crashes usually require straighforward approach ● kgdb(1) is an extention of gdb(1) that understands FreeBSD kernel corefiles ● Symbol resolving ● Scripting support ● On-line debugging via /dev/mem ● Remote debugging – via serial line – via firewire
  • 12. [syrinx@tweety]/home/syrinx(92)% sudo kgdb /boot/kernel.old/kernel /var/crash/vmcore.1 GNU gdb 6.1.1 [FreeBSD] Copyright 2004 Free Software Foundation, Inc. Unread portion of the kernel message buffer: rum0: could not multi read MAC register: USB_ERR_NOT_CONFIGURED Fatal trap 12: page fault while in kernel mode cpuid = 1; apic id = 01 fault virtual address = 0x0 fault code = supervisor read, page not present instruction pointer = 0x20:0xc069bf24 stack pointer = 0x28:0xe6b40c44 frame pointer = 0x28:0xe6b40c60 code segment = base 0x0, limit 0xfffff, type 0x1b = DPL 0, pres 1, def32 1, gran 1 processor eflags = interrupt enabled, resume, IOPL = 0 current process = 0 (rum0 taskq) panic: from debugger
  • 13. NULL Pointer Dereference ● Resource leak ● Bad test condition, resulting in code path never executed ● Use before test (NULL/-1) ● Use after free ● Buffer overflow ● Unsafe use of returned value ● Uninitialized value read ● Type and allocation size mismatch
  • 14. ddb(4) – interactive kernel ● Inspecting locks with ddb debugger ● db> show lock [lockaddr] ● Poor symbol resolving ● db> show turnstile [lockaddr] compared to kgdb(1) ● # mutexes ● Extensible – new commands ● db> show lockchain added at compile time - ● # six locks, sleepqueues ● Sources at src/sys/ddb ● db> show sleepchain ● Scripting support since FreeBSD 7.1 – ddb(8) ● More info in manual page. ● Enter DDB ● #sysctl debug.kdb.enter=1
  • 15. Examination of CPU registers, variables, etc.  Stepping over the instructions code to view the process execution.
  • 16.
  • 17. ps shows selected fields from the process structures. With an understanding of the structures, it can give a good idea of what's going on.  top is like a repetitive ps: it shows the most active processes at regular intervals.  vmstat shows a number of parameters, including virtual memory. It can also be set up to run at regular intervals.
  • 18. iostat is similar to vmstat, and it duplicates some fields, but it concentrates more on I/O activity.  netstat show network information. It can also be set up to show transfer rates for specific interfaces.  systat is a curses-based program which displays a large number of parameters, including most of the parameters displayed by vmstat, iostat and netstat.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26. [syrinx@tweety]/home/syrinx(71)% sysctl debug.ktr debug.ktr.alq_enable: 0 debug.ktr.alq_file: /tmp/ktr.out debug.ktr.alq_depth: 1024 debug.ktr.alq_failed: 0 debug.ktr.alq_cnt: 0 debug.ktr.alq_max: 0 debug.ktr.clear: 0 debug.ktr.version: 2 debug.ktr.entries: 1024 debug.ktr.compile: 270540806 debug.ktr.mask: 270540806 debug.ktr.cpumask: 3 ● KTR buffer accessible in DDB db> show ktr [v] ● read the contents of a ktr(4) file [syrinx@tweety]/(105)% sudo ktrdump -t -o /tmp/ktr.out
  • 27. Kernel process tracing ● [syrinx@tweety]/home/syrinx(89)% ktrace -a -tcy -f /home/syrinx/krtace.out ifconfig ● kdump(1) displays the kernel trace data ● [syrinx@tweety]/home/syrinx(91)% kdump -f ~/krtace.out ... 7490 ifconfig CALL write(0x1,0x28203000,0x38) 7490 ifconfig GIO fd 1 wrote 56 bytes options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL> 7490 ifconfig RET write 56/0x38 7490 ifconfig CALL ioctl(0x3,SIOCGIFMAC,0xbfbfdfac) 7490 ifconfig RET ioctl -1 errno 22 Invalid argument 7490 ifconfig CALL ioctl(0x3,SIOCGIFMEDIA,0xbfbfdfa0) ...
  • 28. ktrace -d -i -p 0  kdump –f ktrace.out >>myfile.txt
  • 29.
  • 30.
  • 31.
  • 32. 1. Writing the Makefile. 2. Writing the description files. 3. Creating the checksum file 4. Testing the port 5. Checking your port with portlint 6. Submitting the port.
  • 33. # New ports collection makefile for: oneko # Date created: 5 December 1994 # Whom: asami # # $FreeBSD$ # PORTNAME= oneko PORTVERSION= 1.1b CATEGORIES= games MASTER_SITES= ftp://ftp.cs.columbia.edu/archives/X11R5/contrib/ MAINTAINER= asami@FreeBSD.org COMMENT= A cat chasing a mouse all over the screen MAN1= oneko.1 MANCOMPRESSED= yes USE_IMAKE= yes .include <bsd.port.mk>
  • 34. pkg-descr  pkg-plist  Refer to the pkg_create(1) manual page for details on the packing list.
  • 35. This is a longer description of the port. One to a few paragraphs concisely explaining what the port does is sufficient.  Example This is a port of oneko, in which a cat chases a poor mouse all over the screen. : (etc.) WWW: http://www.oneko.org/
  • 36. This file lists all the files installed by the port.  Also called the “packing list” because the package is generated by packing the files listed here.  The pathnames are relative to the installation prefix (usually /usr/local or /usr/X11R6).  If you are using the MANn variables (as you should be), do not list any manpages here. If the port creates directories during installation, make sure to add @dirrm lines to remove them when the package is deleted.  Example: bin/oneko lib/X11/app-defaults/Oneko lib/X11/oneko/cat1.xpm lib/X11/oneko/cat2.xpm lib/X11/oneko/mouse.xpm @dirrm lib/X11/oneko
  • 37. Type make makesum. The ports make rules will automatically generate the file distinfo.
  • 38. pkg-plist does not contain anything not installed by your port  pkg-plist contains everything that is installed by your port  Your port can be installed multiple times using the reinstall target  Your port cleans up after itself upon deinstall
  • 39. 1. make install 2. make package 3. make deinstall 4. pkg_add package-name 5. make deinstall 6. make reinstall 7. make package
  • 40. http://www.FreeBSD.org/doc/en_US.ISO8859 -1/articles/contributing/contrib- how.html#CONTRIB-GENERAL  http://www.FreeBSD.org/cgi/query-pr- summary.cgi?category=ports