dt_module.c (256281) | dt_module.c (268578) |
---|---|
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 --- 8 unchanged lines hidden (view full) --- 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 24 */ | 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 --- 8 unchanged lines hidden (view full) --- 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 24 */ |
25/* 26 * Copyright (c) 2013, Joyent, Inc. All rights reserved. 27 */ |
|
25 26#include <sys/types.h> 27#if defined(sun) 28#include <sys/modctl.h> 29#include <sys/kobj.h> 30#include <sys/kobj_impl.h> 31#include <sys/sysmacros.h> 32#include <sys/elf.h> --- 12 unchanged lines hidden (view full) --- 45#include <stdlib.h> 46#include <libelf.h> 47#include <limits.h> 48#include <assert.h> 49#include <errno.h> 50#include <dirent.h> 51#if !defined(sun) 52#include <fcntl.h> | 28 29#include <sys/types.h> 30#if defined(sun) 31#include <sys/modctl.h> 32#include <sys/kobj.h> 33#include <sys/kobj_impl.h> 34#include <sys/sysmacros.h> 35#include <sys/elf.h> --- 12 unchanged lines hidden (view full) --- 48#include <stdlib.h> 49#include <libelf.h> 50#include <limits.h> 51#include <assert.h> 52#include <errno.h> 53#include <dirent.h> 54#if !defined(sun) 55#include <fcntl.h> |
56#include <libproc_compat.h> |
|
53#endif 54 55#include <dt_strtab.h> 56#include <dt_module.h> 57#include <dt_impl.h> 58 59static const char *dt_module_strtab; /* active strtab for qsort callbacks */ 60 --- 396 unchanged lines hidden (view full) --- 457 dt_module_symsort64, 458 dt_module_symname64, 459 dt_module_symaddr64 460}; 461 462dt_module_t * 463dt_module_create(dtrace_hdl_t *dtp, const char *name) 464{ | 57#endif 58 59#include <dt_strtab.h> 60#include <dt_module.h> 61#include <dt_impl.h> 62 63static const char *dt_module_strtab; /* active strtab for qsort callbacks */ 64 --- 396 unchanged lines hidden (view full) --- 461 dt_module_symsort64, 462 dt_module_symname64, 463 dt_module_symaddr64 464}; 465 466dt_module_t * 467dt_module_create(dtrace_hdl_t *dtp, const char *name) 468{ |
469 long pid; 470 char *eptr; 471 dt_ident_t *idp; |
|
465 uint_t h = dt_strtab_hash(name, NULL) % dtp->dt_modbuckets; 466 dt_module_t *dmp; 467 468 for (dmp = dtp->dt_mods[h]; dmp != NULL; dmp = dmp->dm_next) { 469 if (strcmp(dmp->dm_name, name) == 0) 470 return (dmp); 471 } 472 --- 7 unchanged lines hidden (view full) --- 480 dtp->dt_mods[h] = dmp; 481 dtp->dt_nmods++; 482 483 if (dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_LP64) 484 dmp->dm_ops = &dt_modops_64; 485 else 486 dmp->dm_ops = &dt_modops_32; 487 | 472 uint_t h = dt_strtab_hash(name, NULL) % dtp->dt_modbuckets; 473 dt_module_t *dmp; 474 475 for (dmp = dtp->dt_mods[h]; dmp != NULL; dmp = dmp->dm_next) { 476 if (strcmp(dmp->dm_name, name) == 0) 477 return (dmp); 478 } 479 --- 7 unchanged lines hidden (view full) --- 487 dtp->dt_mods[h] = dmp; 488 dtp->dt_nmods++; 489 490 if (dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_LP64) 491 dmp->dm_ops = &dt_modops_64; 492 else 493 dmp->dm_ops = &dt_modops_32; 494 |
495 /* 496 * Modules for userland processes are special. They always refer to a 497 * specific process and have a copy of their CTF data from a specific 498 * instant in time. Any dt_module_t that begins with 'pid' is a module 499 * for a specific process, much like how any probe description that 500 * begins with 'pid' is special. pid123 refers to process 123. A module 501 * that is just 'pid' refers specifically to pid$target. This is 502 * generally done as D does not currently allow for macros to be 503 * evaluated when working with types. 504 */ 505 if (strncmp(dmp->dm_name, "pid", 3) == 0) { 506 errno = 0; 507 if (dmp->dm_name[3] == '\0') { 508 idp = dt_idhash_lookup(dtp->dt_macros, "target"); 509 if (idp != NULL && idp->di_id != 0) 510 dmp->dm_pid = idp->di_id; 511 } else { 512 pid = strtol(dmp->dm_name + 3, &eptr, 10); 513 if (errno == 0 && *eptr == '\0') 514 dmp->dm_pid = (pid_t)pid; 515 else 516 dt_dprintf("encountered malformed pid " 517 "module: %s\n", dmp->dm_name); 518 } 519 } 520 |
|
488 return (dmp); 489} 490 491dt_module_t * 492dt_module_lookup_by_name(dtrace_hdl_t *dtp, const char *name) 493{ 494 uint_t h = dt_strtab_hash(name, NULL) % dtp->dt_modbuckets; 495 dt_module_t *dmp; --- 53 unchanged lines hidden (view full) --- 549 ctsp->cts_size = dp->d_size; 550 551 dt_dprintf("loaded %s [%s] (%lu bytes)\n", 552 dmp->dm_name, ctsp->cts_name, (ulong_t)ctsp->cts_size); 553 554 return (0); 555} 556 | 521 return (dmp); 522} 523 524dt_module_t * 525dt_module_lookup_by_name(dtrace_hdl_t *dtp, const char *name) 526{ 527 uint_t h = dt_strtab_hash(name, NULL) % dtp->dt_modbuckets; 528 dt_module_t *dmp; --- 53 unchanged lines hidden (view full) --- 582 ctsp->cts_size = dp->d_size; 583 584 dt_dprintf("loaded %s [%s] (%lu bytes)\n", 585 dmp->dm_name, ctsp->cts_name, (ulong_t)ctsp->cts_size); 586 587 return (0); 588} 589 |
590typedef struct dt_module_cb_arg { 591 struct ps_prochandle *dpa_proc; 592 dtrace_hdl_t *dpa_dtp; 593 dt_module_t *dpa_dmp; 594 uint_t dpa_count; 595} dt_module_cb_arg_t; 596 597/* ARGSUSED */ 598static int 599dt_module_load_proc_count(void *arg, const prmap_t *prmap, const char *obj) 600{ 601 ctf_file_t *fp; 602 dt_module_cb_arg_t *dcp = arg; 603 604 /* Try to grab a ctf container if it exists */ 605 fp = Pname_to_ctf(dcp->dpa_proc, obj); 606 if (fp != NULL) 607 dcp->dpa_count++; 608 return (0); 609} 610 611/* ARGSUSED */ 612static int 613dt_module_load_proc_build(void *arg, const prmap_t *prmap, const char *obj) 614{ 615 ctf_file_t *fp; 616 char buf[MAXPATHLEN], *p; 617 dt_module_cb_arg_t *dcp = arg; 618 int count = dcp->dpa_count; 619 Lmid_t lmid; 620 621 fp = Pname_to_ctf(dcp->dpa_proc, obj); 622 if (fp == NULL) 623 return (0); 624 fp = ctf_dup(fp); 625 if (fp == NULL) 626 return (0); 627 dcp->dpa_dmp->dm_libctfp[count] = fp; 628 /* 629 * While it'd be nice to simply use objname here, because of our prior 630 * actions we'll always get a resolved object name to its on disk file. 631 * Like the pid provider, we need to tell a bit of a lie here. The type 632 * that the user thinks of is in terms of the libraries they requested, 633 * eg. libc.so.1, they don't care about the fact that it's 634 * libc_hwcap.so.1. 635 */ 636 (void) Pobjname(dcp->dpa_proc, prmap->pr_vaddr, buf, sizeof (buf)); 637 if ((p = strrchr(buf, '/')) == NULL) 638 p = buf; 639 else 640 p++; 641 642 /* 643 * If for some reason we can't find a link map id for this module, which 644 * would be really quite weird. We instead just say the link map id is 645 * zero. 646 */ 647 if (Plmid(dcp->dpa_proc, prmap->pr_vaddr, &lmid) != 0) 648 lmid = 0; 649 650 if (lmid == 0) 651 dcp->dpa_dmp->dm_libctfn[count] = strdup(p); 652 else 653 (void) asprintf(&dcp->dpa_dmp->dm_libctfn[count], 654 "LM%x`%s", lmid, p); 655 if (dcp->dpa_dmp->dm_libctfn[count] == NULL) 656 return (1); 657 ctf_setspecific(fp, dcp->dpa_dmp); 658 dcp->dpa_count++; 659 return (0); 660} 661 662/* 663 * We've been asked to load data that belongs to another process. As such we're 664 * going to pgrab it at this instant, load everything that we might ever care 665 * about, and then drive on. The reason for this is that the process that we're 666 * interested in might be changing. As long as we have grabbed it, then this 667 * can't be a problem for us. 668 * 669 * For now, we're actually going to punt on most things and just try to get CTF 670 * data, nothing else. Basically this is only useful as a source of type 671 * information, we can't go and do the stacktrace lookups, etc. 672 */ 673static int 674dt_module_load_proc(dtrace_hdl_t *dtp, dt_module_t *dmp) 675{ 676 struct ps_prochandle *p; 677 dt_module_cb_arg_t arg; 678 679 /* 680 * Note that on success we do not release this hold. We must hold this 681 * for our life time. 682 */ 683 p = dt_proc_grab(dtp, dmp->dm_pid, 0, PGRAB_RDONLY | PGRAB_FORCE); 684 if (p == NULL) { 685 dt_dprintf("failed to grab pid: %d\n", (int)dmp->dm_pid); 686 return (dt_set_errno(dtp, EDT_CANTLOAD)); 687 } 688 dt_proc_lock(dtp, p); 689 690 arg.dpa_proc = p; 691 arg.dpa_dtp = dtp; 692 arg.dpa_dmp = dmp; 693 arg.dpa_count = 0; 694 if (Pobject_iter_resolved(p, dt_module_load_proc_count, &arg) != 0) { 695 dt_dprintf("failed to iterate objects\n"); 696 dt_proc_release(dtp, p); 697 return (dt_set_errno(dtp, EDT_CANTLOAD)); 698 } 699 700 if (arg.dpa_count == 0) { 701 dt_dprintf("no ctf data present\n"); 702 dt_proc_unlock(dtp, p); 703 dt_proc_release(dtp, p); 704 return (dt_set_errno(dtp, EDT_CANTLOAD)); 705 } 706 707 dmp->dm_libctfp = malloc(sizeof (ctf_file_t *) * arg.dpa_count); 708 if (dmp->dm_libctfp == NULL) { 709 dt_proc_unlock(dtp, p); 710 dt_proc_release(dtp, p); 711 return (dt_set_errno(dtp, EDT_NOMEM)); 712 } 713 bzero(dmp->dm_libctfp, sizeof (ctf_file_t *) * arg.dpa_count); 714 715 dmp->dm_libctfn = malloc(sizeof (char *) * arg.dpa_count); 716 if (dmp->dm_libctfn == NULL) { 717 free(dmp->dm_libctfp); 718 dt_proc_unlock(dtp, p); 719 dt_proc_release(dtp, p); 720 return (dt_set_errno(dtp, EDT_NOMEM)); 721 } 722 bzero(dmp->dm_libctfn, sizeof (char *) * arg.dpa_count); 723 724 dmp->dm_nctflibs = arg.dpa_count; 725 726 arg.dpa_count = 0; 727 if (Pobject_iter_resolved(p, dt_module_load_proc_build, &arg) != 0) { 728 dt_proc_unlock(dtp, p); 729 dt_module_unload(dtp, dmp); 730 dt_proc_release(dtp, p); 731 return (dt_set_errno(dtp, EDT_CANTLOAD)); 732 } 733 assert(arg.dpa_count == dmp->dm_nctflibs); 734 dt_dprintf("loaded %d ctf modules for pid %d\n", arg.dpa_count, 735 (int)dmp->dm_pid); 736 737 dt_proc_unlock(dtp, p); 738 dt_proc_release(dtp, p); 739 dmp->dm_flags |= DT_DM_LOADED; 740 741 return (0); 742} 743 |
|
557int 558dt_module_load(dtrace_hdl_t *dtp, dt_module_t *dmp) 559{ 560 if (dmp->dm_flags & DT_DM_LOADED) 561 return (0); /* module is already loaded */ 562 | 744int 745dt_module_load(dtrace_hdl_t *dtp, dt_module_t *dmp) 746{ 747 if (dmp->dm_flags & DT_DM_LOADED) 748 return (0); /* module is already loaded */ 749 |
750 if (dmp->dm_pid != 0) 751 return (dt_module_load_proc(dtp, dmp)); 752 |
|
563 dmp->dm_ctdata.cts_name = ".SUNW_ctf"; 564 dmp->dm_ctdata.cts_type = SHT_PROGBITS; 565 dmp->dm_ctdata.cts_flags = 0; 566 dmp->dm_ctdata.cts_data = NULL; 567 dmp->dm_ctdata.cts_size = 0; 568 dmp->dm_ctdata.cts_entsize = 0; 569 dmp->dm_ctdata.cts_offset = 0; 570 --- 69 unchanged lines hidden (view full) --- 640 641 dt_dprintf("sorted %s [%s] (%u symbols)\n", 642 dmp->dm_name, dmp->dm_symtab.cts_name, dmp->dm_aslen); 643 644 dmp->dm_flags |= DT_DM_LOADED; 645 return (0); 646} 647 | 753 dmp->dm_ctdata.cts_name = ".SUNW_ctf"; 754 dmp->dm_ctdata.cts_type = SHT_PROGBITS; 755 dmp->dm_ctdata.cts_flags = 0; 756 dmp->dm_ctdata.cts_data = NULL; 757 dmp->dm_ctdata.cts_size = 0; 758 dmp->dm_ctdata.cts_entsize = 0; 759 dmp->dm_ctdata.cts_offset = 0; 760 --- 69 unchanged lines hidden (view full) --- 830 831 dt_dprintf("sorted %s [%s] (%u symbols)\n", 832 dmp->dm_name, dmp->dm_symtab.cts_name, dmp->dm_aslen); 833 834 dmp->dm_flags |= DT_DM_LOADED; 835 return (0); 836} 837 |
838int 839dt_module_hasctf(dtrace_hdl_t *dtp, dt_module_t *dmp) 840{ 841 if (dmp->dm_pid != 0 && dmp->dm_nctflibs > 0) 842 return (1); 843 return (dt_module_getctf(dtp, dmp) != NULL); 844} 845 |
|
648ctf_file_t * 649dt_module_getctf(dtrace_hdl_t *dtp, dt_module_t *dmp) 650{ 651 const char *parent; 652 dt_module_t *pmp; 653 ctf_file_t *pfp; 654 int model; 655 --- 57 unchanged lines hidden (view full) --- 713 dmp->dm_ctfp = NULL; 714 return (NULL); 715} 716 717/*ARGSUSED*/ 718void 719dt_module_unload(dtrace_hdl_t *dtp, dt_module_t *dmp) 720{ | 846ctf_file_t * 847dt_module_getctf(dtrace_hdl_t *dtp, dt_module_t *dmp) 848{ 849 const char *parent; 850 dt_module_t *pmp; 851 ctf_file_t *pfp; 852 int model; 853 --- 57 unchanged lines hidden (view full) --- 911 dmp->dm_ctfp = NULL; 912 return (NULL); 913} 914 915/*ARGSUSED*/ 916void 917dt_module_unload(dtrace_hdl_t *dtp, dt_module_t *dmp) 918{ |
919 int i; 920 |
|
721 ctf_close(dmp->dm_ctfp); 722 dmp->dm_ctfp = NULL; 723 724#if !defined(sun) 725 if (dmp->dm_ctdata.cts_data != NULL) { 726 free(dmp->dm_ctdata.cts_data); 727 } 728 if (dmp->dm_symtab.cts_data != NULL) { 729 free(dmp->dm_symtab.cts_data); 730 } 731 if (dmp->dm_strtab.cts_data != NULL) { 732 free(dmp->dm_strtab.cts_data); 733 } 734#endif 735 | 921 ctf_close(dmp->dm_ctfp); 922 dmp->dm_ctfp = NULL; 923 924#if !defined(sun) 925 if (dmp->dm_ctdata.cts_data != NULL) { 926 free(dmp->dm_ctdata.cts_data); 927 } 928 if (dmp->dm_symtab.cts_data != NULL) { 929 free(dmp->dm_symtab.cts_data); 930 } 931 if (dmp->dm_strtab.cts_data != NULL) { 932 free(dmp->dm_strtab.cts_data); 933 } 934#endif 935 |
936 if (dmp->dm_libctfp != NULL) { 937 for (i = 0; i < dmp->dm_nctflibs; i++) { 938 ctf_close(dmp->dm_libctfp[i]); 939 free(dmp->dm_libctfn[i]); 940 } 941 free(dmp->dm_libctfp); 942 free(dmp->dm_libctfn); 943 dmp->dm_libctfp = NULL; 944 dmp->dm_nctflibs = 0; 945 } 946 |
|
736 bzero(&dmp->dm_ctdata, sizeof (ctf_sect_t)); 737 bzero(&dmp->dm_symtab, sizeof (ctf_sect_t)); 738 bzero(&dmp->dm_strtab, sizeof (ctf_sect_t)); 739 740 if (dmp->dm_symbuckets != NULL) { 741 free(dmp->dm_symbuckets); 742 dmp->dm_symbuckets = NULL; 743 } --- 29 unchanged lines hidden (view full) --- 773 if (dmp->dm_extern != NULL) { 774 dt_idhash_destroy(dmp->dm_extern); 775 dmp->dm_extern = NULL; 776 } 777 778 (void) elf_end(dmp->dm_elf); 779 dmp->dm_elf = NULL; 780 | 947 bzero(&dmp->dm_ctdata, sizeof (ctf_sect_t)); 948 bzero(&dmp->dm_symtab, sizeof (ctf_sect_t)); 949 bzero(&dmp->dm_strtab, sizeof (ctf_sect_t)); 950 951 if (dmp->dm_symbuckets != NULL) { 952 free(dmp->dm_symbuckets); 953 dmp->dm_symbuckets = NULL; 954 } --- 29 unchanged lines hidden (view full) --- 984 if (dmp->dm_extern != NULL) { 985 dt_idhash_destroy(dmp->dm_extern); 986 dmp->dm_extern = NULL; 987 } 988 989 (void) elf_end(dmp->dm_elf); 990 dmp->dm_elf = NULL; 991 |
992 dmp->dm_pid = 0; 993 |
|
781 dmp->dm_flags &= ~DT_DM_LOADED; 782} 783 784void 785dt_module_destroy(dtrace_hdl_t *dtp, dt_module_t *dmp) 786{ 787 uint_t h = dt_strtab_hash(dmp->dm_name, NULL) % dtp->dt_modbuckets; 788 dt_module_t **dmpp = &dtp->dt_mods[h]; --- 72 unchanged lines hidden (view full) --- 861dt_module_modelname(dt_module_t *dmp) 862{ 863 if (dmp->dm_ops == &dt_modops_64) 864 return ("64-bit"); 865 else 866 return ("32-bit"); 867} 868 | 994 dmp->dm_flags &= ~DT_DM_LOADED; 995} 996 997void 998dt_module_destroy(dtrace_hdl_t *dtp, dt_module_t *dmp) 999{ 1000 uint_t h = dt_strtab_hash(dmp->dm_name, NULL) % dtp->dt_modbuckets; 1001 dt_module_t **dmpp = &dtp->dt_mods[h]; --- 72 unchanged lines hidden (view full) --- 1074dt_module_modelname(dt_module_t *dmp) 1075{ 1076 if (dmp->dm_ops == &dt_modops_64) 1077 return ("64-bit"); 1078 else 1079 return ("32-bit"); 1080} 1081 |
1082/* ARGSUSED */ 1083int 1084dt_module_getlibid(dtrace_hdl_t *dtp, dt_module_t *dmp, const ctf_file_t *fp) 1085{ 1086 int i; 1087 1088 for (i = 0; i < dmp->dm_nctflibs; i++) { 1089 if (dmp->dm_libctfp[i] == fp) 1090 return (i); 1091 } 1092 1093 return (-1); 1094} 1095 1096/* ARGSUSED */ 1097ctf_file_t * 1098dt_module_getctflib(dtrace_hdl_t *dtp, dt_module_t *dmp, const char *name) 1099{ 1100 int i; 1101 1102 for (i = 0; i < dmp->dm_nctflibs; i++) { 1103 if (strcmp(dmp->dm_libctfn[i], name) == 0) 1104 return (dmp->dm_libctfp[i]); 1105 } 1106 1107 return (NULL); 1108} 1109 |
|
869/* 870 * Update our module cache by adding an entry for the specified module 'name'. 871 * We create the dt_module_t and populate it using /system/object/<name>/. 872 * 873 * On FreeBSD, the module name is passed as the full module file name, 874 * including the path. 875 */ 876static void --- 412 unchanged lines hidden (view full) --- 1289int 1290dtrace_lookup_by_type(dtrace_hdl_t *dtp, const char *object, const char *name, 1291 dtrace_typeinfo_t *tip) 1292{ 1293 dtrace_typeinfo_t ti; 1294 dt_module_t *dmp; 1295 int found = 0; 1296 ctf_id_t id; | 1110/* 1111 * Update our module cache by adding an entry for the specified module 'name'. 1112 * We create the dt_module_t and populate it using /system/object/<name>/. 1113 * 1114 * On FreeBSD, the module name is passed as the full module file name, 1115 * including the path. 1116 */ 1117static void --- 412 unchanged lines hidden (view full) --- 1530int 1531dtrace_lookup_by_type(dtrace_hdl_t *dtp, const char *object, const char *name, 1532 dtrace_typeinfo_t *tip) 1533{ 1534 dtrace_typeinfo_t ti; 1535 dt_module_t *dmp; 1536 int found = 0; 1537 ctf_id_t id; |
1297 uint_t n; | 1538 uint_t n, i; |
1298 int justone; | 1539 int justone; |
1540 ctf_file_t *fp; 1541 char *buf, *p, *q; |
|
1299 1300 uint_t mask = 0; /* mask of dt_module flags to match */ 1301 uint_t bits = 0; /* flag bits that must be present */ 1302 1303 if (object != DTRACE_OBJ_EVERY && 1304 object != DTRACE_OBJ_KMODS && 1305 object != DTRACE_OBJ_UMODS) { 1306 if ((dmp = dt_module_from_object(dtp, object)) == NULL) 1307 return (-1); /* dt_errno is set for us */ 1308 1309 if (dt_module_load(dtp, dmp) == -1) 1310 return (-1); /* dt_errno is set for us */ 1311 n = 1; 1312 justone = 1; | 1542 1543 uint_t mask = 0; /* mask of dt_module flags to match */ 1544 uint_t bits = 0; /* flag bits that must be present */ 1545 1546 if (object != DTRACE_OBJ_EVERY && 1547 object != DTRACE_OBJ_KMODS && 1548 object != DTRACE_OBJ_UMODS) { 1549 if ((dmp = dt_module_from_object(dtp, object)) == NULL) 1550 return (-1); /* dt_errno is set for us */ 1551 1552 if (dt_module_load(dtp, dmp) == -1) 1553 return (-1); /* dt_errno is set for us */ 1554 n = 1; 1555 justone = 1; |
1313 | |
1314 } else { 1315 if (object == DTRACE_OBJ_KMODS) 1316 mask = bits = DT_DM_KERNEL; 1317 else if (object == DTRACE_OBJ_UMODS) 1318 mask = DT_DM_KERNEL; 1319 1320 dmp = dt_list_next(&dtp->dt_modlist); 1321 n = dtp->dt_nmods; --- 7 unchanged lines hidden (view full) --- 1329 if ((dmp->dm_flags & mask) != bits) 1330 continue; /* failed to match required attributes */ 1331 1332 /* 1333 * If we can't load the CTF container, continue on to the next 1334 * module. If our search was scoped to only one module then 1335 * return immediately leaving dt_errno unmodified. 1336 */ | 1556 } else { 1557 if (object == DTRACE_OBJ_KMODS) 1558 mask = bits = DT_DM_KERNEL; 1559 else if (object == DTRACE_OBJ_UMODS) 1560 mask = DT_DM_KERNEL; 1561 1562 dmp = dt_list_next(&dtp->dt_modlist); 1563 n = dtp->dt_nmods; --- 7 unchanged lines hidden (view full) --- 1571 if ((dmp->dm_flags & mask) != bits) 1572 continue; /* failed to match required attributes */ 1573 1574 /* 1575 * If we can't load the CTF container, continue on to the next 1576 * module. If our search was scoped to only one module then 1577 * return immediately leaving dt_errno unmodified. 1578 */ |
1337 if (dt_module_getctf(dtp, dmp) == NULL) { | 1579 if (dt_module_hasctf(dtp, dmp) == 0) { |
1338 if (justone) 1339 return (-1); 1340 continue; 1341 } 1342 1343 /* 1344 * Look up the type in the module's CTF container. If our 1345 * match is a forward declaration tag, save this choice in 1346 * 'tip' and keep going in the hope that we will locate the 1347 * underlying structure definition. Otherwise just return. 1348 */ | 1580 if (justone) 1581 return (-1); 1582 continue; 1583 } 1584 1585 /* 1586 * Look up the type in the module's CTF container. If our 1587 * match is a forward declaration tag, save this choice in 1588 * 'tip' and keep going in the hope that we will locate the 1589 * underlying structure definition. Otherwise just return. 1590 */ |
1349 if ((id = ctf_lookup_by_name(dmp->dm_ctfp, name)) != CTF_ERR) { | 1591 if (dmp->dm_pid == 0) { 1592 id = ctf_lookup_by_name(dmp->dm_ctfp, name); 1593 fp = dmp->dm_ctfp; 1594 } else { 1595 if ((p = strchr(name, '`')) != NULL) { 1596 buf = strdup(name); 1597 if (buf == NULL) 1598 return (dt_set_errno(dtp, EDT_NOMEM)); 1599 p = strchr(buf, '`'); 1600 if ((q = strchr(p + 1, '`')) != NULL) 1601 p = q; 1602 *p = '\0'; 1603 fp = dt_module_getctflib(dtp, dmp, buf); 1604 if (fp == NULL || (id = ctf_lookup_by_name(fp, 1605 p + 1)) == CTF_ERR) 1606 id = CTF_ERR; 1607 free(buf); 1608 } else { 1609 for (i = 0; i < dmp->dm_nctflibs; i++) { 1610 fp = dmp->dm_libctfp[i]; 1611 id = ctf_lookup_by_name(fp, name); 1612 if (id != CTF_ERR) 1613 break; 1614 } 1615 } 1616 } 1617 if (id != CTF_ERR) { |
1350 tip->dtt_object = dmp->dm_name; | 1618 tip->dtt_object = dmp->dm_name; |
1351 tip->dtt_ctfp = dmp->dm_ctfp; | 1619 tip->dtt_ctfp = fp; |
1352 tip->dtt_type = id; | 1620 tip->dtt_type = id; |
1353 1354 if (ctf_type_kind(dmp->dm_ctfp, ctf_type_resolve( 1355 dmp->dm_ctfp, id)) != CTF_K_FORWARD) | 1621 if (ctf_type_kind(fp, ctf_type_resolve(fp, id)) != 1622 CTF_K_FORWARD) |
1356 return (0); 1357 1358 found++; 1359 } 1360 } 1361 1362 if (found == 0) 1363 return (dt_set_errno(dtp, EDT_NOTYPE)); --- 5 unchanged lines hidden (view full) --- 1369dtrace_symbol_type(dtrace_hdl_t *dtp, const GElf_Sym *symp, 1370 const dtrace_syminfo_t *sip, dtrace_typeinfo_t *tip) 1371{ 1372 dt_module_t *dmp; 1373 1374 tip->dtt_object = NULL; 1375 tip->dtt_ctfp = NULL; 1376 tip->dtt_type = CTF_ERR; | 1623 return (0); 1624 1625 found++; 1626 } 1627 } 1628 1629 if (found == 0) 1630 return (dt_set_errno(dtp, EDT_NOTYPE)); --- 5 unchanged lines hidden (view full) --- 1636dtrace_symbol_type(dtrace_hdl_t *dtp, const GElf_Sym *symp, 1637 const dtrace_syminfo_t *sip, dtrace_typeinfo_t *tip) 1638{ 1639 dt_module_t *dmp; 1640 1641 tip->dtt_object = NULL; 1642 tip->dtt_ctfp = NULL; 1643 tip->dtt_type = CTF_ERR; |
1644 tip->dtt_flags = 0; |
|
1377 1378 if ((dmp = dt_module_lookup_by_name(dtp, sip->dts_object)) == NULL) 1379 return (dt_set_errno(dtp, EDT_NOMOD)); 1380 1381 if (symp->st_shndx == SHN_UNDEF && dmp->dm_extern != NULL) { 1382 dt_ident_t *idp = 1383 dt_idhash_lookup(dmp->dm_extern, sip->dts_name); 1384 --- 83 unchanged lines hidden --- | 1645 1646 if ((dmp = dt_module_lookup_by_name(dtp, sip->dts_object)) == NULL) 1647 return (dt_set_errno(dtp, EDT_NOMOD)); 1648 1649 if (symp->st_shndx == SHN_UNDEF && dmp->dm_extern != NULL) { 1650 dt_ident_t *idp = 1651 dt_idhash_lookup(dmp->dm_extern, sip->dts_name); 1652 --- 83 unchanged lines hidden --- |