-.\" $OpenBSD: bt.5,v 1.12 2021/10/03 22:01:48 dv Exp $
+.\" $OpenBSD: bt.5,v 1.13 2021/11/12 16:57:24 claudio Exp $
.\"
.\" Copyright (c) 2019 Martin Pieuchot <mpi@openbsd.org>
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: October 3 2021 $
+.Dd $Mdocdate: November 12 2021 $
.Dt BT 5
.Os
.Sh NAME
Timestamp of the event in nanoseconds.
.It Va pid
Process ID of the current thread.
+.It Va probe
+Full name of the probe.
.It Va retval
Return value of the traced syscall.
.It Va tid
-/* $OpenBSD: bt_parse.y,v 1.44 2021/10/03 22:01:48 dv Exp $ */
+/* $OpenBSD: bt_parse.y,v 1.45 2021/11/12 16:57:24 claudio Exp $ */
/*
* Copyright (c) 2019-2021 Martin Pieuchot <mpi@openbsd.org>
{ "pid", BUILTIN, B_AT_BI_PID },
{ "print", F_PRINT, B_AC_PRINT },
{ "printf", FUNCN, B_AC_PRINTF },
+ { "probe", BUILTIN, B_AT_BI_PROBE },
{ "retval", BUILTIN, B_AT_BI_RETVAL },
{ "str", STR, B_AT_FN_STR },
{ "sum", MOP1, B_AT_MF_SUM },
-/* $OpenBSD: bt_parser.h,v 1.21 2021/10/03 22:01:48 dv Exp $ */
+/* $OpenBSD: bt_parser.h,v 1.22 2021/11/12 16:57:24 claudio Exp $ */
/*
* Copyright (c) 2019-2021 Martin Pieuchot <mpi@openbsd.org>
B_AT_BI_ARG9,
B_AT_BI_ARGS,
B_AT_BI_RETVAL,
+ B_AT_BI_PROBE,
B_AT_FN_STR, /* str($1); str($1, 3); */
-/* $OpenBSD: btrace.c,v 1.59 2021/10/24 14:18:58 mpi Exp $ */
+/* $OpenBSD: btrace.c,v 1.60 2021/11/12 16:57:24 claudio Exp $ */
/*
* Copyright (c) 2019 - 2021 Martin Pieuchot <mpi@openbsd.org>
return fcontent;
}
+static int
+dtpi_cmp(const void *a, const void *b)
+{
+ const struct dtioc_probe_info *ai = a, *bi = b;
+
+ if (ai->dtpi_pbn > bi->dtpi_pbn)
+ return 1;
+ if (ai->dtpi_pbn < bi->dtpi_pbn)
+ return -1;
+ return 0;
+}
+
void
dtpi_cache(int fd)
{
dtpr.dtpr_probes = dt_dtpis;
if (ioctl(fd, DTIOCGPLIST, &dtpr))
err(1, "DTIOCGPLIST");
+
+ qsort(dt_dtpis, dt_ndtpi, sizeof(*dt_dtpis), dtpi_cmp);
}
void
return NULL;
}
+static struct dtioc_probe_info *
+dtpi_get_by_id(unsigned int pbn)
+{
+ struct dtioc_probe_info d;
+
+ d.dtpi_pbn = pbn;
+ return bsearch(&d, dt_dtpis, dt_ndtpi, sizeof(*dt_dtpis), dtpi_cmp);
+}
+
void
rules_do(int fd)
{
return "args";
case B_AT_BI_RETVAL:
return "retval";
+ case B_AT_BI_PROBE:
+ return "probe";
case B_AT_FN_STR:
return "str";
case B_AT_OP_PLUS:
case B_AT_BI_RETVAL:
val = dtev->dtev_retval[0];
break;
+ case B_AT_BI_PROBE:
+ val = dtev->dtev_pbn;
+ break;
case B_AT_OP_PLUS ... B_AT_OP_LOR:
val = baexpr2long(ba, dtev);
break;
{
static char buf[STRLEN];
struct bt_var *bv;
+ struct dtioc_probe_info *dtpi;
const char *str;
buf[0] = '\0';
snprintf(buf, sizeof(buf), "%ld", (long)dtev->dtev_retval[0]);
str = buf;
break;
+ case B_AT_BI_PROBE:
+ dtpi = dtpi_get_by_id(dtev->dtev_pbn);
+ if (dtpi != NULL)
+ snprintf(buf, sizeof(buf), "%s:%s:%s",
+ dtpi->dtpi_prov, dtpi_func(dtpi), dtpi->dtpi_name);
+ else
+ snprintf(buf, sizeof(buf), "%u", dtev->dtev_pbn);
+ str = buf;
+ break;
case B_AT_MAP:
bv = ba->ba_value;
/* Unitialized map */
flags |= DTEVT_FUNCARGS;
break;
case B_AT_BI_RETVAL:
+ case B_AT_BI_PROBE:
break;
case B_AT_MF_COUNT:
case B_AT_MF_MAX:
-/* $OpenBSD: map.c,v 1.17 2021/09/09 06:58:39 mpi Exp $ */
+/* $OpenBSD: map.c,v 1.18 2021/11/12 16:57:24 claudio Exp $ */
/*
* Copyright (c) 2020 Martin Pieuchot <mpi@openbsd.org>
case B_AT_BI_NSECS:
case B_AT_BI_ARG0 ... B_AT_BI_ARG9:
case B_AT_BI_RETVAL:
+ case B_AT_BI_PROBE:
free(mep->mval);
mep->mval = ba_new(ba2long(bval, dtev), B_AT_LONG);
break;