SlideShare ist ein Scribd-Unternehmen logo
1 von 42
   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

Weitere ähnliche Inhalte

Was ist angesagt?

Linux Containers From Scratch: Makfile MicroVPS
Linux Containers From Scratch: Makfile MicroVPSLinux Containers From Scratch: Makfile MicroVPS
Linux Containers From Scratch: Makfile MicroVPSjoshuasoundcloud
 
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawnGábor Nyers
 
How to design a file system
How to design a file systemHow to design a file system
How to design a file systemNikhil Anurag VN
 
Programming Embedded linux
Programming Embedded linuxProgramming Embedded linux
Programming Embedded linuxLiran 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 systemdDavid Timothy Strauss
 
Kernel init
Kernel initKernel init
Kernel initgowell
 
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 KernelOpenVZ
 
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 loveAlison Chaiken
 
Linux cgroups and namespaces
Linux cgroups and namespacesLinux cgroups and namespaces
Linux cgroups and namespacesLocaweb
 
Summit demystifying systemd1
Summit demystifying systemd1Summit demystifying systemd1
Summit demystifying systemd1Susant Sahani
 

Was ist angesagt? (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
 

Andere mochten auch

Soc. Unit I, Packet 2
Soc. Unit I, Packet 2Soc. Unit I, Packet 2
Soc. Unit I, Packet 2NHSDAnderson
 
Dec 06, Sermon Am
Dec 06, Sermon AmDec 06, Sermon Am
Dec 06, Sermon AmGeo Acts
 
Problems of the Week
Problems of the WeekProblems of the Week
Problems of the WeekGlenn Kenyon
 
Responding to student writing
Responding to student writingResponding to student writing
Responding to student writingElizabeth Nesius
 
The Means Of Salvation
The Means Of SalvationThe Means Of Salvation
The Means Of SalvationGeo 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 AssunzioniFrancesco 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 GradersClint Walters
 
Comparativesquiz 3
Comparativesquiz 3Comparativesquiz 3
Comparativesquiz 3lola guillen
 
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 2013Francesco 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 presoDavid R. Klauser
 

Andere mochten auch (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
 

Ähnlich wie Lecture 6 Kernel Debugging + Ports Development

ELC-E Linux Awareness
ELC-E Linux AwarenessELC-E Linux Awareness
ELC-E Linux AwarenessPeter Griffin
 
Solaris Kernel Debugging V1.0
Solaris Kernel Debugging V1.0Solaris Kernel Debugging V1.0
Solaris Kernel Debugging V1.0Jarod 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 cloudAndrea Righi
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugginglibfetion
 
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
 
LAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel AwarenessLAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel AwarenessLinaro
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debuggingHao-Ran Liu
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource KernelsSilvio 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
 
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 2013dotCloud
 
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 2013Docker, Inc.
 
Austin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectreAustin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectreKim 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 WorkshopQuey-Liang Kao
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)shimosawa
 

Ähnlich wie 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 Awareness LAS16-403 - GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness
 
LAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel AwarenessLAS16-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)
 

Mehr von Mohammed Farrag

Resume for Mohamed Farag
Resume for Mohamed FaragResume for Mohamed Farag
Resume for Mohamed FaragMohammed Farrag
 
Mum Article Recognition for Mohamed Farag
Mum Article Recognition for Mohamed FaragMum Article Recognition for Mohamed Farag
Mum Article Recognition for Mohamed FaragMohammed 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 FaragMohammed 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
 

Mehr von 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
 

Kürzlich hochgeladen

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 

Kürzlich hochgeladen (20)

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 

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