Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_ctf.c
Show All 21 Lines | |||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/ctf.h> | #include <sys/ctf.h> | ||||
#include <sys/kdb.h> | |||||
#include <sys/linker.h> | |||||
#include <ddb/db_ctf.h> | |||||
/* | /* | ||||
* Note this file is included by both link_elf.c and link_elf_obj.c. | * Note this file is included by both link_elf.c and link_elf_obj.c. | ||||
*/ | */ | ||||
#ifdef DDB_CTF | #ifdef DDB_CTF | ||||
#include <contrib/zlib/zlib.h> | #include <contrib/zlib/zlib.h> | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if (ef->ctfcnt > 0) { | ||||
lc->strcnt = ef->ddbstrcnt; | lc->strcnt = ef->ddbstrcnt; | ||||
lc->nsym = ef->ddbsymcnt; | lc->nsym = ef->ddbsymcnt; | ||||
lc->ctfoffp = (uint32_t **) &ef->ctfoff; | lc->ctfoffp = (uint32_t **) &ef->ctfoff; | ||||
lc->typoffp = (uint32_t **) &ef->typoff; | lc->typoffp = (uint32_t **) &ef->typoff; | ||||
lc->typlenp = &ef->typlen; | lc->typlenp = &ef->typlen; | ||||
return (0); | return (0); | ||||
} | } | ||||
if (panicstr != NULL || kdb_active) | |||||
return (ENXIO); | |||||
/* | /* | ||||
* We need to try reading the CTF data. Flag no CTF data present | * We need to try reading the CTF data. Flag no CTF data present | ||||
* by default and if we actually succeed in reading it, we'll | * by default and if we actually succeed in reading it, we'll | ||||
* update ctfcnt to the number of bytes read. | * update ctfcnt to the number of bytes read. | ||||
*/ | */ | ||||
ef->ctfcnt = -1; | ef->ctfcnt = -1; | ||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, lf->pathname); | NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, lf->pathname); | ||||
▲ Show 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | if (ctftab != NULL) | ||||
free(ctftab, M_LINKER); | free(ctftab, M_LINKER); | ||||
if (raw != NULL) | if (raw != NULL) | ||||
free(raw, M_LINKER); | free(raw, M_LINKER); | ||||
#else | #else | ||||
error = EOPNOTSUPP; | error = EOPNOTSUPP; | ||||
#endif | #endif | ||||
return (error); | return (error); | ||||
} | |||||
static int | |||||
link_elf_ctf_get_ddb(linker_file_t lf, linker_ctf_t *lc) | |||||
{ | |||||
elf_file_t ef = (elf_file_t)lf; | |||||
/* | |||||
* Check whether CTF data was loaded or if a | |||||
* previous loading attempt failed (ctfcnt == -1). | |||||
*/ | |||||
if (ef->ctfcnt <= 0) { | |||||
return (ENOENT); | |||||
} | |||||
lc->ctftab = ef->ctftab; | |||||
lc->ctfcnt = ef->ctfcnt; | |||||
lc->symtab = ef->ddbsymtab; | |||||
lc->strtab = ef->ddbstrtab; | |||||
lc->strcnt = ef->ddbstrcnt; | |||||
lc->nsym = ef->ddbsymcnt; | |||||
return (0); | |||||
} | |||||
static int | |||||
link_elf_ctf_lookup_typename(linker_file_t lf, linker_ctf_t *lc, | |||||
const char *typename) | |||||
{ | |||||
if (link_elf_ctf_get_ddb(lf, lc)) | |||||
return (ENOENT); | |||||
return (db_ctf_lookup_typename(lc, typename) ? 0 : ENOENT); | |||||
} | } |