Date: Thu, 3 Mar 2016 12:48:49 -0500 From: Philip Semanchuk <philip@semanchuk.com> To: freebsd-questions@freebsd.org Subject: Re: Adding printf() to observe semaphore behavior? Message-ID: <98D5BCB4-FE03-40CE-9CEF-CD9FBD65F964@semanchuk.com> In-Reply-To: <61DF564A-5DB5-4C9C-B12B-24CE529706D8@semanchuk.com> References: <61DF564A-5DB5-4C9C-B12B-24CE529706D8@semanchuk.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> On Feb 22, 2016, at 9:01 PM, Philip Semanchuk <philip@semanchuk.com> = wrote: >=20 > Hi all, > I=E2=80=99m trying to debug a potential kernel problem with POSIX = semaphores. I=E2=80=99m trying to build a custom kernel with some added = printf() statements and I=E2=80=99m not seeing any output, neither to = /var/log/messages nor to the console. I would appreciate any help at = getting the kernel to talk to me.=20 >=20 > Here=E2=80=99s what I=E2=80=99ve already done on my PC BSD 10.2 = running inside a VM =E2=80=94 =20 > - Downloaded the source to /usr/src > - Added a printf(=E2=80=9CHello world\n=E2=80=9D) in each = implementation of sem_open() (both in lib/libc/gen/sem.c and sem_new.c) = and one inside the implementation of ksem_open() (in = sys/kern/uipc_sem.c) for good measure. I did not #include <stdio.h> = which I=E2=80=99ve read is the correct thing to do when one wants to use = the kernel=E2=80=99s printf().=20 > - cd /usr/src > - sudo make buildkernel=20 > - sudo make installkernel > - reboot > - Create a POSIX semaphore. It works, but I don=E2=80=99t see my = =E2=80=9CHello world=E2=80=9D message. >=20 > Any suggestions on what I=E2=80=99m doing wrong would be appreciated. Here=E2=80=99s the answer my own question for anyone else who might have = the same problem.=20 POSIX semaphores are implemented in libc.ko. If you want to experiment = with them (say, by adding printf() as I was doing), modify the = appropriate files (e.g. sem_new.c) and then =E2=80=94 cd /usr/src/lib/libc make DEBUG_FLAGS=3D-g obj all install clean You might be able to load the new libc.ko with kldunload/kldload, = otherwise you=E2=80=99ll have to reboot.=20 More info here: = https://lists.freebsd.org/pipermail/freebsd-hackers/2012-December/041338.h= tml Happy hacking, Philip=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?98D5BCB4-FE03-40CE-9CEF-CD9FBD65F964>