From owner-freebsd-hackers@freebsd.org Sun Jul 26 05:06:45 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 365149ABFF1 for ; Sun, 26 Jul 2015 05:06:45 +0000 (UTC) (envelope-from hetakcoder@gmail.com) Received: from mail-wi0-x232.google.com (mail-wi0-x232.google.com [IPv6:2a00:1450:400c:c05::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BB9E3C41 for ; Sun, 26 Jul 2015 05:06:44 +0000 (UTC) (envelope-from hetakcoder@gmail.com) Received: by wibxm9 with SMTP id xm9so76920665wib.1 for ; Sat, 25 Jul 2015 22:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=IQI8lmYMHFvNlQXv/ByPxtWkXXyiNwOPS9ZTE4ZxECg=; b=KTZsv67fwNGmMY7r9VgQHsjXXaHBCDdY/LejKfviqE7XflzWix/sWTGQajR6EI4M3W jEDlfFKg6NK2vrM6mHV2+yxUP68QrYmOhoHK/ao4mMMKpSyCyJPX3MgCeyecJ7JlWdEV j+7GA1KGe2hVsKHVy6d8VYsIITntO1OuxdeK2UcZcNjLSxSe+dg/cweICYLenju0Px9p KthrQomqhmO7qzkCb6uMVX79oPkBAyfJwuuZptNIlrPC4XidiTFl4WPKooMtjhhkPcOw JxDl3uVhqiql7ZRnm97SU3drFhRaRPYfQSR6CjlgB3peCWerfvPOUixBw3eMuHiuKTYU K9pQ== X-Received: by 10.194.61.175 with SMTP id q15mr1161431wjr.135.1437887202126; Sat, 25 Jul 2015 22:06:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.68.233 with HTTP; Sat, 25 Jul 2015 22:06:02 -0700 (PDT) In-Reply-To: References: <514DDE7F-CF61-461D-A9FF-232DC938BDF5@FreeBSD.org> From: HeTak Date: Sun, 26 Jul 2015 09:36:02 +0430 Message-ID: Subject: Re: Kernel Debug Howto To: Benjamin Kaduk Cc: freebsd-hackers , Mehmet Erol Sanliturk Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Jul 2015 05:06:45 -0000 Thank you, Mehmet and Benjamin, for the tips :) On Sun, Jul 26, 2015 at 12:27 AM, Benjamin Kaduk wrote: > On Sat, 25 Jul 2015, Kristof Provost wrote: > > > > > > On 25 Jul 2015, at 10:54, HeTak wrote: > > > I have recently started some developments on FreeBSD net section. > > Great! > > > > > But I am kinda new to this field. My base interest is to first > understand the > > > implementation structure via tracing the code and so. > > > > > > I have three major questions: > > > 1- how to debug changes made to FreeBSD kernel? > > > (You know, till some levels, I can even use uprintf or so, but, for > example > > > inside radix.c (where I wanna understand how a route is checked to be > > > unique and then inserted to the tree) I can't do such checks..) > > dtrace can be quite useful to understand flows. You can grab stack trac= es > > (i.e. figure out where things are called from), get function arguments,= =E2=80=A6 > > Remote kgdb over a serial line can also be useful for stepping through > execution in cases where that is appropriate, and of course kgdb on > coredumps when the kernel panics. > =E2=80=8BI'm working on VMs to use of snapshots and other facilities while = applying my changes. so i guess this serial line solution is not useful for me, btw, is this debugging tool really useful? don't you face possible kernel crashes after applying some changes on kernel which disconnects you from the system? =E2=80=8B > > > > 3- what is the fastest way to apply changes to FreeBSD kernel? > > > (For now, I just follow the normal build & install kernel & reboot.) > > I pretty much do that. Depending on what you=E2=80=99re working on it m= ight be > easier to run it in a VM. > > My work lately has been on the network code, so a VM is very convenient= . > > It=E2=80=99s not so useful if you=E2=80=99re working on drivers, of cou= rse. > > To speed up the build stage, you can 'make -DKERNFAST kernel' if you have > only made "normal" code changes. > =E2=80=8BI have seen this option before but I don't know what it means by "= normal" code changes. would you please explain it to me? Thank you :) --HeTak