Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Sep 2010 11:28:00 +0200
From:      Norberto Lopes <nlopes.ml@gmail.com>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        freebsd-current@freebsd.org, netchild@freebsd.org
Subject:   Re: Extend ktrace/kdump output
Message-ID:  <AANLkTimCwNA2BGbm9N-iFo%2BomR06h%2BXJDxOFSrT0AnJ7@mail.gmail.com>
In-Reply-To: <AANLkTikWEzjeA8miRXkkSBuK65sBi%2BtDvx7F=mirTZ7g@mail.gmail.com>
References:  <8C5C36F5-A070-4CBA-8B8C-6751F8D636E1@gmail.com> <20100917203645.GS2389@deviant.kiev.zoral.com.ua> <AANLkTikWEzjeA8miRXkkSBuK65sBi%2BtDvx7F=mirTZ7g@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--00c09f82cc309c9fee0490854b59
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Anyway, attached is the patch.
All (constructive) criticism is welcome, even if it has to deal with
"how I should do things freebsd way (in case there is one)".

On Fri, Sep 17, 2010 at 10:48 PM, Norberto Lopes <nlopes.ml@gmail.com> wrot=
e:
> On Fri, Sep 17, 2010 at 10:36 PM, Kostik Belousov <kostikbel@gmail.com> w=
rote:
>> On Fri, Sep 17, 2010 at 09:55:26PM +0200, Norberto Lopes wrote:
>>> Hi.
>>> I've been taking a look at ktrace and kdump in order to get (1) familia=
r with the sources and (2) to finally try to give back something to the com=
munity.
>>>
>>> So far from what I've seen, and after reading this thread http://lists.=
freebsd.org/pipermail/freebsd-arch/2006-April/005107.html it seems that mos=
t of those points got done.
>>>
>>> To warm up I changed the output of the stat structure in order to provi=
de me with the device name (something I actually find useful for me sometim=
es)
>>>
>>> Instead of:
>>> =C2=A022596 cat =C2=A0 =C2=A0 =C2=A0STRU =C2=A0struct stat {dev=3D89, i=
no=3D3320836, mode=3D-r--r--r-- , nlink=3D1, uid=3D0, gid=3D0, atime=3D1284=
725358, stime=3D1284485510, ctime=3D1284485510, birthtime=3D1284485509, siz=
e=3D1172220, blksize=3D16384, blocks=3D2336, flags=3D0x20000 }
>>>
>>> I get this now (including major and minor):
>>> =C2=A022596 cat =C2=A0 =C2=A0 =C2=A0STRU =C2=A0struct stat {dev=3D<id=
=3D89:M=3D0:m=3D89> (/dev/ad4s1a), ino=3D3320836, mode=3D-r--r--r-- , nlink=
=3D1, uid=3D0, gid=3D0, atime=3D1284725358, stime=3D1284485510, ctime=3D128=
4485510, birthtime=3D1284485509, size=3D1172220, blksize=3D16384, blocks=3D=
2336, flags=3D0x20000 }
>>>
>>> I wouldn't mind having someone help me whenever and if I get stuck on t=
he technical side (*wink* Alexander Leidinger *wink*) and also to give me m=
ore insight on what the road to help in this should be.
>>>
>>> P.S.: I'm still going through "man style" hence no patch attached. If a=
nyone finds this one useful, I'll reply with the patch though.
>>>
>> How do you look up the device name by st_dev ? Note that the number is
>> generated by devfs at the moment of cdev creation. It is only valid on
>> the machine where stat(2) is done, and only due to the next reboot.
>>
>
> Through a really ugly hack...
> opendir("/dev")
> readdir("/dev")
> go through them and find the one...
>
> Yes, I know, painful and ugly, but as I usually use kdump with no
> reboots between analysis (I hardly ever reboot actually), and because
> I find it exhausting to keep going back to look up the device name,
> this kept me happy enough. :)
>

--00c09f82cc309c9fee0490854b59
Content-Type: application/octet-stream; name="kstat_devname.diff"
Content-Disposition: attachment; filename="kstat_devname.diff"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_ge89zcwl0

SW5kZXg6IGtkdW1wLmMKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0ga2R1bXAuYwkocmV2aXNpb24gMjEyODIwKQor
Kysga2R1bXAuYwkod29ya2luZyBjb3B5KQpAQCAtODIsNiArODIsOCBAQCBleHRlcm4gaW50IGVy
cm5vOwogI2luY2x1ZGUgPHRpbWUuaD4KICNpbmNsdWRlIDx1bmlzdGQuaD4KICNpbmNsdWR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Aqc3RhdHApCiAJZWxzZQogCQlwcmludGYoIiwgIik7CiAJcHJpbnRmKCJz
aXplPSVqZCwgYmxrc2l6ZT0lanUsIGJsb2Nrcz0lamQsIGZsYWdzPTB4JXgiLAotCQkodWludG1h
eF90KXN0YXRwLT5zdF9zaXplLCAodWludG1heF90KXN0YXRwLT5zdF9ibGtzaXplLAotCQkoaW50
bWF4X3Qpc3RhdHAtPnN0X2Jsb2Nrcywgc3RhdHAtPnN0X2ZsYWdzKTsKKwkgICAgICAgICh1aW50
bWF4X3Qpc3RhdHAtPnN0X3NpemUsICh1aW50bWF4X3Qpc3RhdHAtPnN0X2Jsa3NpemUsCisJICAg
ICAgICAoaW50bWF4X3Qpc3RhdHAtPnN0X2Jsb2Nrcywgc3RhdHAtPnN0X2ZsYWdzKTsKIAlwcmlu
dGYoIiB9XG4iKTsKIH0KIAo=
--00c09f82cc309c9fee0490854b59--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimCwNA2BGbm9N-iFo%2BomR06h%2BXJDxOFSrT0AnJ7>