Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Sep 2022 10:43:47 +0200
From:      Kristof Provost <kp@FreeBSD.org>
To:        Lee MATTHEWS <Lee.MATTHEWS.external@stormshield.eu>
Cc:        freebsd-drivers@freebsd.org
Subject:   Re: Tracing userland calls through to a driver
Message-ID:  <7C93934E-7DF5-44FC-93B5-331AE3490189@FreeBSD.org>
In-Reply-To: <484f6c4f5a2840daafaeda4943f22793@stormshield.eu>
References:  <484f6c4f5a2840daafaeda4943f22793@stormshield.eu>

next in thread | previous in thread | raw e-mail | index | archive | help

--=_MailMate_347D4661-E9A5-4E2F-997D-72ABF7C2E717_=
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

On 15 Sep 2022, at 10:37, Lee MATTHEWS wrote:
> I am trying to debug some GPIO issues on FreeBSD 10.3.
>
That’s an unsupported version (unless you meant 12.3), so the first 
thing to do is to see if your issue is still present in main.

> I'd like to know if it is possible to know what process in userland 
> (via a process id) has called a method in the driver.
>
> So for example, in the driver, the functions are bound via DEVMETHOD 
> like :
>
>
> static device_method_t winbond_gpio_methods[] = {
>     /* Device interface */
> ...
>     DEVMETHOD(gpio_pin_set,            winbond_gpio_pin_set),
>     DEVMETHOD(gpio_pin_get,            winbond_gpio_pin_get),
> ...
>     DEVMETHOD_END
> };
>
>
> When the function winbond_gpio_pin_get() is called, how can I know 
> what called this?
>
>
For things like this I’d either look at truss(1), which will tell you 
what system calls the user space process called, or Dtrace.

Something like `dtrace -n fbt::winbond_gpio_pin_set:entry { stack(); }` 
should give you a pointer already.
Dtrace can take a bit of effort to learn, but it’s generally well 
worth it. The wiki has some initial hints: 
https://wiki.freebsd.org/DTrace

Best regards,
Kristof
--=_MailMate_347D4661-E9A5-4E2F-997D-72ABF7C2E717_=
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html>
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/xhtml; charset=3Dutf-8"=
>
</head>
<body><div style=3D"font-family: sans-serif;"><div class=3D"markdown" sty=
le=3D"white-space: normal;">
<p dir=3D"auto">On 15 Sep 2022, at 10:37, Lee MATTHEWS wrote:</p>
</div><div class=3D"plaintext" style=3D"white-space: normal;"><blockquote=
 style=3D"margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #136=
BCE; color: #136BCE;"><p dir=3D"auto">I am trying to debug some GPIO issu=
es on FreeBSD 10.3.</p>
<br></blockquote></div>
<div class=3D"markdown" style=3D"white-space: normal;">
<p dir=3D"auto">That=E2=80=99s an unsupported version (unless you meant 1=
2.3), so the first thing to do is to see if your issue is still present i=
n main.</p>
</div><div class=3D"plaintext" style=3D"white-space: normal;"><blockquote=
 style=3D"margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #136=
BCE; color: #136BCE;"><p dir=3D"auto">I'd like to know if it is possible =
to know what process in userland (via a process id) has called a method i=
n the driver.</p>
<p dir=3D"auto">So for example, in the driver, the functions are bound vi=
a DEVMETHOD like :</p>
<p dir=3D"auto">static device_method_t winbond_gpio_methods[] =3D {
<br>
    /* Device interface */
<br>
=2E..
<br>
    DEVMETHOD(gpio_pin_set,            winbond_gpio_pin_set),
<br>
    DEVMETHOD(gpio_pin_get,            winbond_gpio_pin_get),
<br>
=2E..
<br>
    DEVMETHOD_END
<br>
};</p>
<p dir=3D"auto">When the function winbond_gpio_pin_get() is called, how c=
an I know what called this?</p>
<br></blockquote></div>
<div class=3D"markdown" style=3D"white-space: normal;">
<p dir=3D"auto">For things like this I=E2=80=99d either look at truss(1),=
 which will tell you what system calls the user space process called, or =
Dtrace.</p>
<p dir=3D"auto">Something like <code>dtrace -n fbt::winbond_gpio_pin_set:=
entry { stack(); }</code> should give you a pointer already.<br>
Dtrace can take a bit of effort to learn, but it=E2=80=99s generally well=
 worth it. The wiki has some initial hints: <a href=3D"https://wiki.freeb=
sd.org/DTrace">https://wiki.freebsd.org/DTrace</a></p>;
<p dir=3D"auto">Best regards,<br>
Kristof</p>

</div></div></body>

</html>

--=_MailMate_347D4661-E9A5-4E2F-997D-72ABF7C2E717_=--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7C93934E-7DF5-44FC-93B5-331AE3490189>