svn commit: r185384 -
user/netchild/linuxulator-dtrace/src/sys/compat/linux
Alexander Leidinger
netchild at FreeBSD.org
Fri Nov 28 06:49:26 PST 2008
Author: netchild
Date: Fri Nov 28 14:49:26 2008
New Revision: 185384
URL: http://svn.freebsd.org/changeset/base/185384
Log:
Add dtrace probes to all functions in linux_util.c. This is only compiletested.
Add some error probes from linux_util to the error checking dtrace script.
Modified:
user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_error.d
user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_util.c
Modified: user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_error.d
==============================================================================
--- user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_error.d Fri Nov 28 14:47:39 2008 (r185383)
+++ user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_error.d Fri Nov 28 14:49:26 2008 (r185384)
@@ -41,3 +41,18 @@ linuxulator*:emul:linux_schedtail:copyou
/* ustack(); */ /* needs to be enabled when PID tracing is available in FreeBSD dtrace */
}
+linuxulator*:util:linux_driver_get_name_dev:nullcall,
+linuxulator*:util:linux_driver_get_major_minor:nullcall
+{
+ printf("WARNING: %s:%s:%s:%s in application %s, maybe an application error?\n", probename, probeprov, probemod, probefunc, execname);
+ stack();
+ /* ustack(); */ /* needs to be enabled when PID tracing is available in FreeBSD dtrace */
+}
+
+linuxulator*:util:linux_driver_get_major_minor:notfound
+{
+ printf("WARNING: Application %s failed to find %s in %s:%s:%s, this may or may not be a problem.\n", execname, arg0, probename, probeprov, probemod);
+ stack();
+ /* ustack(); */ /* needs to be enabled when PID tracing is available in FreeBSD dtrace */
+}
+
Modified: user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_util.c
==============================================================================
--- user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_util.c Fri Nov 28 14:47:39 2008 (r185383)
+++ user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_util.c Fri Nov 28 14:49:26 2008 (r185384)
@@ -33,16 +33,19 @@
__FBSDID("$FreeBSD$");
#include "opt_compat.h"
+#include "opt_kdtrace.h"
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/fcntl.h>
#include <sys/lock.h>
#include <sys/malloc.h>
+#include <sys/kernel.h>
#include <sys/linker_set.h>
#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/proc.h>
+#include <sys/sdt.h>
#include <sys/syscallsubr.h>
#include <sys/systm.h>
#include <sys/vnode.h>
@@ -56,8 +59,58 @@ __FBSDID("$FreeBSD$");
#include <machine/../linux/linux.h>
#endif
+#include <compat/linux/linux_dtrace.h>
+
const char linux_emul_path[] = "/compat/linux";
+LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE);
+LIN_SDT_PROBE_DEFINE(util, linux_emul_convpath, entry);
+LIN_SDT_PROBE_ARGTYPE(util, linux_emul_convpath, entry, 0, "const char *");
+LIN_SDT_PROBE_ARGTYPE(util, linux_emul_convpath, entry, 1, "enum uio_seg");
+LIN_SDT_PROBE_ARGTYPE(util, linux_emul_convpath, entry, 2, "char **");
+LIN_SDT_PROBE_ARGTYPE(util, linux_emul_convpath, entry, 3, "int");
+LIN_SDT_PROBE_ARGTYPE(util, linux_emul_convpath, entry, 4, "int");
+LIN_SDT_PROBE_DEFINE(util, linux_emul_convpath, return);
+LIN_SDT_PROBE_ARGTYPE(util, linux_emul_convpath, return, 0, "int");
+LIN_SDT_PROBE_DEFINE(util, linux_msg, entry);
+LIN_SDT_PROBE_ARGTYPE(util, linux_msg, entry, 0, "const char *");
+LIN_SDT_PROBE_DEFINE(util, linux_msg, return);
+LIN_SDT_PROBE_DEFINE(util, linux_driver_get_name_dev, entry);
+LIN_SDT_PROBE_ARGTYPE(util, linux_driver_get_name_dev, entry, 0, "device_t");
+LIN_SDT_PROBE_ARGTYPE(util, linux_driver_get_name_dev, entry, 1,
+ "const char *");
+LIN_SDT_PROBE_DEFINE(util, linux_driver_get_name_dev, nullcall);
+LIN_SDT_PROBE_DEFINE(util, linux_driver_get_name_dev, return);
+LIN_SDT_PROBE_ARGTYPE(util, linux_driver_get_name_dev, return, 0, "char *");
+LIN_SDT_PROBE_DEFINE(util, linux_driver_get_major_minor, entry);
+LIN_SDT_PROBE_ARGTYPE(util, linux_driver_get_major_minor, entry, 0, "char *");
+LIN_SDT_PROBE_ARGTYPE(util, linux_driver_get_major_minor, entry, 1, "int *");
+LIN_SDT_PROBE_ARGTYPE(util, linux_driver_get_major_minor, entry, 2, "int *");
+LIN_SDT_PROBE_DEFINE(util, linux_driver_get_major_minor, nullcall);
+LIN_SDT_PROBE_DEFINE(util, linux_driver_get_major_minor, notfound);
+LIN_SDT_PROBE_ARGTYPE(util, linux_driver_get_major_minor, notfound, 0,
+ "char *");
+LIN_SDT_PROBE_DEFINE(util, linux_driver_get_major_minor, return);
+LIN_SDT_PROBE_ARGTYPE(util, linux_driver_get_major_minor, return, 0, "int");
+LIN_SDT_PROBE_ARGTYPE(util, linux_driver_get_major_minor, return, 1, "int");
+LIN_SDT_PROBE_ARGTYPE(util, linux_driver_get_major_minor, return, 2, "int");
+LIN_SDT_PROBE_DEFINE(util, linux_get_char_devices, entry);
+LIN_SDT_PROBE_DEFINE(util, linux_get_char_devices, return);
+LIN_SDT_PROBE_ARGTYPE(util, linux_get_char_devices, return, 0, "char *");
+LIN_SDT_PROBE_DEFINE(util, linux_free_get_char_devices, entry);
+LIN_SDT_PROBE_ARGTYPE(util, linux_free_get_char_devices, entry, 0, "char *");
+LIN_SDT_PROBE_DEFINE(util, linux_free_get_char_devices, return);
+LIN_SDT_PROBE_DEFINE(util, linux_device_register_handler, entry);
+LIN_SDT_PROBE_ARGTYPE(util, linux_device_register_handler, entry, 0,
+ "struct linux_device_handler *");
+LIN_SDT_PROBE_DEFINE(util, linux_device_register_handler, return);
+LIN_SDT_PROBE_ARGTYPE(util, linux_device_register_handler, return, 0, "int");
+LIN_SDT_PROBE_DEFINE(util, linux_device_unregister_handler, entry);
+LIN_SDT_PROBE_ARGTYPE(util, linux_device_unregister_handler, entry, 0,
+ "struct linux_device_handler *");
+LIN_SDT_PROBE_DEFINE(util, linux_device_unregister_handler, return);
+LIN_SDT_PROBE_ARGTYPE(util, linux_device_unregister_handler, return, 0, "int");
+
/*
* Search an alternate path before passing pathname arguments on to
* system calls. Useful for keeping a separate 'emulation tree'.
@@ -66,17 +119,20 @@ const char linux_emul_path[] = "/co
* named file, i.e. we check if the directory it should be in exists.
*/
int
-linux_emul_convpath(td, path, pathseg, pbuf, cflag, dfd)
- struct thread *td;
- const char *path;
- enum uio_seg pathseg;
- char **pbuf;
- int cflag;
- int dfd;
+linux_emul_convpath(struct thread *td, const char *path, enum uio_seg pathseg,
+ char **pbuf, int cflag, int dfd)
{
+ int retval;
+
+ LIN_SDT_PROBE(util, linux_emul_convpath, entry, path, pathseg, pbuf,
+ cflag, dfd);
- return (kern_alternate_path(td, linux_emul_path, path, pathseg, pbuf,
- cflag, dfd));
+ retval = kern_alternate_path(td, linux_emul_path, path, pathseg, pbuf,
+ cflag, dfd);
+
+ LIN_SDT_PROBE(util, linux_emul_convpath, return, retval, 0, 0, 0, 0);
+
+ return (retval);
}
void
@@ -85,12 +141,16 @@ linux_msg(const struct thread *td, const
va_list ap;
struct proc *p;
+ LIN_SDT_PROBE(util, linux_msg, entry, fmt, 0, 0, 0, 0);
+
p = td->td_proc;
printf("linux: pid %d (%s): ", (int)p->p_pid, p->p_comm);
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
printf("\n");
+
+ LIN_SDT_PROBE(util, linux_msg, return, 0, 0, 0, 0, 0);
}
struct device_element
@@ -113,13 +173,26 @@ linux_driver_get_name_dev(device_t dev)
struct device_element *de;
const char *device_name = device_get_name(dev);
- if (device_name == NULL)
+ LIN_SDT_PROBE(util, linux_driver_get_name_dev, entry, dev,
+ device_name, 0, 0, 0);
+
+ if (device_name == NULL) {
+ LIN_SDT_PROBE(util, linux_driver_get_name_dev, nullcall, 0, 0,
+ 0, 0, 0);
+ LIN_SDT_PROBE(util, linux_driver_get_name_dev, return, NULL,
+ 0, 0, 0, 0);
return NULL;
+ }
TAILQ_FOREACH(de, &devices, list) {
- if (strcmp(device_name, de->entry.bsd_driver_name) == 0)
+ if (strcmp(device_name, de->entry.bsd_driver_name) == 0) {
+ LIN_SDT_PROBE(util, linux_driver_get_name_dev, return,
+ de->entry.linux_driver_name, 0, 0, 0, 0);
return (de->entry.linux_driver_name);
+ }
}
+ LIN_SDT_PROBE(util, linux_driver_get_name_dev, return, NULL, 0, 0, 0,
+ 0);
return NULL;
}
@@ -128,8 +201,16 @@ linux_driver_get_major_minor(char *node,
{
struct device_element *de;
- if (node == NULL || major == NULL || minor == NULL)
+ LIN_SDT_PROBE(util, linux_driver_get_major_minor, entry, node, major,
+ minor, 0, 0);
+
+ if (node == NULL || major == NULL || minor == NULL) {
+ LIN_SDT_PROBE(util, linux_driver_get_major_minor, nullcall, 0,
+ 0, 0, 0, 0);
+ LIN_SDT_PROBE(util, linux_driver_get_major_minor, return, 1,
+ *major, *minor, 0, 0);
return 1;
+ }
if (strlen(node) > strlen("pts/") &&
strncmp(node, "pts/", strlen("pts/")) == 0) {
@@ -143,6 +224,9 @@ linux_driver_get_major_minor(char *node,
devno = strtoul(node + strlen("pts/"), NULL, 10);
*major = 136 + (devno / 256);
*minor = devno % 256;
+
+ LIN_SDT_PROBE(util, linux_driver_get_major_minor, return, 0,
+ *major, *minor, 0, 0);
return 0;
}
@@ -150,21 +234,30 @@ linux_driver_get_major_minor(char *node,
if (strcmp(node, de->entry.bsd_device_name) == 0) {
*major = de->entry.linux_major;
*minor = de->entry.linux_minor;
+
+ LIN_SDT_PROBE(util, linux_driver_get_major_minor,
+ return, 0, *major, *minor, 0, 0);
return 0;
}
}
+ LIN_SDT_PROBE(util, linux_driver_get_major_minor, notfound, node, 0, 0,
+ 0, 0);
+ LIN_SDT_PROBE(util, linux_driver_get_major_minor, return, 1, *major,
+ *minor, 0, 0);
return 1;
}
char *
-linux_get_char_devices()
+linux_get_char_devices(void)
{
struct device_element *de;
char *temp, *string, *last;
char formated[256];
int current_size = 0, string_size = 1024;
+ LIN_SDT_PROBE(util, linux_get_char_devices, entry, 0, 0, 0, 0, 0);
+
string = malloc(string_size, M_LINUX, M_WAITOK);
string[0] = '\000';
last = "";
@@ -191,13 +284,19 @@ linux_get_char_devices()
}
}
+ LIN_SDT_PROBE(util, linux_get_char_devices, return, string, 0, 0, 0, 0);
return string;
}
void
linux_free_get_char_devices(char *string)
{
+
+ LIN_SDT_PROBE(util, linux_get_char_devices, entry, string, 0, 0, 0, 0);
+
free(string, M_LINUX);
+
+ LIN_SDT_PROBE(util, linux_get_char_devices, return, 0, 0, 0, 0, 0);
}
static int linux_major_starting = 200;
@@ -207,11 +306,16 @@ linux_device_register_handler(struct lin
{
struct device_element *de;
- if (d == NULL)
+ LIN_SDT_PROBE(util, linux_device_register_handler, entry, d, 0, 0, 0,
+ 0);
+
+ if (d == NULL) {
+ LIN_SDT_PROBE(util, linux_device_register_handler, return,
+ EINVAL, 0, 0, 0, 0);
return (EINVAL);
+ }
- de = malloc(sizeof(*de),
- M_LINUX, M_WAITOK);
+ de = malloc(sizeof(*de), M_LINUX, M_WAITOK);
if (d->linux_major < 0) {
d->linux_major = linux_major_starting++;
}
@@ -220,6 +324,8 @@ linux_device_register_handler(struct lin
/* Add the element to the list, sorted on span. */
TAILQ_INSERT_TAIL(&devices, de, list);
+ LIN_SDT_PROBE(util, linux_device_register_handler, return, 0, 0, 0, 0,
+ 0);
return (0);
}
@@ -228,16 +334,27 @@ linux_device_unregister_handler(struct l
{
struct device_element *de;
- if (d == NULL)
+ LIN_SDT_PROBE(util, linux_device_unregister_handler, entry, d, 0, 0, 0,
+ 0);
+
+ if (d == NULL) {
+ LIN_SDT_PROBE(util, linux_device_unregister_handler, return,
+ EINVAL, 0, 0, 0, 0);
return (EINVAL);
+ }
TAILQ_FOREACH(de, &devices, list) {
if (bcmp(d, &de->entry, sizeof(*d)) == 0) {
TAILQ_REMOVE(&devices, de, list);
free(de, M_LINUX);
+
+ LIN_SDT_PROBE(util, linux_device_unregister_handler,
+ return, 0, 0, 0, 0, 0);
return (0);
}
}
+ LIN_SDT_PROBE(util, linux_device_unregister_handler, return, EINVAL, 0,
+ 0, 0, 0);
return (EINVAL);
}
More information about the svn-src-user
mailing list