4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include <sys/sysmacros.h>
44 #include <sys/sysctl.h>
55 } dtrace_probespecs[] = {
56 { offsetof(dtrace_probedesc_t, dtpd_provider), DTRACE_PROVNAMELEN },
57 { offsetof(dtrace_probedesc_t, dtpd_mod), DTRACE_MODNAMELEN },
58 { offsetof(dtrace_probedesc_t, dtpd_func), DTRACE_FUNCNAMELEN },
59 { offsetof(dtrace_probedesc_t, dtpd_name), DTRACE_NAMELEN }
63 dtrace_xstr2desc(dtrace_hdl_t *dtp, dtrace_probespec_t spec,
64 const char *s, int argc, char *const argv[], dtrace_probedesc_t *pdp)
66 size_t off, len, vlen;
67 const char *p, *q, *v;
69 char buf[32]; /* for id_t as %d (see below) */
71 if (spec < DTRACE_PROBESPEC_NONE || spec > DTRACE_PROBESPEC_NAME)
72 return (dt_set_errno(dtp, EINVAL));
74 bzero(pdp, sizeof (dtrace_probedesc_t));
75 p = s + strlen(s) - 1;
78 for (len = 0; p >= s && *p != ':'; len++)
79 p--; /* move backward until we find a delimiter */
84 if ((v = strchr(q, '$')) != NULL && v < q + len) {
86 * Set vlen to the length of the variable name and then
87 * reset len to the length of the text prior to '$'. If
88 * the name begins with a digit, interpret it using the
89 * the argv[] array. Otherwise we look in dt_macros.
90 * For the moment, all dt_macros variables are of type
91 * id_t (see dtrace_update() for more details on that).
93 vlen = (size_t)(q + len - v);
94 len = (size_t)(v - q);
97 * If the variable string begins with $$, skip past the
98 * leading dollar sign since $ and $$ are equivalent
99 * macro reference operators in a probe description.
101 if (vlen > 2 && v[1] == '$') {
111 i = strtol(v + 1, &end, 10);
113 if (i < 0 || i >= argc ||
114 errno != 0 || end != v + vlen)
115 return (dt_set_errno(dtp, EDT_BADSPCV));
120 if (yypcb != NULL && yypcb->pcb_sargv == argv)
121 yypcb->pcb_sflagv[i] |= DT_IDFLG_REF;
123 } else if (vlen > 1) {
124 char *vstr = alloca(vlen);
127 (void) strncpy(vstr, v + 1, vlen - 1);
128 vstr[vlen - 1] = '\0';
129 idp = dt_idhash_lookup(dtp->dt_macros, vstr);
132 return (dt_set_errno(dtp, EDT_BADSPCV));
135 vlen = snprintf(buf, 32, "%d", idp->di_id);
138 return (dt_set_errno(dtp, EDT_BADSPCV));
141 if (spec == DTRACE_PROBESPEC_NONE)
142 return (dt_set_errno(dtp, EDT_BADSPEC));
144 if (len + vlen >= dtrace_probespecs[spec].dtps_len)
145 return (dt_set_errno(dtp, ENAMETOOLONG));
147 off = dtrace_probespecs[spec--].dtps_offset;
148 bcopy(q, (char *)pdp + off, len);
149 bcopy(v, (char *)pdp + off + len, vlen);
153 pdp->dtpd_id = DTRACE_IDNONE;
158 dtrace_str2desc(dtrace_hdl_t *dtp, dtrace_probespec_t spec,
159 const char *s, dtrace_probedesc_t *pdp)
161 return (dtrace_xstr2desc(dtp, spec, s, 0, NULL, pdp));
165 dtrace_id2desc(dtrace_hdl_t *dtp, dtrace_id_t id, dtrace_probedesc_t *pdp)
167 bzero(pdp, sizeof (dtrace_probedesc_t));
170 if (dt_ioctl(dtp, DTRACEIOC_PROBES, pdp) == -1 ||
172 return (dt_set_errno(dtp, EDT_BADID));
178 dtrace_desc2str(const dtrace_probedesc_t *pdp, char *buf, size_t len)
180 if (pdp->dtpd_id == 0) {
181 (void) snprintf(buf, len, "%s:%s:%s:%s", pdp->dtpd_provider,
182 pdp->dtpd_mod, pdp->dtpd_func, pdp->dtpd_name);
184 (void) snprintf(buf, len, "%u", pdp->dtpd_id);
190 dtrace_attr2str(dtrace_attribute_t attr, char *buf, size_t len)
192 const char *name = dtrace_stability_name(attr.dtat_name);
193 const char *data = dtrace_stability_name(attr.dtat_data);
194 const char *class = dtrace_class_name(attr.dtat_class);
196 if (name == NULL || data == NULL || class == NULL)
197 return (NULL); /* one or more invalid attributes */
199 (void) snprintf(buf, len, "%s/%s/%s", name, data, class);
204 dt_getstrattr(char *p, char **qp)
211 if ((q = strchr(p, '/')) == NULL)
221 dtrace_str2attr(const char *str, dtrace_attribute_t *attr)
223 dtrace_stability_t s;
227 if (str == NULL || attr == NULL)
228 return (-1); /* invalid function arguments */
230 *attr = _dtrace_maxattr;
231 p = alloca(strlen(str) + 1);
232 (void) strcpy(p, str);
234 if ((p = dt_getstrattr(p, &q)) == NULL)
237 for (s = 0; s <= DTRACE_STABILITY_MAX; s++) {
238 if (strcasecmp(p, dtrace_stability_name(s)) == 0) {
244 if (s > DTRACE_STABILITY_MAX)
247 if ((p = dt_getstrattr(q, &q)) == NULL)
250 for (s = 0; s <= DTRACE_STABILITY_MAX; s++) {
251 if (strcasecmp(p, dtrace_stability_name(s)) == 0) {
257 if (s > DTRACE_STABILITY_MAX)
260 if ((p = dt_getstrattr(q, &q)) == NULL)
263 for (c = 0; c <= DTRACE_CLASS_MAX; c++) {
264 if (strcasecmp(p, dtrace_class_name(c)) == 0) {
265 attr->dtat_class = c;
270 if (c > DTRACE_CLASS_MAX || (p = dt_getstrattr(q, &q)) != NULL)
277 dtrace_stability_name(dtrace_stability_t s)
280 case DTRACE_STABILITY_INTERNAL: return ("Internal");
281 case DTRACE_STABILITY_PRIVATE: return ("Private");
282 case DTRACE_STABILITY_OBSOLETE: return ("Obsolete");
283 case DTRACE_STABILITY_EXTERNAL: return ("External");
284 case DTRACE_STABILITY_UNSTABLE: return ("Unstable");
285 case DTRACE_STABILITY_EVOLVING: return ("Evolving");
286 case DTRACE_STABILITY_STABLE: return ("Stable");
287 case DTRACE_STABILITY_STANDARD: return ("Standard");
288 default: return (NULL);
293 dtrace_class_name(dtrace_class_t c)
296 case DTRACE_CLASS_UNKNOWN: return ("Unknown");
297 case DTRACE_CLASS_CPU: return ("CPU");
298 case DTRACE_CLASS_PLATFORM: return ("Platform");
299 case DTRACE_CLASS_GROUP: return ("Group");
300 case DTRACE_CLASS_ISA: return ("ISA");
301 case DTRACE_CLASS_COMMON: return ("Common");
302 default: return (NULL);
307 dt_attr_min(dtrace_attribute_t a1, dtrace_attribute_t a2)
309 dtrace_attribute_t am;
311 am.dtat_name = MIN(a1.dtat_name, a2.dtat_name);
312 am.dtat_data = MIN(a1.dtat_data, a2.dtat_data);
313 am.dtat_class = MIN(a1.dtat_class, a2.dtat_class);
319 dt_attr_max(dtrace_attribute_t a1, dtrace_attribute_t a2)
321 dtrace_attribute_t am;
323 am.dtat_name = MAX(a1.dtat_name, a2.dtat_name);
324 am.dtat_data = MAX(a1.dtat_data, a2.dtat_data);
325 am.dtat_class = MAX(a1.dtat_class, a2.dtat_class);
331 * Compare two attributes and return an integer value in the following ranges:
333 * <0 if any of a1's attributes are less than a2's attributes
334 * =0 if all of a1's attributes are equal to a2's attributes
335 * >0 if all of a1's attributes are greater than or equal to a2's attributes
337 * To implement this function efficiently, we subtract a2's attributes from
338 * a1's to obtain a negative result if an a1 attribute is less than its a2
339 * counterpart. We then OR the intermediate results together, relying on the
340 * twos-complement property that if any result is negative, the bitwise union
341 * will also be negative since the highest bit will be set in the result.
344 dt_attr_cmp(dtrace_attribute_t a1, dtrace_attribute_t a2)
346 return (((int)a1.dtat_name - a2.dtat_name) |
347 ((int)a1.dtat_data - a2.dtat_data) |
348 ((int)a1.dtat_class - a2.dtat_class));
352 dt_attr_str(dtrace_attribute_t a, char *buf, size_t len)
354 static const char stability[] = "ipoxuesS";
355 static const char class[] = "uCpgIc";
357 if (a.dtat_name < sizeof (stability) &&
358 a.dtat_data < sizeof (stability) && a.dtat_class < sizeof (class)) {
359 (void) snprintf(buf, len, "[%c/%c/%c]", stability[a.dtat_name],
360 stability[a.dtat_data], class[a.dtat_class]);
362 (void) snprintf(buf, len, "[%u/%u/%u]",
363 a.dtat_name, a.dtat_data, a.dtat_class);
370 dt_version_num2str(dt_version_t v, char *buf, size_t len)
372 uint_t M = DT_VERSION_MAJOR(v);
373 uint_t m = DT_VERSION_MINOR(v);
374 uint_t u = DT_VERSION_MICRO(v);
377 (void) snprintf(buf, len, "%u.%u", M, m);
379 (void) snprintf(buf, len, "%u.%u.%u", M, m, u);
385 dt_version_str2num(const char *s, dt_version_t *vp)
387 int i = 0, n[3] = { 0, 0, 0 };
390 while ((c = *s++) != '\0') {
392 n[i] = n[i] * 10 + c - '0';
393 else if (c != '.' || i++ >= sizeof (n) / sizeof (n[0]) - 1)
397 if (n[0] > DT_VERSION_MAJMAX ||
398 n[1] > DT_VERSION_MINMAX ||
399 n[2] > DT_VERSION_MICMAX)
403 *vp = DT_VERSION_NUMBER(n[0], n[1], n[2]);
409 dt_version_defined(dt_version_t v)
413 for (i = 0; _dtrace_versions[i] != 0; i++) {
414 if (_dtrace_versions[i] == v)
422 dt_cpp_add_arg(dtrace_hdl_t *dtp, const char *str)
426 if (dtp->dt_cpp_argc == dtp->dt_cpp_args) {
427 int olds = dtp->dt_cpp_args;
429 char **argv = realloc(dtp->dt_cpp_argv, sizeof (char *) * news);
434 bzero(&argv[olds], sizeof (char *) * olds);
435 dtp->dt_cpp_argv = argv;
436 dtp->dt_cpp_args = news;
439 if ((arg = strdup(str)) == NULL)
442 assert(dtp->dt_cpp_argc < dtp->dt_cpp_args);
443 dtp->dt_cpp_argv[dtp->dt_cpp_argc++] = arg;
448 dt_cpp_pop_arg(dtrace_hdl_t *dtp)
452 if (dtp->dt_cpp_argc <= 1)
453 return (NULL); /* dt_cpp_argv[0] cannot be popped */
455 arg = dtp->dt_cpp_argv[--dtp->dt_cpp_argc];
456 dtp->dt_cpp_argv[dtp->dt_cpp_argc] = NULL;
463 dt_dprintf(const char *format, ...)
468 va_start(alist, format);
469 (void) fputs("libdtrace DEBUG: ", stderr);
470 (void) vfprintf(stderr, format, alist);
477 dt_ioctl(dtrace_hdl_t *dtp, int val, void *arg)
479 dt_ioctl(dtrace_hdl_t *dtp, u_long val, void *arg)
482 const dtrace_vector_t *v = dtp->dt_vector;
485 /* Avoid sign extension. */
490 return (v->dtv_ioctl(dtp->dt_varg, val, arg));
493 return (ioctl(dtp->dt_fd, val, arg));
500 dt_status(dtrace_hdl_t *dtp, processorid_t cpu)
502 const dtrace_vector_t *v = dtp->dt_vector;
506 return (p_online(cpu, P_STATUS));
509 size_t len = sizeof(maxid);
510 if (sysctlbyname("kern.smp.maxid", &maxid, &len, NULL, 0) != 0)
511 return (cpu == 0 ? 1 : -1);
513 return (cpu <= maxid ? 1 : -1);
517 return (v->dtv_status(dtp->dt_varg, cpu));
521 dt_sysconf(dtrace_hdl_t *dtp, int name)
523 const dtrace_vector_t *v = dtp->dt_vector;
526 return (sysconf(name));
528 return (v->dtv_sysconf(dtp->dt_varg, name));
532 * Wrapper around write(2) to handle partial writes. For maximum safety of
533 * output files and proper error reporting, we continuing writing in the
534 * face of partial writes until write(2) fails or 'buf' is completely written.
535 * We also record any errno in the specified dtrace_hdl_t as well as 'errno'.
538 dt_write(dtrace_hdl_t *dtp, int fd, const void *buf, size_t n)
544 if ((len = write(fd, buf, resid)) <= 0)
548 buf = (char *)buf + len;
551 if (resid == n && n != 0)
552 return (dt_set_errno(dtp, errno));
558 * This function handles all output from libdtrace, as well as the
559 * dtrace_sprintf() case. If we're here due to dtrace_sprintf(), then
560 * dt_sprintf_buflen will be non-zero; in this case, we sprintf into the
561 * specified buffer and return. Otherwise, if output is buffered (denoted by
562 * a NULL fp), we sprintf the desired output into the buffered buffer
563 * (expanding the buffer if required). If we don't satisfy either of these
564 * conditions (that is, if we are to actually generate output), then we call
565 * fprintf with the specified fp. In this case, we need to deal with one of
566 * the more annoying peculiarities of libc's printf routines: any failed
567 * write persistently sets an error flag inside the FILE causing every
568 * subsequent write to fail, but only the caller that initiated the error gets
569 * the errno. Since libdtrace clients often intercept SIGINT, this case is
570 * particularly frustrating since we don't want the EINTR on one attempt to
571 * write to the output file to preclude later attempts to write. This
572 * function therefore does a clearerr() if any error occurred, and saves the
573 * errno for the caller inside the specified dtrace_hdl_t.
577 dt_printf(dtrace_hdl_t *dtp, FILE *fp, const char *format, ...)
584 * On FreeBSD, check if output is currently being re-directed
585 * to another file. If so, output to that file instead of the
586 * one the caller has specified.
588 if (dtp->dt_freopen_fp != NULL)
589 fp = dtp->dt_freopen_fp;
592 va_start(ap, format);
594 if (dtp->dt_sprintf_buflen != 0) {
598 assert(dtp->dt_sprintf_buf != NULL);
600 buf = &dtp->dt_sprintf_buf[len = strlen(dtp->dt_sprintf_buf)];
601 len = dtp->dt_sprintf_buflen - len;
604 if ((n = vsnprintf(buf, len, format, ap)) < 0)
605 n = dt_set_errno(dtp, errno);
617 * It's not legal to use buffered ouput if there is not a
618 * handler for buffered output.
620 if (dtp->dt_bufhdlr == NULL) {
622 return (dt_set_errno(dtp, EDT_NOBUFFERED));
625 if (dtp->dt_buffered_buf == NULL) {
626 assert(dtp->dt_buffered_size == 0);
627 dtp->dt_buffered_size = 1;
628 dtp->dt_buffered_buf = malloc(dtp->dt_buffered_size);
630 if (dtp->dt_buffered_buf == NULL) {
632 return (dt_set_errno(dtp, EDT_NOMEM));
635 dtp->dt_buffered_offs = 0;
636 dtp->dt_buffered_buf[0] = '\0';
639 if ((needed = vsnprintf(NULL, 0, format, ap)) < 0) {
640 rval = dt_set_errno(dtp, errno);
653 assert(dtp->dt_buffered_offs < dtp->dt_buffered_size);
654 avail = dtp->dt_buffered_size - dtp->dt_buffered_offs;
656 if (needed + 1 < avail)
659 if ((newbuf = realloc(dtp->dt_buffered_buf,
660 dtp->dt_buffered_size << 1)) == NULL) {
662 return (dt_set_errno(dtp, EDT_NOMEM));
665 dtp->dt_buffered_buf = newbuf;
666 dtp->dt_buffered_size <<= 1;
669 if (vsnprintf(&dtp->dt_buffered_buf[dtp->dt_buffered_offs],
670 avail, format, ap) < 0) {
671 rval = dt_set_errno(dtp, errno);
676 dtp->dt_buffered_offs += needed;
677 assert(dtp->dt_buffered_buf[dtp->dt_buffered_offs] == '\0');
681 n = vfprintf(fp, format, ap);
687 return (dt_set_errno(dtp, errno));
694 dt_buffered_flush(dtrace_hdl_t *dtp, dtrace_probedata_t *pdata,
695 const dtrace_recdesc_t *rec, const dtrace_aggdata_t *agg, uint32_t flags)
697 dtrace_bufdata_t data;
699 if (dtp->dt_buffered_offs == 0)
702 data.dtbda_handle = dtp;
703 data.dtbda_buffered = dtp->dt_buffered_buf;
704 data.dtbda_probe = pdata;
705 data.dtbda_recdesc = rec;
706 data.dtbda_aggdata = agg;
707 data.dtbda_flags = flags;
709 if ((*dtp->dt_bufhdlr)(&data, dtp->dt_bufarg) == DTRACE_HANDLE_ABORT)
710 return (dt_set_errno(dtp, EDT_DIRABORT));
712 dtp->dt_buffered_offs = 0;
713 dtp->dt_buffered_buf[0] = '\0';
719 dt_buffered_destroy(dtrace_hdl_t *dtp)
721 free(dtp->dt_buffered_buf);
722 dtp->dt_buffered_buf = NULL;
723 dtp->dt_buffered_offs = 0;
724 dtp->dt_buffered_size = 0;
728 dt_zalloc(dtrace_hdl_t *dtp, size_t size)
732 if (size > 16 * 1024 * 1024) {
733 (void) dt_set_errno(dtp, EDT_NOMEM);
737 if ((data = malloc(size)) == NULL)
738 (void) dt_set_errno(dtp, EDT_NOMEM);
746 dt_alloc(dtrace_hdl_t *dtp, size_t size)
750 if (size > 16 * 1024 * 1024) {
751 (void) dt_set_errno(dtp, EDT_NOMEM);
755 if ((data = malloc(size)) == NULL)
756 (void) dt_set_errno(dtp, EDT_NOMEM);
762 dt_free(dtrace_hdl_t *dtp, void *data)
764 assert(dtp != NULL); /* ensure sane use of this interface */
769 dt_difo_free(dtrace_hdl_t *dtp, dtrace_difo_t *dp)
772 return; /* simplify caller code */
774 dt_free(dtp, dp->dtdo_buf);
775 dt_free(dtp, dp->dtdo_inttab);
776 dt_free(dtp, dp->dtdo_strtab);
777 dt_free(dtp, dp->dtdo_vartab);
778 dt_free(dtp, dp->dtdo_kreltab);
779 dt_free(dtp, dp->dtdo_ureltab);
780 dt_free(dtp, dp->dtdo_xlmtab);
786 * dt_gmatch() is similar to gmatch(3GEN) and dtrace(7D) globbing, but also
787 * implements the behavior that an empty pattern matches any string.
790 dt_gmatch(const char *s, const char *p)
792 return (p == NULL || *p == '\0' || gmatch(s, p));
796 dt_basename(char *str)
798 char *last = strrchr(str, '/');
807 * dt_popc() is a fast implementation of population count. The algorithm is
808 * from "Hacker's Delight" by Henry Warren, Jr with a 64-bit equivalent added.
814 x = x - ((x >> 1) & 0x55555555UL);
815 x = (x & 0x33333333UL) + ((x >> 2) & 0x33333333UL);
816 x = (x + (x >> 4)) & 0x0F0F0F0FUL;
822 x = x - ((x >> 1) & 0x5555555555555555ULL);
823 x = (x & 0x3333333333333333ULL) + ((x >> 2) & 0x3333333333333333ULL);
824 x = (x + (x >> 4)) & 0x0F0F0F0F0F0F0F0FULL;
833 * dt_popcb() is a bitmap-based version of population count that returns the
834 * number of one bits in the specified bitmap 'bp' at bit positions below 'n'.
837 dt_popcb(const ulong_t *bp, ulong_t n)
839 ulong_t maxb = n & BT_ULMASK;
840 ulong_t maxw = n >> BT_ULSHIFT;
846 for (w = 0; w < maxw; w++)
847 popc += dt_popc(bp[w]);
849 return (popc + dt_popc(bp[maxw] & ((1UL << maxb) - 1)));
857 dt_rw_read_held(pthread_rwlock_t *lock)
859 extern int _rw_read_held(struct _rwlock *);
860 return (_rw_read_held((struct _rwlock *)lock));
864 dt_rw_write_held(pthread_rwlock_t *lock)
866 extern int _rw_write_held(struct _rwlock *);
867 return (_rw_write_held((struct _rwlock *)lock));
872 dt_mutex_held(pthread_mutex_t *lock)
875 extern int _mutex_held(struct _lwp_mutex *);
876 return (_mutex_held((struct _lwp_mutex *)lock));
883 dt_string2str(char *s, char *str, int nbytes)
889 * Like snprintf(3C), we don't check the value of str if the
890 * number of bytes is 0.
896 (void) strncpy(str, s, nbytes - 1);
898 * Like snprintf(3C) (and unlike strncpy(3C)), we guarantee
899 * that the string is null-terminated.
901 str[nbytes - 1] = '\0';
903 (void) strcpy(str, s);
910 dtrace_addr2str(dtrace_hdl_t *dtp, uint64_t addr, char *str, int nbytes)
912 dtrace_syminfo_t dts;
915 size_t n = 20; /* for 0x%llx\0 */
919 if ((err = dtrace_lookup_by_addr(dtp, addr, &sym, &dts)) == 0)
920 n += strlen(dts.dts_object) + strlen(dts.dts_name) + 2; /* +` */
924 if (err == 0 && addr != sym.st_value) {
925 (void) snprintf(s, n, "%s`%s+0x%llx", dts.dts_object,
926 dts.dts_name, (u_longlong_t)addr - sym.st_value);
927 } else if (err == 0) {
928 (void) snprintf(s, n, "%s`%s",
929 dts.dts_object, dts.dts_name);
932 * We'll repeat the lookup, but this time we'll specify a NULL
933 * GElf_Sym -- indicating that we're only interested in the
936 if (dtrace_lookup_by_addr(dtp, addr, NULL, &dts) == 0) {
937 (void) snprintf(s, n, "%s`0x%llx", dts.dts_object,
940 (void) snprintf(s, n, "0x%llx", (u_longlong_t)addr);
944 return (dt_string2str(s, str, nbytes));
948 dtrace_uaddr2str(dtrace_hdl_t *dtp, pid_t pid,
949 uint64_t addr, char *str, int nbytes)
951 char name[PATH_MAX], objname[PATH_MAX], c[PATH_MAX * 2];
952 struct ps_prochandle *P = NULL;
957 P = dt_proc_grab(dtp, pid, PGRAB_RDONLY | PGRAB_FORCE, 0);
960 (void) snprintf(c, sizeof (c), "0x%llx", addr);
961 return (dt_string2str(c, str, nbytes));
964 dt_proc_lock(dtp, P);
967 if (Plookup_by_addr(P, addr, name, sizeof (name), &sym) == 0) {
968 (void) Pobjname(P, addr, objname, sizeof (objname));
970 if (proc_addr2sym(P, addr, name, sizeof (name), &sym) == 0) {
971 (void) proc_objname(P, addr, objname, sizeof (objname));
974 obj = dt_basename(objname);
976 if (addr > sym.st_value) {
977 (void) snprintf(c, sizeof (c), "%s`%s+0x%llx", obj,
978 name, (u_longlong_t)(addr - sym.st_value));
980 (void) snprintf(c, sizeof (c), "%s`%s", obj, name);
983 } else if (Pobjname(P, addr, objname, sizeof (objname)) != 0) {
985 } else if (proc_objname(P, addr, objname, sizeof (objname)) != 0) {
987 (void) snprintf(c, sizeof (c), "%s`0x%llx",
988 dt_basename(objname), addr);
990 (void) snprintf(c, sizeof (c), "0x%llx", addr);
993 dt_proc_unlock(dtp, P);
994 dt_proc_release(dtp, P);
996 return (dt_string2str(c, str, nbytes));