BEGIN
{
- printf("Hello from BEGIN\n");
+ printf("Hello from %s\n", probe);
}
END
{
// Comment inside of a block
- printf("Bye from END\n");
+ printf("Bye from %s\n", probe);
}
-/* $OpenBSD: btrace.c,v 1.74 2023/08/16 13:07:11 dv Exp $ */
+/* $OpenBSD: btrace.c,v 1.75 2023/09/02 15:16:12 dv Exp $ */
/*
* Copyright (c) 2019 - 2021 Martin Pieuchot <mpi@openbsd.org>
struct dtioc_arg_info **dt_args; /* array of probe arguments */
struct dt_evt bt_devt; /* fake event for BEGIN/END */
+#define EVENT_BEGIN 0
+#define EVENT_END (unsigned int)(-1)
uint64_t bt_filtered; /* # of events filtered out */
struct syms *kelf, *uelf;
kelf = kelf_open(_PATH_KSYMS);
/* Initialize "fake" event for BEGIN/END */
- bt_devt.dtev_pbn = -1;
+ bt_devt.dtev_pbn = EVENT_BEGIN;
strlcpy(bt_devt.dtev_comm, getprogname(), sizeof(bt_devt.dtev_comm));
bt_devt.dtev_pid = getpid();
bt_devt.dtev_tid = getthrid();
uelf = NULL;
/* Update "fake" event for BEGIN/END */
+ bt_devt.dtev_pbn = EVENT_END;
clock_gettime(CLOCK_REALTIME, &bt_devt.dtev_tsp);
if (rend)
str = buf;
break;
case B_AT_BI_PROBE:
+ if (dtev->dtev_pbn == EVENT_BEGIN) {
+ str = "BEGIN";
+ break;
+ } else if (dtev->dtev_pbn == EVENT_END) {
+ str = "END";
+ break;
+ }
dtpi = &dt_dtpis[dtev->dtev_pbn - 1];
if (dtpi != NULL)
snprintf(buf, sizeof(buf), "%s:%s:%s",