Print this page
4159 dtrace ignores all ustack helper frames from dead processes
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>


1364 
1365         for (i = 0; i < depth && pc[i] != NULL; i++) {
1366                 const prmap_t *map;
1367 
1368                 if ((err = dt_printf(dtp, fp, "%*s", indent, "")) < 0)
1369                         break;
1370 
1371                 if (P != NULL && Plookup_by_addr(P, pc[i],
1372                     name, sizeof (name), &sym) == 0) {
1373                         (void) Pobjname(P, pc[i], objname, sizeof (objname));
1374 
1375                         if (pc[i] > sym.st_value) {
1376                                 (void) snprintf(c, sizeof (c),
1377                                     "%s`%s+0x%llx", dt_basename(objname), name,
1378                                     (u_longlong_t)(pc[i] - sym.st_value));
1379                         } else {
1380                                 (void) snprintf(c, sizeof (c),
1381                                     "%s`%s", dt_basename(objname), name);
1382                         }
1383                 } else if (str != NULL && str[0] != '\0' && str[0] != '@' &&
1384                     (P != NULL && ((map = Paddr_to_map(P, pc[i])) == NULL ||
1385                     (map->pr_mflags & MA_WRITE)))) {
1386                         /*
1387                          * If the current string pointer in the string table
1388                          * does not point to an empty string _and_ the program
1389                          * counter falls in a writable region, we'll use the
1390                          * string from the string table instead of the raw
1391                          * address.  This last condition is necessary because
1392                          * some (broken) ustack helpers will return a string
1393                          * even for a program counter that they can't
1394                          * identify.  If we have a string for a program
1395                          * counter that falls in a segment that isn't
1396                          * writable, we assume that we have fallen into this
1397                          * case and we refuse to use the string.



1398                          */
1399                         (void) snprintf(c, sizeof (c), "%s", str);
1400                 } else {
1401                         if (P != NULL && Pobjname(P, pc[i], objname,
1402                             sizeof (objname)) != NULL) {
1403                                 (void) snprintf(c, sizeof (c), "%s`0x%llx",
1404                                     dt_basename(objname), (u_longlong_t)pc[i]);
1405                         } else {
1406                                 (void) snprintf(c, sizeof (c), "0x%llx",
1407                                     (u_longlong_t)pc[i]);
1408                         }
1409                 }
1410 
1411                 if ((err = dt_printf(dtp, fp, format, c)) < 0)
1412                         break;
1413 
1414                 if ((err = dt_printf(dtp, fp, "\n")) < 0)
1415                         break;
1416 
1417                 if (str != NULL && str[0] == '@') {




1364 
1365         for (i = 0; i < depth && pc[i] != NULL; i++) {
1366                 const prmap_t *map;
1367 
1368                 if ((err = dt_printf(dtp, fp, "%*s", indent, "")) < 0)
1369                         break;
1370 
1371                 if (P != NULL && Plookup_by_addr(P, pc[i],
1372                     name, sizeof (name), &sym) == 0) {
1373                         (void) Pobjname(P, pc[i], objname, sizeof (objname));
1374 
1375                         if (pc[i] > sym.st_value) {
1376                                 (void) snprintf(c, sizeof (c),
1377                                     "%s`%s+0x%llx", dt_basename(objname), name,
1378                                     (u_longlong_t)(pc[i] - sym.st_value));
1379                         } else {
1380                                 (void) snprintf(c, sizeof (c),
1381                                     "%s`%s", dt_basename(objname), name);
1382                         }
1383                 } else if (str != NULL && str[0] != '\0' && str[0] != '@' &&
1384                     (P == NULL || (map = Paddr_to_map(P, pc[i])) == NULL ||
1385                     map->pr_mflags & MA_WRITE)) {
1386                         /*
1387                          * If the current string pointer in the string table
1388                          * does not point to an empty string _and_ the program
1389                          * counter falls in a writable region, we'll use the
1390                          * string from the string table instead of the raw
1391                          * address.  This last condition is necessary because
1392                          * some (broken) ustack helpers will return a string
1393                          * even for a program counter that they can't
1394                          * identify.  If we have a string for a program
1395                          * counter that falls in a segment that isn't
1396                          * writable, we assume that we have fallen into this
1397                          * case and we refuse to use the string.  Finally,
1398                          * note that if we could not grab the process (e.g.,
1399                          * because it exited), the information from the helper
1400                          * is better than nothing.
1401                          */
1402                         (void) snprintf(c, sizeof (c), "%s", str);
1403                 } else {
1404                         if (P != NULL && Pobjname(P, pc[i], objname,
1405                             sizeof (objname)) != NULL) {
1406                                 (void) snprintf(c, sizeof (c), "%s`0x%llx",
1407                                     dt_basename(objname), (u_longlong_t)pc[i]);
1408                         } else {
1409                                 (void) snprintf(c, sizeof (c), "0x%llx",
1410                                     (u_longlong_t)pc[i]);
1411                         }
1412                 }
1413 
1414                 if ((err = dt_printf(dtp, fp, format, c)) < 0)
1415                         break;
1416 
1417                 if ((err = dt_printf(dtp, fp, "\n")) < 0)
1418                         break;
1419 
1420                 if (str != NULL && str[0] == '@') {