dt_pid.c (210775) | dt_pid.c (211554) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 26 unchanged lines hidden (view full) --- 35#endif 36#include <libgen.h> 37#include <stddef.h> 38 39#include <dt_impl.h> 40#include <dt_program.h> 41#include <dt_pid.h> 42#include <dt_string.h> | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 26 unchanged lines hidden (view full) --- 35#endif 36#include <libgen.h> 37#include <stddef.h> 38 39#include <dt_impl.h> 40#include <dt_program.h> 41#include <dt_pid.h> 42#include <dt_string.h> |
43#if !defined(sun) 44#include <libproc_compat.h> 45#endif |
|
43 44typedef struct dt_pid_probe { 45 dtrace_hdl_t *dpp_dtp; 46 dt_pcb_t *dpp_pcb; 47 dt_proc_t *dpp_dpr; 48 struct ps_prochandle *dpp_pr; 49 const char *dpp_mod; 50 char *dpp_func; --- 86 unchanged lines hidden (view full) --- 137 138 ftp->ftps_pid = pid; 139 (void) strncpy(ftp->ftps_func, func, sizeof (ftp->ftps_func)); 140 141 dt_pid_objname(ftp->ftps_mod, sizeof (ftp->ftps_mod), pp->dpp_lmid, 142 pp->dpp_obj); 143 144 if (!isdash && gmatch("return", pp->dpp_name)) { | 46 47typedef struct dt_pid_probe { 48 dtrace_hdl_t *dpp_dtp; 49 dt_pcb_t *dpp_pcb; 50 dt_proc_t *dpp_dpr; 51 struct ps_prochandle *dpp_pr; 52 const char *dpp_mod; 53 char *dpp_func; --- 86 unchanged lines hidden (view full) --- 140 141 ftp->ftps_pid = pid; 142 (void) strncpy(ftp->ftps_func, func, sizeof (ftp->ftps_func)); 143 144 dt_pid_objname(ftp->ftps_mod, sizeof (ftp->ftps_mod), pp->dpp_lmid, 145 pp->dpp_obj); 146 147 if (!isdash && gmatch("return", pp->dpp_name)) { |
145#ifdef DOODAD | |
146 if (dt_pid_create_return_probe(pp->dpp_pr, dtp, ftp, symp, 147 pp->dpp_stret) < 0) { 148 return (dt_pid_error(dtp, pcb, dpr, ftp, 149 D_PROC_CREATEFAIL, "failed to create return probe " 150 "for '%s': %s", func, 151 dtrace_errmsg(dtp, dtrace_errno(dtp)))); 152 } | 148 if (dt_pid_create_return_probe(pp->dpp_pr, dtp, ftp, symp, 149 pp->dpp_stret) < 0) { 150 return (dt_pid_error(dtp, pcb, dpr, ftp, 151 D_PROC_CREATEFAIL, "failed to create return probe " 152 "for '%s': %s", func, 153 dtrace_errmsg(dtp, dtrace_errno(dtp)))); 154 } |
153#endif | |
154 155 nmatches++; 156 } 157 158 if (!isdash && gmatch("entry", pp->dpp_name)) { | 155 156 nmatches++; 157 } 158 159 if (!isdash && gmatch("entry", pp->dpp_name)) { |
159#ifdef DOODAD | |
160 if (dt_pid_create_entry_probe(pp->dpp_pr, dtp, ftp, symp) < 0) { 161 return (dt_pid_error(dtp, pcb, dpr, ftp, 162 D_PROC_CREATEFAIL, "failed to create entry probe " 163 "for '%s': %s", func, 164 dtrace_errmsg(dtp, dtrace_errno(dtp)))); 165 } | 160 if (dt_pid_create_entry_probe(pp->dpp_pr, dtp, ftp, symp) < 0) { 161 return (dt_pid_error(dtp, pcb, dpr, ftp, 162 D_PROC_CREATEFAIL, "failed to create entry probe " 163 "for '%s': %s", func, 164 dtrace_errmsg(dtp, dtrace_errno(dtp)))); 165 } |
166#endif | |
167 168 nmatches++; 169 } 170 171 glob = strisglob(pp->dpp_name); 172 if (!glob && nmatches == 0) { 173 off = strtoull(pp->dpp_name, &end, 16); 174 if (*end != '\0') { 175 return (dt_pid_error(dtp, pcb, dpr, ftp, D_PROC_NAME, 176 "'%s' is an invalid probe name", pp->dpp_name)); 177 } 178 179 if (off >= symp->st_size) { 180 return (dt_pid_error(dtp, pcb, dpr, ftp, D_PROC_OFF, 181 "offset 0x%llx outside of function '%s'", 182 (u_longlong_t)off, func)); 183 } 184 | 166 167 nmatches++; 168 } 169 170 glob = strisglob(pp->dpp_name); 171 if (!glob && nmatches == 0) { 172 off = strtoull(pp->dpp_name, &end, 16); 173 if (*end != '\0') { 174 return (dt_pid_error(dtp, pcb, dpr, ftp, D_PROC_NAME, 175 "'%s' is an invalid probe name", pp->dpp_name)); 176 } 177 178 if (off >= symp->st_size) { 179 return (dt_pid_error(dtp, pcb, dpr, ftp, D_PROC_OFF, 180 "offset 0x%llx outside of function '%s'", 181 (u_longlong_t)off, func)); 182 } 183 |
185#ifdef DOODAD | |
186 err = dt_pid_create_offset_probe(pp->dpp_pr, pp->dpp_dtp, ftp, 187 symp, off); | 184 err = dt_pid_create_offset_probe(pp->dpp_pr, pp->dpp_dtp, ftp, 185 symp, off); |
188#endif | |
189 190 if (err == DT_PROC_ERR) { 191 return (dt_pid_error(dtp, pcb, dpr, ftp, 192 D_PROC_CREATEFAIL, "failed to create probe at " 193 "'%s+0x%llx': %s", func, (u_longlong_t)off, 194 dtrace_errmsg(dtp, dtrace_errno(dtp)))); 195 } 196 197 if (err == DT_PROC_ALIGN) { 198 return (dt_pid_error(dtp, pcb, dpr, ftp, D_PROC_ALIGN, 199 "offset 0x%llx is not aligned on an instruction", 200 (u_longlong_t)off)); 201 } 202 203 nmatches++; 204 205 } else if (glob && !isdash) { | 186 187 if (err == DT_PROC_ERR) { 188 return (dt_pid_error(dtp, pcb, dpr, ftp, 189 D_PROC_CREATEFAIL, "failed to create probe at " 190 "'%s+0x%llx': %s", func, (u_longlong_t)off, 191 dtrace_errmsg(dtp, dtrace_errno(dtp)))); 192 } 193 194 if (err == DT_PROC_ALIGN) { 195 return (dt_pid_error(dtp, pcb, dpr, ftp, D_PROC_ALIGN, 196 "offset 0x%llx is not aligned on an instruction", 197 (u_longlong_t)off)); 198 } 199 200 nmatches++; 201 202 } else if (glob && !isdash) { |
206#ifdef DOODAD | |
207 if (dt_pid_create_glob_offset_probes(pp->dpp_pr, 208 pp->dpp_dtp, ftp, symp, pp->dpp_name) < 0) { 209 return (dt_pid_error(dtp, pcb, dpr, ftp, 210 D_PROC_CREATEFAIL, 211 "failed to create offset probes in '%s': %s", func, 212 dtrace_errmsg(dtp, dtrace_errno(dtp)))); 213 } | 203 if (dt_pid_create_glob_offset_probes(pp->dpp_pr, 204 pp->dpp_dtp, ftp, symp, pp->dpp_name) < 0) { 205 return (dt_pid_error(dtp, pcb, dpr, ftp, 206 D_PROC_CREATEFAIL, 207 "failed to create offset probes in '%s': %s", func, 208 dtrace_errmsg(dtp, dtrace_errno(dtp)))); 209 } |
214#endif | |
215 216 nmatches++; 217 } 218 219 pp->dpp_nmatches += nmatches; 220 221 dt_free(dtp, ftp); 222 --- 51 unchanged lines hidden (view full) --- 274 (void) Plmid(pp->dpp_pr, pmp->pr_vaddr, &pp->dpp_lmid); 275#endif 276 277 278 if ((pp->dpp_obj = strrchr(obj, '/')) == NULL) 279 pp->dpp_obj = obj; 280 else 281 pp->dpp_obj++; | 210 211 nmatches++; 212 } 213 214 pp->dpp_nmatches += nmatches; 215 216 dt_free(dtp, ftp); 217 --- 51 unchanged lines hidden (view full) --- 269 (void) Plmid(pp->dpp_pr, pmp->pr_vaddr, &pp->dpp_lmid); 270#endif 271 272 273 if ((pp->dpp_obj = strrchr(obj, '/')) == NULL) 274 pp->dpp_obj = obj; 275 else 276 pp->dpp_obj++; |
282 | |
283#if defined(sun) 284 if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, ".stret1", &sym, 285 NULL) == 0) 286 pp->dpp_stret[0] = sym.st_value; 287 else 288 pp->dpp_stret[0] = 0; 289 290 if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, ".stret2", &sym, --- 9 unchanged lines hidden (view full) --- 300 pp->dpp_stret[2] = 0; 301 302 if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, ".stret8", &sym, 303 NULL) == 0) 304 pp->dpp_stret[3] = sym.st_value; 305 else 306 pp->dpp_stret[3] = 0; 307#else | 277#if defined(sun) 278 if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, ".stret1", &sym, 279 NULL) == 0) 280 pp->dpp_stret[0] = sym.st_value; 281 else 282 pp->dpp_stret[0] = 0; 283 284 if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, ".stret2", &sym, --- 9 unchanged lines hidden (view full) --- 294 pp->dpp_stret[2] = 0; 295 296 if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, ".stret8", &sym, 297 NULL) == 0) 298 pp->dpp_stret[3] = sym.st_value; 299 else 300 pp->dpp_stret[3] = 0; 301#else |
308 if (proc_name2sym(pp->dpp_pr, obj, ".stret1", &sym) == 0) 309 pp->dpp_stret[0] = sym.st_value; 310 else 311 pp->dpp_stret[0] = 0; 312 313 if (proc_name2sym(pp->dpp_pr, obj, ".stret2", &sym) == 0) 314 pp->dpp_stret[1] = sym.st_value; 315 else 316 pp->dpp_stret[1] = 0; 317 318 if (proc_name2sym(pp->dpp_pr, obj, ".stret4", &sym) == 0) 319 pp->dpp_stret[2] = sym.st_value; 320 else 321 pp->dpp_stret[2] = 0; 322 323 if (proc_name2sym(pp->dpp_pr, obj, ".stret8", &sym) == 0) 324 pp->dpp_stret[3] = sym.st_value; 325 else 326 pp->dpp_stret[3] = 0; | 302 pp->dpp_stret[0] = 0; 303 pp->dpp_stret[1] = 0; 304 pp->dpp_stret[2] = 0; 305 pp->dpp_stret[3] = 0; |
327#endif 328 329 dt_dprintf("%s stret %llx %llx %llx %llx\n", obj, 330 (u_longlong_t)pp->dpp_stret[0], (u_longlong_t)pp->dpp_stret[1], 331 (u_longlong_t)pp->dpp_stret[2], (u_longlong_t)pp->dpp_stret[3]); 332 333 /* 334 * If pp->dpp_func contains any globbing meta-characters, we need --- 5 unchanged lines hidden (view full) --- 340 * If we fail to lookup the symbol, try interpreting the 341 * function as the special "-" function that indicates that the 342 * probe name should be interpreted as a absolute virtual 343 * address. If that fails and we were matching a specific 344 * function in a specific module, report the error, otherwise 345 * just fail silently in the hopes that some other object will 346 * contain the desired symbol. 347 */ | 306#endif 307 308 dt_dprintf("%s stret %llx %llx %llx %llx\n", obj, 309 (u_longlong_t)pp->dpp_stret[0], (u_longlong_t)pp->dpp_stret[1], 310 (u_longlong_t)pp->dpp_stret[2], (u_longlong_t)pp->dpp_stret[3]); 311 312 /* 313 * If pp->dpp_func contains any globbing meta-characters, we need --- 5 unchanged lines hidden (view full) --- 319 * If we fail to lookup the symbol, try interpreting the 320 * function as the special "-" function that indicates that the 321 * probe name should be interpreted as a absolute virtual 322 * address. If that fails and we were matching a specific 323 * function in a specific module, report the error, otherwise 324 * just fail silently in the hopes that some other object will 325 * contain the desired symbol. 326 */ |
348#if defined(sun) | |
349 if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, 350 pp->dpp_func, &sym, NULL) != 0) { | 327 if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, 328 pp->dpp_func, &sym, NULL) != 0) { |
351#else 352 if (proc_name2sym(pp->dpp_pr, obj, pp->dpp_func, &sym) != 0) { 353#endif | |
354 if (strcmp("-", pp->dpp_func) == 0) { 355 sym.st_name = 0; 356 sym.st_info = 357 GELF_ST_INFO(STB_LOCAL, STT_FUNC); 358 sym.st_other = 0; 359 sym.st_value = 0; 360#if defined(sun) 361 sym.st_size = Pstatus(pp->dpp_pr)->pr_dmodel == --- 23 unchanged lines hidden (view full) --- 385 * We don't instrument PLTs -- they're dynamically rewritten, 386 * and, so, inherently dicey to instrument. 387 */ 388#ifdef DOODAD 389 if (Ppltdest(pp->dpp_pr, sym.st_value) != NULL) 390 return (0); 391#endif 392 | 329 if (strcmp("-", pp->dpp_func) == 0) { 330 sym.st_name = 0; 331 sym.st_info = 332 GELF_ST_INFO(STB_LOCAL, STT_FUNC); 333 sym.st_other = 0; 334 sym.st_value = 0; 335#if defined(sun) 336 sym.st_size = Pstatus(pp->dpp_pr)->pr_dmodel == --- 23 unchanged lines hidden (view full) --- 360 * We don't instrument PLTs -- they're dynamically rewritten, 361 * and, so, inherently dicey to instrument. 362 */ 363#ifdef DOODAD 364 if (Ppltdest(pp->dpp_pr, sym.st_value) != NULL) 365 return (0); 366#endif 367 |
393#if defined(sun) | |
394 (void) Plookup_by_addr(pp->dpp_pr, sym.st_value, pp->dpp_func, | 368 (void) Plookup_by_addr(pp->dpp_pr, sym.st_value, pp->dpp_func, |
395#else 396 (void) proc_addr2sym(pp->dpp_pr, sym.st_value, pp->dpp_func, 397#endif | |
398 DTRACE_FUNCNAMELEN, &sym); 399 400 return (dt_pid_per_sym(pp, &sym, pp->dpp_func)); 401 } else { | 369 DTRACE_FUNCNAMELEN, &sym); 370 371 return (dt_pid_per_sym(pp, &sym, pp->dpp_func)); 372 } else { |
402#ifdef DOODAD | |
403 uint_t nmatches = pp->dpp_nmatches; 404 405 if (Psymbol_iter_by_addr(pp->dpp_pr, obj, PR_SYMTAB, 406 BIND_ANY | TYPE_FUNC, dt_pid_sym_filt, pp) == 1) 407 return (1); 408 409 if (nmatches == pp->dpp_nmatches) { 410 /* 411 * If we didn't match anything in the PR_SYMTAB, try 412 * the PR_DYNSYM. 413 */ 414 if (Psymbol_iter_by_addr(pp->dpp_pr, obj, PR_DYNSYM, 415 BIND_ANY | TYPE_FUNC, dt_pid_sym_filt, pp) == 1) 416 return (1); 417 } | 373 uint_t nmatches = pp->dpp_nmatches; 374 375 if (Psymbol_iter_by_addr(pp->dpp_pr, obj, PR_SYMTAB, 376 BIND_ANY | TYPE_FUNC, dt_pid_sym_filt, pp) == 1) 377 return (1); 378 379 if (nmatches == pp->dpp_nmatches) { 380 /* 381 * If we didn't match anything in the PR_SYMTAB, try 382 * the PR_DYNSYM. 383 */ 384 if (Psymbol_iter_by_addr(pp->dpp_pr, obj, PR_DYNSYM, 385 BIND_ANY | TYPE_FUNC, dt_pid_sym_filt, pp) == 1) 386 return (1); 387 } |
418#endif | |
419 } 420 421 return (0); 422} 423 424static int 425dt_pid_mod_filt(void *arg, const prmap_t *pmp, const char *obj) 426{ --- 27 unchanged lines hidden (view full) --- 454 return (dt_pid_per_mod(pp, pmp, obj)); 455 456 return (0); 457} 458 459static const prmap_t * 460dt_pid_fix_mod(dtrace_probedesc_t *pdp, struct ps_prochandle *P) 461{ | 388 } 389 390 return (0); 391} 392 393static int 394dt_pid_mod_filt(void *arg, const prmap_t *pmp, const char *obj) 395{ --- 27 unchanged lines hidden (view full) --- 423 return (dt_pid_per_mod(pp, pmp, obj)); 424 425 return (0); 426} 427 428static const prmap_t * 429dt_pid_fix_mod(dtrace_probedesc_t *pdp, struct ps_prochandle *P) 430{ |
462#ifdef DOODAD | |
463 char m[MAXPATHLEN]; | 431 char m[MAXPATHLEN]; |
432#if defined(sun) |
|
464 Lmid_t lmid = PR_LMID_EVERY; | 433 Lmid_t lmid = PR_LMID_EVERY; |
465 const char *obj; | 434#else 435 Lmid_t lmid = 0; |
466#endif | 436#endif |
437 const char *obj; |
|
467 const prmap_t *pmp; 468 | 438 const prmap_t *pmp; 439 |
469#ifdef DOODAD | 440#if defined(sun) |
470 /* 471 * Pick apart the link map from the library name. 472 */ 473 if (strchr(pdp->dtpd_mod, '`') != NULL) { 474 char *end; 475 476 if (strncmp(pdp->dtpd_mod, "LM", 2) != 0 || 477 !isdigit(pdp->dtpd_mod[2])) --- 4 unchanged lines hidden (view full) --- 482 obj = end + 1; 483 484 if (*end != '`' || strchr(obj, '`') != NULL) 485 return (NULL); 486 487 } else { 488 obj = pdp->dtpd_mod; 489 } | 441 /* 442 * Pick apart the link map from the library name. 443 */ 444 if (strchr(pdp->dtpd_mod, '`') != NULL) { 445 char *end; 446 447 if (strncmp(pdp->dtpd_mod, "LM", 2) != 0 || 448 !isdigit(pdp->dtpd_mod[2])) --- 4 unchanged lines hidden (view full) --- 453 obj = end + 1; 454 455 if (*end != '`' || strchr(obj, '`') != NULL) 456 return (NULL); 457 458 } else { 459 obj = pdp->dtpd_mod; 460 } |
461#else 462 obj = pdp->dtpd_mod; 463#endif |
|
490 491 if ((pmp = Plmid_to_map(P, lmid, obj)) == NULL) 492 return (NULL); 493 | 464 465 if ((pmp = Plmid_to_map(P, lmid, obj)) == NULL) 466 return (NULL); 467 |
468#if defined(sun) |
|
494 (void) Pobjname(P, pmp->pr_vaddr, m, sizeof (m)); 495 if ((obj = strrchr(m, '/')) == NULL) 496 obj = &m[0]; 497 else 498 obj++; 499 500 (void) Plmid(P, pmp->pr_vaddr, &lmid); | 469 (void) Pobjname(P, pmp->pr_vaddr, m, sizeof (m)); 470 if ((obj = strrchr(m, '/')) == NULL) 471 obj = &m[0]; 472 else 473 obj++; 474 475 (void) Plmid(P, pmp->pr_vaddr, &lmid); |
476#endif |
|
501 502 dt_pid_objname(pdp->dtpd_mod, sizeof (pdp->dtpd_mod), lmid, obj); | 477 478 dt_pid_objname(pdp->dtpd_mod, sizeof (pdp->dtpd_mod), lmid, obj); |
503#else 504pmp = NULL; 505#endif | |
506 507 return (pmp); 508} 509 510 511static int 512dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, 513 dt_pcb_t *pcb, dt_proc_t *dpr) --- 25 unchanged lines hidden (view full) --- 539 540 if (strcmp(pp.dpp_func, "-") == 0) { 541 const prmap_t *aout, *pmp; 542 543 if (pdp->dtpd_mod[0] == '\0') { 544 pp.dpp_mod = pdp->dtpd_mod; 545 (void) strcpy(pdp->dtpd_mod, "a.out"); 546 } else if (strisglob(pp.dpp_mod) || | 479 480 return (pmp); 481} 482 483 484static int 485dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, 486 dt_pcb_t *pcb, dt_proc_t *dpr) --- 25 unchanged lines hidden (view full) --- 512 513 if (strcmp(pp.dpp_func, "-") == 0) { 514 const prmap_t *aout, *pmp; 515 516 if (pdp->dtpd_mod[0] == '\0') { 517 pp.dpp_mod = pdp->dtpd_mod; 518 (void) strcpy(pdp->dtpd_mod, "a.out"); 519 } else if (strisglob(pp.dpp_mod) || |
547#if defined(sun) | |
548 (aout = Pname_to_map(pp.dpp_pr, "a.out")) == NULL || 549 (pmp = Pname_to_map(pp.dpp_pr, pp.dpp_mod)) == NULL || | 520 (aout = Pname_to_map(pp.dpp_pr, "a.out")) == NULL || 521 (pmp = Pname_to_map(pp.dpp_pr, pp.dpp_mod)) == NULL || |
550#else 551 (aout = proc_name2map(pp.dpp_pr, "a.out")) == NULL || 552 (pmp = proc_name2map(pp.dpp_pr, pp.dpp_mod)) == NULL || 553#endif | |
554 aout->pr_vaddr != pmp->pr_vaddr) { 555 return (dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_LIB, 556 "only the a.out module is valid with the " 557 "'-' function")); 558 } 559 560 if (strisglob(pp.dpp_name)) { 561 return (dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_NAME, 562 "only individual addresses may be specified " 563 "with the '-' function")); 564 } 565 } 566 567 /* 568 * If pp.dpp_mod contains any globbing meta-characters, we need 569 * to iterate over each module and compare its name against the 570 * pattern. An empty module name is treated as '*'. 571 */ | 522 aout->pr_vaddr != pmp->pr_vaddr) { 523 return (dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_LIB, 524 "only the a.out module is valid with the " 525 "'-' function")); 526 } 527 528 if (strisglob(pp.dpp_name)) { 529 return (dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_NAME, 530 "only individual addresses may be specified " 531 "with the '-' function")); 532 } 533 } 534 535 /* 536 * If pp.dpp_mod contains any globbing meta-characters, we need 537 * to iterate over each module and compare its name against the 538 * pattern. An empty module name is treated as '*'. 539 */ |
572#ifdef DOODAD | |
573 if (strisglob(pp.dpp_mod)) { 574 ret = Pobject_iter(pp.dpp_pr, dt_pid_mod_filt, &pp); 575 } else { 576 const prmap_t *pmp; 577 char *obj; 578 579 /* 580 * If we can't find a matching module, don't sweat it -- either --- 4 unchanged lines hidden (view full) --- 585 if ((obj = strchr(pdp->dtpd_mod, '`')) == NULL) 586 obj = pdp->dtpd_mod; 587 else 588 obj++; 589 590 ret = dt_pid_per_mod(&pp, pmp, obj); 591 } 592 } | 540 if (strisglob(pp.dpp_mod)) { 541 ret = Pobject_iter(pp.dpp_pr, dt_pid_mod_filt, &pp); 542 } else { 543 const prmap_t *pmp; 544 char *obj; 545 546 /* 547 * If we can't find a matching module, don't sweat it -- either --- 4 unchanged lines hidden (view full) --- 552 if ((obj = strchr(pdp->dtpd_mod, '`')) == NULL) 553 obj = pdp->dtpd_mod; 554 else 555 obj++; 556 557 ret = dt_pid_per_mod(&pp, pmp, obj); 558 } 559 } |
593#endif | |
594 595 return (ret); 596} 597 598static int 599dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname) 600{ 601 struct ps_prochandle *P = data; --- 9 unchanged lines hidden (view full) --- 611 612 /* 613 * The symbol ___SUNW_dof is for lazy-loaded DOF sections, and 614 * __SUNW_dof is for actively-loaded DOF sections. We try to force 615 * in both types of DOF section since the process may not yet have 616 * run the code to instantiate these providers. 617 */ 618 for (i = 0; i < 2; i++) { | 560 561 return (ret); 562} 563 564static int 565dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname) 566{ 567 struct ps_prochandle *P = data; --- 9 unchanged lines hidden (view full) --- 577 578 /* 579 * The symbol ___SUNW_dof is for lazy-loaded DOF sections, and 580 * __SUNW_dof is for actively-loaded DOF sections. We try to force 581 * in both types of DOF section since the process may not yet have 582 * run the code to instantiate these providers. 583 */ 584 for (i = 0; i < 2; i++) { |
619#if defined(sun) | |
620 if (Pxlookup_by_name(P, PR_LMID_EVERY, oname, syms[i], &sym, 621 &sip) != 0) { | 585 if (Pxlookup_by_name(P, PR_LMID_EVERY, oname, syms[i], &sym, 586 &sip) != 0) { |
622#else 623 if (proc_name2sym(P, oname, syms[i], &sym) != 0) { 624#endif | |
625 continue; 626 } 627 628 if ((mname = strrchr(oname, '/')) == NULL) 629 mname = oname; 630 else 631 mname++; 632 633 dt_dprintf("lookup of %s succeeded for %s\n", syms[i], mname); 634 | 587 continue; 588 } 589 590 if ((mname = strrchr(oname, '/')) == NULL) 591 mname = oname; 592 else 593 mname++; 594 595 dt_dprintf("lookup of %s succeeded for %s\n", syms[i], mname); 596 |
635#ifdef DOODAD | |
636 if (Pread(P, &e_type, sizeof (e_type), pmp->pr_vaddr + 637 offsetof(Elf64_Ehdr, e_type)) != sizeof (e_type)) { 638 dt_dprintf("read of ELF header failed"); 639 continue; 640 } | 597 if (Pread(P, &e_type, sizeof (e_type), pmp->pr_vaddr + 598 offsetof(Elf64_Ehdr, e_type)) != sizeof (e_type)) { 599 dt_dprintf("read of ELF header failed"); 600 continue; 601 } |
641#endif | |
642 643 dh.dofhp_dof = sym.st_value; 644 dh.dofhp_addr = (e_type == ET_EXEC) ? 0 : pmp->pr_vaddr; 645 646 dt_pid_objname(dh.dofhp_mod, sizeof (dh.dofhp_mod), 647#if defined(sun) 648 sip.prs_lmid, mname); 649#else 650 0, mname); 651#endif 652 | 602 603 dh.dofhp_dof = sym.st_value; 604 dh.dofhp_addr = (e_type == ET_EXEC) ? 0 : pmp->pr_vaddr; 605 606 dt_pid_objname(dh.dofhp_mod, sizeof (dh.dofhp_mod), 607#if defined(sun) 608 sip.prs_lmid, mname); 609#else 610 0, mname); 611#endif 612 |
653#ifdef DOODAD | 613#if defined(sun) |
654 if (fd == -1 && 655 (fd = pr_open(P, "/dev/dtrace/helper", O_RDWR, 0)) < 0) { 656 dt_dprintf("pr_open of helper device failed: %s\n", 657 strerror(errno)); 658 return (-1); /* errno is set for us */ 659 } 660 661 if (pr_ioctl(P, fd, DTRACEHIOC_ADDDOF, &dh, sizeof (dh)) < 0) 662 dt_dprintf("DOF was rejected for %s\n", dh.dofhp_mod); 663#endif 664 } 665 | 614 if (fd == -1 && 615 (fd = pr_open(P, "/dev/dtrace/helper", O_RDWR, 0)) < 0) { 616 dt_dprintf("pr_open of helper device failed: %s\n", 617 strerror(errno)); 618 return (-1); /* errno is set for us */ 619 } 620 621 if (pr_ioctl(P, fd, DTRACEHIOC_ADDDOF, &dh, sizeof (dh)) < 0) 622 dt_dprintf("DOF was rejected for %s\n", dh.dofhp_mod); 623#endif 624 } 625 |
666#ifdef DOODAD | 626#if defined(sun) |
667 if (fd != -1) 668 (void) pr_close(P, fd); 669#endif 670 671 return (0); 672} 673 674static int 675dt_pid_create_usdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, 676 dt_pcb_t *pcb, dt_proc_t *dpr) 677{ 678 struct ps_prochandle *P = dpr->dpr_proc; 679 int ret = 0; 680 681 assert(DT_MUTEX_HELD(&dpr->dpr_lock)); | 627 if (fd != -1) 628 (void) pr_close(P, fd); 629#endif 630 631 return (0); 632} 633 634static int 635dt_pid_create_usdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, 636 dt_pcb_t *pcb, dt_proc_t *dpr) 637{ 638 struct ps_prochandle *P = dpr->dpr_proc; 639 int ret = 0; 640 641 assert(DT_MUTEX_HELD(&dpr->dpr_lock)); |
682 683#ifdef DOODAD | 642#if defined(sun) |
684 (void) Pupdate_maps(P); | 643 (void) Pupdate_maps(P); |
644#endif |
|
685 if (Pobject_iter(P, dt_pid_usdt_mapping, P) != 0) { 686 ret = -1; 687 (void) dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_USDT, 688 "failed to instantiate probes for pid %d: %s", 689#if defined(sun) 690 (int)Pstatus(P)->pr_pid, strerror(errno)); 691#else 692 (int)proc_getpid(P), strerror(errno)); 693#endif 694 } | 645 if (Pobject_iter(P, dt_pid_usdt_mapping, P) != 0) { 646 ret = -1; 647 (void) dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_USDT, 648 "failed to instantiate probes for pid %d: %s", 649#if defined(sun) 650 (int)Pstatus(P)->pr_pid, strerror(errno)); 651#else 652 (int)proc_getpid(P), strerror(errno)); 653#endif 654 } |
695#endif | |
696 697 /* 698 * Put the module name in its canonical form. 699 */ 700 (void) dt_pid_fix_mod(pdp, P); 701 702 return (ret); 703} --- 165 unchanged lines hidden --- | 655 656 /* 657 * Put the module name in its canonical form. 658 */ 659 (void) dt_pid_fix_mod(pdp, P); 660 661 return (ret); 662} --- 165 unchanged lines hidden --- |