Index: share/mk/sys.mk =================================================================== --- share/mk/sys.mk (revision 239689) +++ share/mk/sys.mk (working copy) @@ -262,7 +262,7 @@ ${CTFCONVERT_CMD} .s.o: - ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} + ${AS} -mfpu=softvfp ${AFLAGS} -o ${.TARGET} ${.IMPSRC} ${CTFCONVERT_CMD} # XXX not -j safe Index: cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h =================================================================== --- cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h (revision 239689) +++ cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h (working copy) @@ -349,6 +349,7 @@ /* ctf.c */ caddr_t ctf_gen(iiburst_t *, size_t *, int); tdata_t *ctf_load(char *, caddr_t, size_t, symit_data_t *, char *); +int ctf_load_target_spec(char *); /* iidesc.c */ iidesc_t *iidesc_new(char *); Index: cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c =================================================================== --- cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c (revision 239689) +++ cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c (working copy) @@ -30,8 +30,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -52,6 +54,9 @@ #define CTF_BUF_CHUNK_SIZE (64 * 1024) #define RES_BUF_CHUNK_SIZE (64 * 1024) +#define SPEC_BUF_SIZE 1024 +#define SPEC_MAX_FIELDS 16 + struct ctf_buf { strtab_t ctb_strtab; /* string table */ caddr_t ctb_base; /* pointer to base of buffer */ @@ -73,7 +78,42 @@ #define SWAP_32(x) (x) = BSWAP_32(x) static int target_requires_swap; +static int compactPresentation; +/* + * In order to prevent frequent small-size allocation + * we keep pre-allocated scratch-pad that should be used for + * converting host representation to target one + */ +struct ctf_struct_spec { + size_t size; /* structure size */ + size_t field_offset[SPEC_MAX_FIELDS]; /* Offsets for fields */ + char *scratchpad; /* memory area of size bytes */ +}; + +typedef enum { + CTF_SPEC_STYPE = 0, + CTF_SPEC_TYPE, + CTF_SPEC_ARRAY, + CTF_SPEC_MEMBER, + CTF_SPEC_LMEMBER, + CTF_SPEC_ENUM, + CTF_SPEC_MAX, +} ctf_spec_type_t; + +static const char* ctf_spec_type_name[] = +{ + "ctf_stype_t", + "ctf_type_t", + "ctf_array_t", + "ctf_member_t", + "ctf_lmember_t", + "ctf_enum_t" +}; + +static struct ctf_struct_spec target_specs[CTF_SPEC_MAX]; +static uint_t ctf_spec_mask = 0; + /*PRINTFLIKE1*/ static void parseterminate(const char *fmt, ...) @@ -142,6 +182,32 @@ } } +static void +ctf_scratchpad_reset(ctf_spec_type_t t) +{ + + bzero(target_specs[t].scratchpad, target_specs[t].size); +} + +static void +ctf_scratchpad_write(ctf_spec_type_t t, int field, void const *p, size_t n) +{ + size_t offset = target_specs[t].field_offset[field]; + + if (offset + n > target_specs[t].size) + terminate("Can't write outside scratchpad, type %s, field %d", + ctf_spec_type_name[t]); + + bcopy(p, target_specs[t].scratchpad + offset, n); +} + +static void +ctf_scratchpad_flush(ctf_buf_t *b, ctf_spec_type_t t) +{ + + ctf_buf_write(b, target_specs[t].scratchpad, target_specs[t].size); +} + static int write_label(void *arg1, void *arg2) { @@ -167,12 +233,13 @@ { ushort_t id = (idp ? idp->ii_dtype->t_id : 0); - ctf_buf_write(b, &id, sizeof (id)); if (target_requires_swap) { SWAP_16(id); } + ctf_buf_write(b, &id, sizeof (id)); + debug(3, "Wrote object %s (%d)\n", (idp ? idp->ii_name : "(null)"), id); } @@ -227,6 +294,31 @@ debug(3, "Wrote function %s (%d args)\n", idp->ii_name, nargs); } +static void +write_unsized_type_rec(ctf_buf_t *b, ctf_type_t *ctt) +{ + ctf_stype_t *cts = (ctf_stype_t *)ctt; + + if (target_requires_swap) { + SWAP_32(cts->ctt_name); + SWAP_16(cts->ctt_info); + SWAP_16(cts->ctt_size); + } + + /* XXXCROSS 1 */ + if (compactPresentation) { + ctf_scratchpad_reset(CTF_SPEC_STYPE); + ctf_scratchpad_write(CTF_SPEC_STYPE, 0, + &cts->ctt_name, sizeof(cts->ctt_name)); + ctf_scratchpad_write(CTF_SPEC_STYPE, 1, + &cts->ctt_info, sizeof(cts->ctt_info)); + ctf_scratchpad_write(CTF_SPEC_STYPE, 2, + &cts->ctt_size, sizeof(cts->ctt_size)); + ctf_scratchpad_flush(b, CTF_SPEC_STYPE); + } else + ctf_buf_write(b, cts, sizeof (*cts)); +} + /* * Depending on the size of the type being described, either a ctf_stype_t (for * types with size < CTF_LSTRUCT_THRESH) or a ctf_type_t (all others) will be @@ -247,7 +339,23 @@ SWAP_32(ctt->ctt_lsizehi); SWAP_32(ctt->ctt_lsizelo); } - ctf_buf_write(b, ctt, sizeof (*ctt)); + /* XXXCROSS 1 */ + if (compactPresentation) { + ctf_scratchpad_reset(CTF_SPEC_TYPE); + ctf_scratchpad_write(CTF_SPEC_TYPE, 0, + &ctt->ctt_name, sizeof(ctt->ctt_name)); + ctf_scratchpad_write(CTF_SPEC_TYPE, 1, + &ctt->ctt_info, sizeof(ctt->ctt_info)); + ctf_scratchpad_write(CTF_SPEC_TYPE, 2, + &ctt->ctt_size, sizeof(ctt->ctt_size)); + ctf_scratchpad_write(CTF_SPEC_TYPE, 3, + &ctt->ctt_lsizehi, sizeof(ctt->ctt_lsizehi)); + ctf_scratchpad_write(CTF_SPEC_TYPE, 4, + &ctt->ctt_lsizelo, sizeof(ctt->ctt_lsizelo)); + ctf_scratchpad_flush(b, CTF_SPEC_TYPE); + + } else + ctf_buf_write(b, ctt, sizeof (*ctt)); } else { ctf_stype_t *cts = (ctf_stype_t *)ctt; @@ -259,24 +367,10 @@ SWAP_16(cts->ctt_size); } - ctf_buf_write(b, cts, sizeof (*cts)); + write_unsized_type_rec(b, ctt); } } -static void -write_unsized_type_rec(ctf_buf_t *b, ctf_type_t *ctt) -{ - ctf_stype_t *cts = (ctf_stype_t *)ctt; - - if (target_requires_swap) { - SWAP_32(cts->ctt_name); - SWAP_16(cts->ctt_info); - SWAP_16(cts->ctt_size); - } - - ctf_buf_write(b, cts, sizeof (*cts)); -} - static int write_type(void *arg1, void *arg2) { @@ -372,7 +466,20 @@ SWAP_16(cta.cta_index); SWAP_32(cta.cta_nelems); } - ctf_buf_write(b, &cta, sizeof (cta)); + /* XXXCROSS 1 */ + if (compactPresentation) { + ctf_scratchpad_reset(CTF_SPEC_ARRAY); + ctf_scratchpad_write(CTF_SPEC_ARRAY, 0, + &cta.cta_contents, sizeof(cta.cta_contents)); + ctf_scratchpad_write(CTF_SPEC_ARRAY, 1, + &cta.cta_index, sizeof(cta.cta_index)); + ctf_scratchpad_write(CTF_SPEC_ARRAY, 2, + &cta.cta_nelems, sizeof(cta.cta_nelems)); + ctf_scratchpad_flush(b, CTF_SPEC_ARRAY); + } + else + ctf_buf_write(b, &cta, sizeof (cta)); + break; case STRUCT: @@ -406,7 +513,20 @@ SWAP_16(ctm.ctm_type); SWAP_16(ctm.ctm_offset); } - ctf_buf_write(b, &ctm, sizeof (ctm)); + + /* XXXCROSS 1 */ + if (compactPresentation) { + ctf_scratchpad_reset(CTF_SPEC_MEMBER); + ctf_scratchpad_write(CTF_SPEC_MEMBER, 0, + &ctm.ctm_name, sizeof(ctm.ctm_name)); + ctf_scratchpad_write(CTF_SPEC_MEMBER, 1, + &ctm.ctm_type, sizeof(ctm.ctm_type)); + ctf_scratchpad_write(CTF_SPEC_MEMBER, 2, + &ctm.ctm_offset, sizeof(ctm.ctm_offset)); + ctf_scratchpad_flush(b, CTF_SPEC_MEMBER); + } + else + ctf_buf_write(b, &ctm, sizeof (ctm)); } } else { for (mp = tp->t_members; mp != NULL; mp = mp->ml_next) { @@ -428,7 +548,22 @@ SWAP_32(ctlm.ctlm_offsetlo); } - ctf_buf_write(b, &ctlm, sizeof (ctlm)); + /* XXXCROSS 1 */ + if (compactPresentation) { + ctf_scratchpad_reset(CTF_SPEC_LMEMBER); + ctf_scratchpad_write(CTF_SPEC_LMEMBER, 0, + &ctlm.ctlm_name, sizeof(ctlm.ctlm_name)); + ctf_scratchpad_write(CTF_SPEC_LMEMBER, 1, + &ctlm.ctlm_type, sizeof(ctlm.ctlm_type)); + ctf_scratchpad_write(CTF_SPEC_LMEMBER, 2, + &ctlm.ctlm_offsethi, sizeof(ctlm.ctlm_offsethi)); + ctf_scratchpad_write(CTF_SPEC_LMEMBER, 3, + &ctlm.ctlm_offsetlo, sizeof(ctlm.ctlm_offsetlo)); + ctf_scratchpad_flush(b, CTF_SPEC_LMEMBER); + } + else + ctf_buf_write(b, &ctlm, sizeof (ctlm)); + } } break; @@ -456,7 +591,18 @@ SWAP_32(cte.cte_value); } - ctf_buf_write(b, &cte, sizeof (cte)); + /* XXXCROSS 1 */ + if (compactPresentation) { + ctf_scratchpad_reset(CTF_SPEC_ENUM); + ctf_scratchpad_write(CTF_SPEC_ENUM, 0, + &cte.cte_name, sizeof(cte.cte_name)); + ctf_scratchpad_write(CTF_SPEC_ENUM, 1, + &cte.cte_value, sizeof(cte.cte_value)); + ctf_scratchpad_flush(b, CTF_SPEC_ENUM); + + } + else + ctf_buf_write(b, &cte, sizeof (cte)); i--; } break; @@ -1299,6 +1445,107 @@ return (td); } +static ctf_spec_type_t +type_by_name(char *name) +{ + int i; + + for (i = 0; i < CTF_SPEC_MAX; i++) { + if (streq(ctf_spec_type_name[i], name)) + break; + } + + return (i); +} + +static void +parse_spec_line(char *line) +{ + char *ptr; + int got_type, got_size; + int field; + ctf_spec_type_t ctf_type = CTF_SPEC_MAX; + + field = got_type = got_size = 0; + for (ptr = strtok(line, ":"); ptr; ptr = strtok(NULL, ":")) + { + if (!got_type) { + ctf_type = type_by_name(ptr); + if (ctf_type == CTF_SPEC_MAX) + terminate("%s: unknown type in spec", ptr); + got_type = 1; + } else if (!got_size) { + target_specs[ctf_type].size = atoi(ptr); + got_size = 1; + } else + target_specs[ctf_type].field_offset[field++] = atoi(ptr); + } + + if (ctf_type == CTF_SPEC_MAX) + terminate("internal error\n"); + + if (target_specs[ctf_type].size == 0) + terminate("%s: structure size is zero", ctf_spec_type_name[ctf_type]); + + target_specs[ctf_type].scratchpad = xcalloc(target_specs[ctf_type].size); + + debug(3, "Spec: Type %s, size: %d, fields: %d\n", ctf_spec_type_name[ctf_type], + target_specs[ctf_type].size, field); + + return; +} + +int +ctf_load_target_spec(char *file) +{ + int fd; + char *buf; + int bytes; + char *line; + int i, j; + + if ((buf = xcalloc(SPEC_BUF_SIZE)) == NULL) + terminate("%s: Cannot allocate buffer for reading spec", file); + + if ((line = xcalloc(SPEC_BUF_SIZE)) == NULL) + terminate("%s: Cannot allocate buffer for reading spec", file); + + if ((fd = open(file, O_RDONLY)) < 0) + terminate("%s: Cannot open for reading", file); + + j = 0; + while ((bytes = read(fd, buf, SPEC_BUF_SIZE)) > 0) { + for (i = 0; i < bytes; i++) { + if (buf[i] == '\n') { + /* + * Parse line + */ + line[j++] = 0; + parse_spec_line(line); + + /* + * Reset line + */ + j = 0; + bzero(line, SPEC_BUF_SIZE); + continue; + } + + if (!isspace(buf[i])) + line[j++] = buf[i]; + } + } + + compactPresentation = 1; + ctf_spec_mask = 1; + + free(buf); + free(line); + close(fd); + + return (0); +} + static size_t decompress_ctf(caddr_t cbuf, size_t cbufsz, caddr_t dbuf, size_t dbufsz) { Index: cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c =================================================================== --- cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c (revision 239689) +++ cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c (working copy) @@ -754,6 +754,7 @@ char *uniqfile = NULL, *uniqlabel = NULL; char *withfile = NULL; char *label = NULL; + char *target_specfile = NULL; char **ifiles, **tifiles; int verbose = 0, docopy = 0; int write_fuzzy_match = 0; @@ -768,7 +769,7 @@ debug_level = atoi(getenv("CTFMERGE_DEBUG_LEVEL")); err = 0; - while ((c = getopt(argc, argv, ":cd:D:fgl:L:o:tvw:s")) != EOF) { + while ((c = getopt(argc, argv, ":cd:D:fgl:L:o:tvw:sX:")) != EOF) { switch (c) { case 'c': docopy = 1; @@ -816,6 +817,10 @@ /* use the dynsym rather than the symtab */ dynsym = CTF_USE_DYNSYM; break; + case 'X': + /* spec for types structure memory layout */ + target_specfile = optarg; + break; default: usage(); exit(2); @@ -849,6 +854,12 @@ exit(2); } + /* + * try loading spec file if provided + */ + if (target_specfile) + ctf_load_target_spec(target_specfile); + if (getenv("STRIPSTABS_KEEP_STABS") != NULL) keep_stabs = CTF_KEEP_STABS; Index: cddl/contrib/opensolaris/lib/libdtrace/arm/dt_isadep.c =================================================================== --- cddl/contrib/opensolaris/lib/libdtrace/arm/dt_isadep.c (revision 0) +++ cddl/contrib/opensolaris/lib/libdtrace/arm/dt_isadep.c (working copy) @@ -0,0 +1,181 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include +#include +#include +#include +#include + +#include +#include + +#define OP(x) ((x) >> 30) +#define OP2(x) (((x) >> 22) & 0x07) +#define COND(x) (((x) >> 25) & 0x0f) +#define A(x) (((x) >> 29) & 0x01) + +#define OP_BRANCH 0 + +#define OP2_BPcc 0x1 +#define OP2_Bicc 0x2 +#define OP2_BPr 0x3 +#define OP2_FBPfcc 0x5 +#define OP2_FBfcc 0x6 + +/*ARGSUSED*/ +int +dt_pid_create_entry_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp, + fasttrap_probe_spec_t *ftp, const GElf_Sym *symp) +{ + ftp->ftps_type = DTFTP_ENTRY; + ftp->ftps_pc = (uintptr_t)symp->st_value; + ftp->ftps_size = (size_t)symp->st_size; + ftp->ftps_noffs = 1; + ftp->ftps_offs[0] = 0; + + if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) { + dt_dprintf("fasttrap probe creation ioctl failed: %s\n", + strerror(errno)); + return (dt_set_errno(dtp, errno)); + } + + return (1); +} + +int +dt_pid_create_return_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp, + fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, uint64_t *stret) +{ + + uint32_t *text; + int i; + int srdepth = 0; + + dt_dprintf("%s: unimplemented\n", __func__); + return (DT_PROC_ERR); + + if ((text = malloc(symp->st_size + 4)) == NULL) { + dt_dprintf("mr sparkle: malloc() failed\n"); + return (DT_PROC_ERR); + } + + if (Pread(P, text, symp->st_size, symp->st_value) != symp->st_size) { + dt_dprintf("mr sparkle: Pread() failed\n"); + free(text); + return (DT_PROC_ERR); + } + + /* + * Leave a dummy instruction in the last slot to simplify edge + * conditions. + */ + text[symp->st_size / 4] = 0; + + ftp->ftps_type = DTFTP_RETURN; + ftp->ftps_pc = symp->st_value; + ftp->ftps_size = symp->st_size; + ftp->ftps_noffs = 0; + + + free(text); + if (ftp->ftps_noffs > 0) { + if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) { + dt_dprintf("fasttrap probe creation ioctl failed: %s\n", + strerror(errno)); + return (dt_set_errno(dtp, errno)); + } + } + + + return (ftp->ftps_noffs); +} + +/*ARGSUSED*/ +int +dt_pid_create_offset_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp, + fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, ulong_t off) +{ + if (off & 0x3) + return (DT_PROC_ALIGN); + + ftp->ftps_type = DTFTP_OFFSETS; + ftp->ftps_pc = (uintptr_t)symp->st_value; + ftp->ftps_size = (size_t)symp->st_size; + ftp->ftps_noffs = 1; + ftp->ftps_offs[0] = off; + + if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) { + dt_dprintf("fasttrap probe creation ioctl failed: %s\n", + strerror(errno)); + return (dt_set_errno(dtp, errno)); + } + + return (1); +} + +/*ARGSUSED*/ +int +dt_pid_create_glob_offset_probes(struct ps_prochandle *P, dtrace_hdl_t *dtp, + fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, const char *pattern) +{ + ulong_t i; + + ftp->ftps_type = DTFTP_OFFSETS; + ftp->ftps_pc = (uintptr_t)symp->st_value; + ftp->ftps_size = (size_t)symp->st_size; + ftp->ftps_noffs = 0; + + /* + * If we're matching against everything, just iterate through each + * instruction in the function, otherwise look for matching offset + * names by constructing the string and comparing it against the + * pattern. + */ + if (strcmp("*", pattern) == 0) { + for (i = 0; i < symp->st_size; i += 4) { + ftp->ftps_offs[ftp->ftps_noffs++] = i; + } + } else { + char name[sizeof (i) * 2 + 1]; + + for (i = 0; i < symp->st_size; i += 4) { + (void) sprintf(name, "%lx", i); + if (gmatch(name, pattern)) + ftp->ftps_offs[ftp->ftps_noffs++] = i; + } + } + + if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) { + dt_dprintf("fasttrap probe creation ioctl failed: %s\n", + strerror(errno)); + return (dt_set_errno(dtp, errno)); + } + + return (ftp->ftps_noffs); +} Property changes on: cddl/contrib/opensolaris/lib/libdtrace/arm/dt_isadep.c ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: cddl/usr.sbin/Makefile =================================================================== --- cddl/usr.sbin/Makefile (revision 239689) +++ cddl/usr.sbin/Makefile (working copy) @@ -21,6 +21,10 @@ _lockstat= lockstat .endif +.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips" +_dtrace= dtrace +.endif + .if ${MACHINE_CPUARCH} == "mips" _dtrace= dtrace .endif Index: cddl/lib/libdtrace/Makefile =================================================================== --- cddl/lib/libdtrace/Makefile (revision 239689) +++ cddl/lib/libdtrace/Makefile (working copy) @@ -74,6 +74,10 @@ CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/mips .PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libdtrace/mips .PATH: ${.CURDIR}/../../../sys/cddl/dev/dtrace/mips +.elif ${MACHINE_CPUARCH} == "arm" +CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/arm +.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libdtrace/arm +.PATH: ${.CURDIR}/../../../sys/cddl/dev/dtrace/arm .else # temporary hack CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/intel Index: cddl/lib/Makefile =================================================================== --- cddl/lib/Makefile (revision 239689) +++ cddl/lib/Makefile (working copy) @@ -19,7 +19,7 @@ .endif .endif -.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" || ${MACHINE_CPUARCH} == "mips" +.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_CPUARCH} == "arm" || ${MACHINE_ARCH} == "i386" || ${MACHINE_CPUARCH} == "mips" _drti= drti _libdtrace= libdtrace .endif Index: sys/cddl/contrib/opensolaris/uts/arm/dtrace/fasttrap_isa.c =================================================================== --- sys/cddl/contrib/opensolaris/uts/arm/dtrace/fasttrap_isa.c (revision 0) +++ sys/cddl/contrib/opensolaris/uts/arm/dtrace/fasttrap_isa.c (working copy) @@ -0,0 +1,30 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +/* + * XXX: Placeholder for MISP fasttrap code + */ Property changes on: sys/cddl/contrib/opensolaris/uts/arm/dtrace/fasttrap_isa.c ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: sys/cddl/contrib/opensolaris/uts/arm/sys/fasttrap_isa.h =================================================================== --- sys/cddl/contrib/opensolaris/uts/arm/sys/fasttrap_isa.h (revision 0) +++ sys/cddl/contrib/opensolaris/uts/arm/sys/fasttrap_isa.h (working copy) @@ -0,0 +1,94 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _FASTTRAP_ISA_H +#define _FASTTRAP_ISA_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This is our reserved trap instruction: ta 0x38 + */ +#define FASTTRAP_INSTR 0x91d02038 + +#define FASTTRAP_SUNWDTRACE_SIZE 128 + +typedef uint32_t fasttrap_instr_t; + +typedef struct fasttrap_machtp { + fasttrap_instr_t ftmt_instr; /* original instruction */ + uintptr_t ftmt_dest; /* destination of DCTI */ + uint8_t ftmt_type; /* emulation type */ + uint8_t ftmt_flags; /* emulation flags */ + uint8_t ftmt_cc; /* which cc to look at */ + uint8_t ftmt_code; /* branch condition */ +} fasttrap_machtp_t; + +#define ftt_instr ftt_mtp.ftmt_instr +#define ftt_dest ftt_mtp.ftmt_dest +#define ftt_type ftt_mtp.ftmt_type +#define ftt_flags ftt_mtp.ftmt_flags +#define ftt_cc ftt_mtp.ftmt_cc +#define ftt_code ftt_mtp.ftmt_code + +#define FASTTRAP_T_COMMON 0x00 /* common case -- no emulation */ +#define FASTTRAP_T_CCR 0x01 /* integer condition code branch */ +#define FASTTRAP_T_FCC 0x02 /* floating-point branch */ +#define FASTTRAP_T_REG 0x03 /* register predicated branch */ +#define FASTTRAP_T_ALWAYS 0x04 /* branch always */ +#define FASTTRAP_T_CALL 0x05 /* call instruction */ +#define FASTTRAP_T_JMPL 0x06 /* jmpl instruction */ +#define FASTTRAP_T_RDPC 0x07 /* rdpc instruction */ +#define FASTTRAP_T_RETURN 0x08 /* return instruction */ + +/* + * For performance rather than correctness. + */ +#define FASTTRAP_T_SAVE 0x10 /* save instruction (func entry only) */ +#define FASTTRAP_T_RESTORE 0x11 /* restore instruction */ +#define FASTTRAP_T_OR 0x12 /* mov instruction */ +#define FASTTRAP_T_SETHI 0x13 /* sethi instruction (includes nop) */ + +#define FASTTRAP_F_ANNUL 0x01 /* branch is annulled */ +#define FASTTRAP_F_RETMAYBE 0x02 /* not definitely a return site */ + +#define FASTTRAP_AFRAMES 3 +#define FASTTRAP_RETURN_AFRAMES 4 +#define FASTTRAP_ENTRY_AFRAMES 3 +#define FASTTRAP_OFFSET_AFRAMES 3 + + +#ifdef __cplusplus +} +#endif + +#endif /* _FASTTRAP_ISA_H */ Property changes on: sys/cddl/contrib/opensolaris/uts/arm/sys/fasttrap_isa.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: sys/cddl/dev/lockstat/lockstat.c =================================================================== --- sys/cddl/dev/lockstat/lockstat.c (revision 239689) +++ sys/cddl/dev/lockstat/lockstat.c (working copy) @@ -45,7 +45,7 @@ #include #include -#if defined(__i386__) || defined(__amd64__) || defined(__mips__) +#if defined(__amd64__) || defined(__arm__) || defined(__i386__) || defined(__mips__) #define LOCKSTAT_AFRAMES 1 #else #error "architecture not supported" Index: sys/cddl/dev/profile/profile.c =================================================================== --- sys/cddl/dev/profile/profile.c (revision 239689) +++ sys/cddl/dev/profile/profile.c (working copy) @@ -119,6 +119,16 @@ #define PROF_ARTIFICIAL_FRAMES 3 #endif +#ifdef __mips +/* bogus */ +#define PROF_ARTIFICIAL_FRAMES 3 +#endif + +#ifdef __arm__ +/* bogus */ +#define PROF_ARTIFICIAL_FRAMES 3 +#endif + typedef struct profile_probe { char prof_name[PROF_NAMELEN]; dtrace_id_t prof_id; Index: sys/cddl/dev/dtrace/arm/dtrace_isa.c =================================================================== --- sys/cddl/dev/dtrace/arm/dtrace_isa.c (revision 0) +++ sys/cddl/dev/dtrace/arm/dtrace_isa.c (working copy) @@ -0,0 +1,325 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * $FreeBSD$ + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "regset.h" + +/* + * Wee need some reasonable default to prevent backtrace code + * from wandering too far + */ +#define MAX_FUNCTION_SIZE 0x10000 +#define MAX_PROLOGUE_SIZE 0x100 + + +uint8_t dtrace_fuword8_nocheck(void *); +uint16_t dtrace_fuword16_nocheck(void *); +uint32_t dtrace_fuword32_nocheck(void *); +uint64_t dtrace_fuword64_nocheck(void *); + +void +dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes, + uint32_t *intrpc) +{ + u_int32_t *frame, *lastframe; + int scp_offset; + int depth = 0; + pc_t caller = (pc_t) solaris_cpu[curcpu].cpu_dtrace_caller; + + if (intrpc != 0) + pcstack[depth++] = (pc_t) intrpc; + + aframes++; + + frame = (u_int32_t *)__builtin_frame_address(0);; + lastframe = NULL; + scp_offset = -(get_pc_str_offset() >> 2); + + while ((frame != NULL) && (depth < pcstack_limit)) { + db_addr_t scp; +#if 0 + u_int32_t savecode; + int r; + u_int32_t *rp; +#endif + + /* + * In theory, the SCP isn't guaranteed to be in the function + * that generated the stack frame. We hope for the best. + */ + scp = frame[FR_SCP]; + printf("--> %08x\n", (uint32_t)scp); + + if (aframes > 0) { + aframes--; + if ((aframes == 0) && (caller != 0)) { + pcstack[depth++] = caller; + } + } + else { + printf("++ --> %08x\n", (uint32_t)scp); + pcstack[depth++] = scp; + } + +#if 0 + savecode = ((u_int32_t *)scp)[scp_offset]; + if ((savecode & 0x0e100000) == 0x08000000) { + /* Looks like an STM */ + rp = frame - 4; + for (r = 10; r >= 0; r--) { + if (savecode & (1 << r)) { + /* register r == *rp-- */ + } + } + } +#endif + + /* + * Switch to next frame up + */ + if (frame[FR_RFP] == 0) + break; /* Top of stack */ + + lastframe = frame; + frame = (u_int32_t *)(frame[FR_RFP]); + + if (INKERNEL((int)frame)) { + /* staying in kernel */ + if (frame <= lastframe) { + /* bad frame pointer */ + break; + } + } + else + break; + } + + for (; depth < pcstack_limit; depth++) { + pcstack[depth] = 0; + } +} + +void +dtrace_getupcstack(uint64_t *pcstack, int pcstack_limit) +{ + printf("unimplemented\n"); +} + +int +dtrace_getustackdepth(void) +{ + printf("unimplemented\n"); + return (0); +} + +void +dtrace_getufpstack(uint64_t *pcstack, uint64_t *fpstack, int pcstack_limit) +{ + printf("IMPLEMENT ME: %s\n", __func__); +} + +/*ARGSUSED*/ +uint64_t +dtrace_getarg(int arg, int aframes) +{ + printf("unimplemented\n"); + + return (0); +} + +int +dtrace_getstackdepth(int aframes) +{ + u_int32_t *frame, *lastframe; + int scp_offset; + int depth = 1; + + frame = (u_int32_t *)__builtin_frame_address(0);; + lastframe = NULL; + scp_offset = -(get_pc_str_offset() >> 2); + + while (frame != NULL) { + db_addr_t scp; +#if 0 + u_int32_t savecode; + int r; + u_int32_t *rp; +#endif + + /* + * In theory, the SCP isn't guaranteed to be in the function + * that generated the stack frame. We hope for the best. + */ + scp = frame[FR_SCP]; + + depth++; + + /* + * Switch to next frame up + */ + if (frame[FR_RFP] == 0) + break; /* Top of stack */ + + lastframe = frame; + frame = (u_int32_t *)(frame[FR_RFP]); + + if (INKERNEL((int)frame)) { + /* staying in kernel */ + if (frame <= lastframe) { + /* bad frame pointer */ + break; + } + } + else + break; + } + + if (depth < aframes) + return 0; + else + return depth - aframes; + +} + +ulong_t +dtrace_getreg(struct trapframe *rp, uint_t reg) +{ + + return (0); +} + +static int +dtrace_copycheck(uintptr_t uaddr, uintptr_t kaddr, size_t size) +{ + + if (uaddr + size > VM_MAXUSER_ADDRESS || uaddr + size < uaddr) { + DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR); + cpu_core[curcpu].cpuc_dtrace_illval = uaddr; + return (0); + } + + return (1); +} + +void +dtrace_copyin(uintptr_t uaddr, uintptr_t kaddr, size_t size, + volatile uint16_t *flags) +{ + if (dtrace_copycheck(uaddr, kaddr, size)) + dtrace_copy(uaddr, kaddr, size); +} + +void +dtrace_copyout(uintptr_t kaddr, uintptr_t uaddr, size_t size, + volatile uint16_t *flags) +{ + if (dtrace_copycheck(uaddr, kaddr, size)) + dtrace_copy(kaddr, uaddr, size); +} + +void +dtrace_copyinstr(uintptr_t uaddr, uintptr_t kaddr, size_t size, + volatile uint16_t *flags) +{ + if (dtrace_copycheck(uaddr, kaddr, size)) + dtrace_copystr(uaddr, kaddr, size, flags); +} + +void +dtrace_copyoutstr(uintptr_t kaddr, uintptr_t uaddr, size_t size, + volatile uint16_t *flags) +{ + if (dtrace_copycheck(uaddr, kaddr, size)) + dtrace_copystr(kaddr, uaddr, size, flags); +} + +uint8_t +dtrace_fuword8(void *uaddr) +{ + if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) { + DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR); + cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr; + return (0); + } + return (dtrace_fuword8_nocheck(uaddr)); +} + +uint16_t +dtrace_fuword16(void *uaddr) +{ + if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) { + DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR); + cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr; + return (0); + } + return (dtrace_fuword16_nocheck(uaddr)); +} + +uint32_t +dtrace_fuword32(void *uaddr) +{ + if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) { + DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR); + cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr; + return (0); + } + return (dtrace_fuword32_nocheck(uaddr)); +} + +uint64_t +dtrace_fuword64(void *uaddr) +{ + if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) { + DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR); + cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr; + return (0); + } + return (dtrace_fuword64_nocheck(uaddr)); +} Property changes on: sys/cddl/dev/dtrace/arm/dtrace_isa.c ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: sys/cddl/dev/dtrace/arm/regset.h =================================================================== --- sys/cddl/dev/dtrace/arm/regset.h (revision 0) +++ sys/cddl/dev/dtrace/arm/regset.h (working copy) @@ -0,0 +1,62 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * $FreeBSD$ + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ + +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +#ifndef _REGSET_H +#define _REGSET_H + +/* + * #pragma ident "@(#)regset.h 1.11 05/06/08 SMI" + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * XXX: define registers properly + */ + +#if 0 +#define REG_PC PC +#define REG_FP EBP +#define REG_SP SP +#define REG_PS EFL +#define REG_R0 EAX +#define REG_R1 EDX +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _REGSET_H */ Property changes on: sys/cddl/dev/dtrace/arm/regset.h ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: sys/cddl/dev/dtrace/arm/dtrace_asm.S =================================================================== --- sys/cddl/dev/dtrace/arm/dtrace_asm.S (revision 0) +++ sys/cddl/dev/dtrace/arm/dtrace_asm.S (working copy) @@ -0,0 +1,222 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * $FreeBSD$ + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#define _ASM +#define _LOCORE +#define LOCORE + +#include +#include + +#include + +#include "assym.s" + +/* +void dtrace_membar_producer(void) +*/ +ENTRY(dtrace_membar_producer) + RET + +/* +void dtrace_membar_consumer(void) +*/ +ENTRY(dtrace_membar_consumer) + RET + +/* +dtrace_icookie_t dtrace_interrupt_disable(void) +*/ +ENTRY(dtrace_interrupt_disable) + mrs r0, cpsr + mov r1, r0 + orr r1, r1, #(I32_bit|F32_bit) + msr cpsr_c, r1 + RET +/* +void dtrace_interrupt_enable(dtrace_icookie_t cookie) +*/ +ENTRY(dtrace_interrupt_enable) + and r0, r0, #(I32_bit|F32_bit) + mrs r1, cpsr + bic r1, r1, #(I32_bit|F32_bit) + orr r1, r1, r0 + msr cpsr_c, r1 + RET + +/* +uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new) +XXX: just disable interrupts for now, add proper implementation for +ARMv6/ARMv7 later +*/ +ENTRY_NP(dtrace_casptr) +ENTRY(dtrace_cas32) + stmfd sp!, {r4, r5} + + mrs r3, cpsr + mov r4, r3 + orr r4, r4, #(I32_bit|F32_bit) + msr cpsr_c, r4 + + ldr r5, [r0] + cmp r5, r2 + movne r0, #0 + bne 2f + + str r2, [r0] + mov r0, #1 + +2: + msr cpsr_c, r3 + ldmfd sp!, {r4, r5} + RET + +/* +uint8_t +dtrace_fuword8_nocheck(void *addr) +*/ +ENTRY(dtrace_fuword8_nocheck) + ldrb r3, [r0] + mov r0, r3 + RET + +/* +uint16_t +dtrace_fuword16_nocheck(void *addr) +*/ +ENTRY(dtrace_fuword16_nocheck) + ldrh r3, [r0] + mov r0, r3 + RET + +/* +uint32_t +dtrace_fuword32_nocheck(void *addr) +*/ +ENTRY(dtrace_fuword32_nocheck) + ldr r3, [r0] + mov r0, r3 + RET + +/* +uint64_t +dtrace_fuword64_nocheck(void *addr) +XXX: add byteorder check +*/ +ENTRY(dtrace_fuword64_nocheck) + ldm r0, {r2, r3} + + mov r0, r2 + mov r1, r3 +#if 0 +/* little endian */ + mov r0, r2 + mov r1, r3 +/* big endian */ + mov r0, r3 + mov r1, r2 +#endif + RET + +/* +void +dtrace_copy(uintptr_t uaddr, uintptr_t kaddr, size_t size) +*/ +ENTRY(dtrace_copy) + stmfd sp!, {r4-r5} /* stack is 8 byte aligned */ + teq r2, #0x00000000 + mov r5, #0x00000000 + beq 2f + +1: ldrb r4, [r0], #0x0001 + add r5, r5, #0x00000001 + strb r4, [r1], #0x0001 + teqne r5, r2 + bne 1b + +2: ldmfd sp!, {r4-r5} /* stack is 8 byte aligned */ + RET + + +/* +void +dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size, + volatile uint16_t *flags) +XXX: Check for flags? +*/ +ENTRY(dtrace_copystr) + stmfd sp!, {r4-r5} /* stack is 8 byte aligned */ + teq r2, #0x00000000 + mov r5, #0x00000000 + beq 2f + +1: ldrb r4, [r0], #0x0001 + add r5, r5, #0x00000001 + teq r4, #0x00000000 + strb r4, [r1], #0x0001 + teqne r5, r2 + bne 1b + +2: ldmfd sp!, {r4-r5} /* stack is 8 byte aligned */ + RET + + +/* +void dtrace_invop_init(void) +*/ +ENTRY(dtrace_invop_init) + RET + +/* +void dtrace_invop_uninit(void) +*/ +ENTRY(dtrace_invop_uninit) + RET + +/* +void +vpanic(const char *format, va_list alist) +*/ +ENTRY(vpanic) /* Initial stack layout: */ +vpanic_common: + RET + +/* +void +dtrace_vpanic(const char *format, va_list alist) +*/ +ENTRY(dtrace_vpanic) /* Initial stack layout: */ + RET + +/* +uintptr_t +dtrace_caller(int aframes) +*/ +ENTRY(dtrace_caller) + mov r0, #-1 + RET Property changes on: sys/cddl/dev/dtrace/arm/dtrace_asm.S ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: sys/cddl/dev/dtrace/arm/dtrace_subr.c =================================================================== --- sys/cddl/dev/dtrace/arm/dtrace_subr.c (revision 0) +++ sys/cddl/dev/dtrace/arm/dtrace_subr.c (working copy) @@ -0,0 +1,187 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + * + * $FreeBSD$ + * + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DELAYBRANCH(x) ((int)(x) < 0) + +extern uintptr_t dtrace_in_probe_addr; +extern int dtrace_in_probe; +extern dtrace_id_t dtrace_probeid_error; + +int dtrace_invop(uintptr_t, uintptr_t *, uintptr_t); + +typedef struct dtrace_invop_hdlr { + int (*dtih_func)(uintptr_t, uintptr_t *, uintptr_t); + struct dtrace_invop_hdlr *dtih_next; +} dtrace_invop_hdlr_t; + +dtrace_invop_hdlr_t *dtrace_invop_hdlr; + +int +dtrace_invop(uintptr_t addr, uintptr_t *stack, uintptr_t eax) +{ + dtrace_invop_hdlr_t *hdlr; + int rval; + + for (hdlr = dtrace_invop_hdlr; hdlr != NULL; hdlr = hdlr->dtih_next) + if ((rval = hdlr->dtih_func(addr, stack, eax)) != 0) + return (rval); + + return (0); +} + + +/*ARGSUSED*/ +void +dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit)) +{ + printf("IMPLEMENT ME: dtrace_toxic_ranges\n"); +} + +void +dtrace_xcall(processorid_t cpu, dtrace_xcall_t func, void *arg) +{ + cpuset_t cpus; + + if (cpu == DTRACE_CPUALL) + cpus = all_cpus; + else + CPU_SETOF(cpu, &cpus); + + smp_rendezvous_cpus(cpus, smp_no_rendevous_barrier, func, + smp_no_rendevous_barrier, arg); +} + +static void +dtrace_sync_func(void) +{ +} + +void +dtrace_sync(void) +{ + dtrace_xcall(DTRACE_CPUALL, (dtrace_xcall_t)dtrace_sync_func, NULL); +} + +/* + * DTrace needs a high resolution time function which can + * be called from a probe context and guaranteed not to have + * instrumented with probes itself. + * + * Returns nanoseconds since boot. + */ +uint64_t +dtrace_gethrtime() +{ + struct timespec curtime; + + nanouptime(&curtime); + + return (curtime.tv_sec * 1000000000UL + curtime.tv_nsec); + +} + +uint64_t +dtrace_gethrestime(void) +{ + struct timespec curtime; + + getnanotime(&curtime); + + return (curtime.tv_sec * 1000000000UL + curtime.tv_nsec); +} + +/* Function to handle DTrace traps during probes. See amd64/amd64/trap.c */ +int +dtrace_trap(struct trapframe *frame, u_int type) +{ + /* + * A trap can occur while DTrace executes a probe. Before + * executing the probe, DTrace blocks re-scheduling and sets + * a flag in it's per-cpu flags to indicate that it doesn't + * want to fault. On returning from the probe, the no-fault + * flag is cleared and finally re-scheduling is enabled. + * + * Check if DTrace has enabled 'no-fault' mode: + * + */ + if ((cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0) { + /* + * There are only a couple of trap types that are expected. + * All the rest will be handled in the usual way. + */ + switch (type) { + /* Page fault. */ + case 0: + /* Flag a bad address. */ + cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR; + cpu_core[curcpu].cpuc_dtrace_illval = 0; + + /* + * Offset the instruction pointer to the instruction + * following the one causing the fault. + */ + panic("%s", __func__); + // frame->pc += sizeof(int); + return (1); + default: + /* Handle all other traps in the usual way. */ + break; + } + } + + /* Handle the trap in the usual way. */ + return (0); +} + +void +dtrace_probe_error(dtrace_state_t *state, dtrace_epid_t epid, int which, + int fault, int fltoffs, uintptr_t illval) +{ + + dtrace_probe(dtrace_probeid_error, (uint64_t)(uintptr_t)state, + (uintptr_t)epid, + (uintptr_t)which, (uintptr_t)fault, (uintptr_t)fltoffs); +} Property changes on: sys/cddl/dev/dtrace/arm/dtrace_subr.c ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: sys/sys/elf_common.h =================================================================== --- sys/sys/elf_common.h (revision 239689) +++ sys/sys/elf_common.h (working copy) @@ -296,6 +296,7 @@ #define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */ #define SHT_LOPROC 0x70000000 /* reserved range for processor */ #define SHT_AMD64_UNWIND 0x70000001 /* unwind information */ +#define SHT_ARM_ATTRIBUTES 0x70000003 /* Section holds attributes. */ #define SHT_MIPS_REGINFO 0x70000006 #define SHT_MIPS_OPTIONS 0x7000000d #define SHT_MIPS_DWARF 0x7000001e /* MIPS gcc uses MIPS_DWARF */ Index: sys/arm/arm/machdep.c =================================================================== --- sys/arm/arm/machdep.c (revision 239708) +++ sys/arm/arm/machdep.c (working copy) @@ -756,8 +756,8 @@ strcpy((char*)&fake_preload[i++], "kernel"); i += 1; fake_preload[i++] = MODINFO_TYPE; - fake_preload[i++] = strlen("elf kernel") + 1; - strcpy((char*)&fake_preload[i++], "elf kernel"); + fake_preload[i++] = strlen("/boot/kernel/kernel") + 1; + strcpy((char*)&fake_preload[i++], "/boot/kernel/kernel"); i += 2; fake_preload[i++] = MODINFO_ADDR; fake_preload[i++] = sizeof(vm_offset_t); Index: sys/arm/arm/trap.c =================================================================== --- sys/arm/arm/trap.c (revision 239708) +++ sys/arm/arm/trap.c (working copy) @@ -80,6 +80,7 @@ #include "opt_ktrace.h" +#include "opt_kdtrace.h" #include __FBSDID("$FreeBSD$"); @@ -122,7 +123,33 @@ #include #endif +#ifdef KDTRACE_HOOKS +#include +/* + * This is a hook which is initialised by the dtrace module + * to handle traps which might occur during DTrace probe + * execution. + */ +dtrace_trap_func_t dtrace_trap_func; + +dtrace_doubletrap_func_t dtrace_doubletrap_func; + +/* + * This is a hook which is initialised by the systrace module + * when it is loaded. This keeps the DTrace syscall provider + * implementation opaque. + */ +systrace_probe_func_t systrace_probe_func; + +/* + * These hooks are necessary for the pid, usdt and fasttrap providers. + */ +dtrace_fasttrap_probe_ptr_t dtrace_fasttrap_probe_ptr; +dtrace_pid_probe_ptr_t dtrace_pid_probe_ptr; +dtrace_return_probe_ptr_t dtrace_return_probe_ptr; +#endif + void swi_handler(trapframe_t *); void undefinedinstruction(trapframe_t *); Index: sys/arm/arm/identcpu.c =================================================================== --- sys/arm/arm/identcpu.c (revision 239708) +++ sys/arm/arm/identcpu.c (working copy) @@ -457,7 +457,7 @@ u_int8_t type, linesize; int i; - cpuid = cpu_id(); + cpuid = cpu_ident(); if (cpuid == 0) { printf("Processor failed probe - no CPU ID\n"); Index: sys/arm/include/cpufunc.h =================================================================== --- sys/arm/include/cpufunc.h (revision 239701) +++ sys/arm/include/cpufunc.h (working copy) @@ -167,7 +167,7 @@ extern struct cpu_functions cpufuncs; extern u_int cputype; -#define cpu_id() cpufuncs.cf_id() +#define cpu_ident() cpufuncs.cf_id() #define cpu_cpwait() cpufuncs.cf_cpwait() #define cpu_control(c, e) cpufuncs.cf_control(c, e) Index: sys/arm/conf/PANDABOARD =================================================================== --- sys/arm/conf/PANDABOARD (revision 239689) +++ sys/arm/conf/PANDABOARD (working copy) @@ -31,8 +31,13 @@ include "../ti/omap4/pandaboard/std.pandaboard" #To statically compile in device wiring instead of /boot/device.hints -makeoptions MODULES_OVERRIDE="" makeoptions WITHOUT_MODULES="ahc" +options KDTRACE_HOOKS # all architectures - enable general DTrace hooks +options DDB_CTF # all architectures - kernel ELF linker loads CTF data +makeoptions DEBUG="-g" +makeoptions WITH_CTF=1 +makeoptions MODULES_OVERRIDE="opensolaris dtrace cyclic dtrace/dtnfsclient dtrace/dtnfscl dtrace/lockstat dtrace/profile" +# makeoptions MODULES_OVERRIDE="" makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols options HZ=100 @@ -46,7 +51,7 @@ options UFS_DIRHASH #Improve performance on big directories options NFSCLIENT #Network Filesystem Client device snp -#options NFSCL +options NFSCL #options NFSSERVER #Network Filesystem Server options NFS_ROOT #NFS usable as /, requires NFSCLIENT options BREAK_TO_DEBUGGER Index: sys/conf/kern.post.mk =================================================================== --- sys/conf/kern.post.mk (revision 239689) +++ sys/conf/kern.post.mk (working copy) @@ -126,7 +126,7 @@ @echo linking ${.TARGET} ${SYSTEM_LD} .if ${MK_CTF} != "no" - ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SYSTEM_OBJS} vers.o + ${CTFMERGE} -X $S/conf/ctfspec.arm ${CTFFLAGS} -o ${.TARGET} ${SYSTEM_OBJS} vers.o .endif .if !defined(DEBUG) ${OBJCOPY} --strip-debug ${.TARGET} Index: sys/conf/ctfspec.arm =================================================================== --- sys/conf/ctfspec.arm (revision 0) +++ sys/conf/ctfspec.arm (working copy) @@ -0,0 +1,6 @@ +ctf_stype_t:12:0:4:8 +ctf_type_t:20:0:4:8:12:16 +ctf_array_t:8:0:2:4 +ctf_member_t:8:0:4:6 +ctf_lmember_t:16:0:4:8:12 +ctf_enum_t:8:0:4 Index: lib/Makefile =================================================================== --- lib/Makefile (revision 239689) +++ lib/Makefile (working copy) @@ -188,16 +188,19 @@ _libypclnt= libypclnt .endif -.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" +.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "mips" .if ${MK_NCP} != "no" _libncp= libncp .endif _libsmb= libsmb -_libvgl= libvgl _libproc= libproc _librtld_db= librtld_db .endif +.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "mips" +_libvgl= libvgl +.endif + .if ${MACHINE_CPUARCH} == "ia64" _libefi= libefi _libsmb= libsmb Index: lib/libproc/proc_regs.c =================================================================== --- lib/libproc/proc_regs.c (revision 239689) +++ lib/libproc/proc_regs.c (working copy) @@ -56,6 +56,8 @@ case REG_PC: #if defined(__amd64__) *regvalue = regs.r_rip; +#elif defined(__arm__) + *regvalue = regs.r_pc; #elif defined(__i386__) *regvalue = regs.r_eip; #elif defined(__mips__) @@ -65,6 +67,8 @@ case REG_SP: #if defined(__amd64__) *regvalue = regs.r_rsp; +#elif defined(__arm__) + *regvalue = regs.r_sp; #elif defined(__i386__) *regvalue = regs.r_esp; #elif defined(__mips__) @@ -95,6 +99,8 @@ case REG_PC: #if defined(__amd64__) regs.r_rip = regvalue; +#elif defined(__arm__) + regs.r_pc = regvalue; #elif defined(__i386__) regs.r_eip = regvalue; #elif defined(__mips__) @@ -104,6 +110,8 @@ case REG_SP: #if defined(__amd64__) regs.r_rsp = regvalue; +#elif defined(__arm__) + regs.r_sp = regvalue; #elif defined(__i386__) regs.r_esp = regvalue; #elif defined(__mips__) Index: lib/libproc/proc_bkpt.c =================================================================== --- lib/libproc/proc_bkpt.c (revision 239689) +++ lib/libproc/proc_bkpt.c (working copy) @@ -47,6 +47,9 @@ #elif defined(__mips__) #define BREAKPOINT_INSTR 0xd /* break */ #define BREAKPOINT_INSTR_SZ 4 +#elif defined(__arm__) +#define BREAKPOINT_INSTR 0xe7ffffff /* bkpt */ +#define BREAKPOINT_INSTR_SZ 4 #else #error "Add support for your architecture" #endif Index: lib/libelf/libelf_data.c =================================================================== --- lib/libelf/libelf_data.c (revision 239689) +++ lib/libelf/libelf_data.c (working copy) @@ -84,6 +84,8 @@ case SHT_SUNW_dof: return (ELF_T_BYTE); #endif + case SHT_ARM_ATTRIBUTES: + /* FALLTHROUGH */ case SHT_MIPS_DWARF: /* FALLTHROUGH */ case SHT_MIPS_REGINFO: