VirtualBox

Changeset 53636 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 2, 2015 12:00:19 PM (10 years ago)
Author:
vboxsync
Message:

VBoxDTrace: getting started! (r6)

Location:
trunk/src/VBox/ExtPacks/VBoxDTrace
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ExtPacks/VBoxDTrace/Config.kmk

    r53635 r53636  
     1# $Id$
     2## @file
     3# Config.kmk for VBoxDTrace.
     4#
     5# This ASSUMES that we're grafted on as src/VBox/ExtPacks/VBoxDTraceR0.
     6#
    17
    2 ifndef VBOX_ROOT
    3  VBOX_ROOT := $(abspath $(PATH_ROOT)/../../../2vn/trunk)
    4 endif
     8#
     9# Copyright (c) 2012 bird
     10#
     11# Permission is hereby granted, free of charge, to any person
     12# obtaining a copy of this software and associated documentation
     13# files (the "Software"), to deal in the Software without
     14# restriction, including without limitation the rights to use,
     15# copy, modify, merge, publish, distribute, sublicense, and/or sell
     16# copies of the Software, and to permit persons to whom the
     17# Software is furnished to do so, subject to the following
     18# conditions:
     19#
     20# The above copyright notice and this permission notice shall be
     21# included in all copies or substantial portions of the Software.
     22#
     23# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     24# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
     25# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     26# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
     27# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
     28# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     29# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     30# OTHER DEALINGS IN THE SOFTWARE.
     31#
    532
    6 include $(VBOX_ROOT)/Config.kmk
     33include $(PATH_ROOT)/Config.kmk
    734
    8 
    9 
    10 VBOXDT_PATH_ONNV = $(PATH_ROOT)/src/onnv
     35VBOXDT_PATH_ONNV = $(PATH_ROOT)/src/VBox/ExtPacks/VBoxDTrace/onnv
    1136VBOXDT_PATH_UTS  = $(VBOXDT_PATH_ONNV)/uts
    1237VBOXDT_PATH_CMD  = $(VBOXDT_PATH_ONNV)/cmd
    1338
    14 VBOXDT_PATH_VBOX_SDK_LIB = $(VBOX_ROOT)/out/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/$(KBUILD_TYPE)/lib
  • trunk/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceR0/Makefile.kmk

    r53635 r53636  
    11# $Id$
    22## @file
    3 # Sub-makefile for VBoxDTraceR0
     3# Sub-makefile for VBoxDTraceR0.
    44#
    55
    66#
    7 # Copyright (C) 2012 ????
     7# Copyright (c) 2012 bird
    88#
    9 # This file is part of VirtualBox Open Source Edition (OSE), as
    10 # available from http://www.virtualbox.org. This file is free software;
    11 # you can redistribute it and/or modify it under the terms of the GNU
    12 # General Public License (GPL) as published by the Free Software
    13 # Foundation, in version 2 as it comes in the "COPYING" file of the
    14 # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
    15 # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
     9# Permission is hereby granted, free of charge, to any person
     10# obtaining a copy of this software and associated documentation
     11# files (the "Software"), to deal in the Software without
     12# restriction, including without limitation the rights to use,
     13# copy, modify, merge, publish, distribute, sublicense, and/or sell
     14# copies of the Software, and to permit persons to whom the
     15# Software is furnished to do so, subject to the following
     16# conditions:
     17#
     18# The above copyright notice and this permission notice shall be
     19# included in all copies or substantial portions of the Software.
     20#
     21# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     22# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
     23# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     24# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
     25# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
     26# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     27# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     28# OTHER DEALINGS IN THE SOFTWARE.
    1629#
    1730
    18 SUB_DEPTH = ../..
     31SUB_DEPTH = ../../../../../
    1932include $(KBUILD_PATH)/subheader.kmk
    20 
    2133
    2234SYSMODS += VBoxDTraceR0
     
    2739endif
    2840VBoxDTraceR0_INCS = \
     41        ../include \
    2942        $(VBOXDT_PATH_UTS)/common
    3043VBoxDTraceR0_SOURCES = \
    31         VBoxDTraceR0.cpp
     44        VBoxDTraceR0.cpp \
     45        $(VBOXDT_PATH_UTS)/common/dtrace/dtrace.c
    3246VBoxDTraceR0_LIBS = \
    33         $(VBOXDT_PATH_VBOX_SDK_LIB)/RuntimeR0$(VBOX_SUFF_LIB)
     47        $(PATH_STAGE_LIB)/RuntimeR0$(VBOX_SUFF_LIB)
    3448ifneq ($(filter pe lx,$(VBOX_LDR_FMT)),)
    3549 VBoxDTraceR0_LIBS += \
    36         $(VBOXDT_PATH_VBOX_SDK_LIB)/SUPR0$(VBOX_SUFF_LIB)
     50        $(PATH_STAGE_LIB)/SUPR0$(VBOX_SUFF_LIB)
    3751endif
    38 
    3952
    4053include $(KBUILD_PATH)/subfooter.kmk
  • trunk/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceR0/VBoxDTraceR0.cpp

    r53635 r53636  
     1/* $Id$ */
     2/** @file
     3 * VBoxDTraceR0.
     4 */
    15
     6/*
     7 * Copyright (c) 2012 bird
     8 *
     9 * Permission is hereby granted, free of charge, to any person
     10 * obtaining a copy of this software and associated documentation
     11 * files (the "Software"), to deal in the Software without
     12 * restriction, including without limitation the rights to use,
     13 * copy, modify, merge, publish, distribute, sublicense, and/or sell
     14 * copies of the Software, and to permit persons to whom the
     15 * Software is furnished to do so, subject to the following
     16 * conditions:
     17 *
     18 * The above copyright notice and this permission notice shall be
     19 * included in all copies or substantial portions of the Software.
     20 *
     21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
     23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
     25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
     26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     28 * OTHER DEALINGS IN THE SOFTWARE.
     29 */
    230
    331#include <VBox/sup.h>
  • trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dtrace.c

    r53634 r53636  
    6363 * on capital-f functions.
    6464 */
     65#ifndef VBOX
    6566#include <sys/errno.h>
    6667#include <sys/stat.h>
     
    9192#include <sys/socket.h>
    9293#include <netinet/in.h>
     94
     95#else  /* VBOX */
     96# include <iprt/types.h>
     97# include <sys/dtrace_impl.h>
     98# include <iprt/mp.h>
     99#endif /* VBOX */
    93100
    94101/*
     
    357364        if (addr & (size - 1)) {                                        \
    358365                *flags |= CPU_DTRACE_BADALIGN;                          \
    359                 cpu_core[CPU->cpu_id].cpuc_dtrace_illval = addr;        \
     366                cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval = addr;   \
    360367                return (0);                                             \
    361368        }
     
    395402        uint##bits##_t rval;                                            \
    396403        int i;                                                          \
     404        processorid_t me = VBDT_GET_CPUID();                            \
    397405        volatile uint16_t *flags = (volatile uint16_t *)                \
    398             &cpu_core[CPU->cpu_id].cpuc_dtrace_flags;                   \
     406            &cpu_core[me].cpuc_dtrace_flags;                            \
    399407                                                                        \
    400408        DTRACE_ALIGNCHECK(addr, size, flags);                           \
     
    411419                 */                                                     \
    412420                *flags |= CPU_DTRACE_BADADDR;                           \
    413                 cpu_core[CPU->cpu_id].cpuc_dtrace_illval = addr;        \
     421                cpu_core[me].cpuc_dtrace_illval = addr;                 \
    414422                return (0);                                             \
    415423        }                                                               \
     
    681689    dtrace_vstate_t *vstate)
    682690{
    683         volatile uintptr_t *illval = &cpu_core[CPU->cpu_id].cpuc_dtrace_illval;
     691        volatile uintptr_t *illval = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval;
    684692
    685693        /*
     
    773781                return (0);
    774782
    775         flags = (volatile uint16_t *)&cpu_core[CPU->cpu_id].cpuc_dtrace_flags;
     783        flags = (volatile uint16_t *)&cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
    776784
    777785        do {
     
    827835                if (kaddr - taddr < tsize) {
    828836                        DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
    829                         cpu_core[CPU->cpu_id].cpuc_dtrace_illval = kaddr;
     837                        cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval = kaddr;
    830838                        return (1);
    831839                }
     
    833841                if (taddr - kaddr < size) {
    834842                        DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
    835                         cpu_core[CPU->cpu_id].cpuc_dtrace_illval = taddr;
     843                        cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval = taddr;
    836844                        return (1);
    837845                }
     
    917925        volatile uint16_t *flags;
    918926
    919         flags = (volatile uint16_t *)&cpu_core[CPU->cpu_id].cpuc_dtrace_flags;
     927        flags = (volatile uint16_t *)&cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
    920928
    921929        if (s1 == s2)
     
    11241132
    11251133bad:
    1126         cpu_core[CPU->cpu_id].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV;
     1134        cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV;
    11271135
    11281136        return (0);
     
    11401148                return (1);
    11411149
    1142         cpu_core[CPU->cpu_id].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV;
     1150        cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV;
    11431151
    11441152        return (0);
     
    11511159                return (1);
    11521160
    1153         cpu_core[CPU->cpu_id].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV;
     1161        cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV;
    11541162
    11551163        return (0);
     
    11621170                return (1);
    11631171
    1164         cpu_core[CPU->cpu_id].cpuc_dtrace_flags |= CPU_DTRACE_KPRIV;
     1172        cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_KPRIV;
    11651173
    11661174        return (0);
     
    11731181                return (1);
    11741182
    1175         cpu_core[CPU->cpu_id].cpuc_dtrace_flags |= CPU_DTRACE_KPRIV;
     1183        cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= CPU_DTRACE_KPRIV;
    11761184
    11771185        return (0);
     
    13321340        dtrace_dynhash_t *hash = dstate->dtds_hash;
    13331341        dtrace_dynvar_t *free, *new_free, *next, *dvar, *start, *prev = NULL;
    1334         processorid_t me = CPU->cpu_id, cpu = me;
     1342        processorid_t me = VBDT_GET_CPUID(), cpu = me;
    13351343        dtrace_dstate_percpu_t *dcpu = &dstate->dtds_percpu[me];
    13361344        size_t bucket, ksize;
     
    24152423{
    24162424        dtrace_icookie_t cookie;
    2417         processorid_t cpu = CPU->cpu_id;
     2425        processorid_t cpu = VBDT_GET_CPUID();
    24182426        dtrace_buffer_t *dest = &state->dts_buffer[cpu];
    24192427        dtrace_specid_t i;
     
    26812689                if ((lwp = curthread->t_lwp) == NULL) {
    26822690                        DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
    2683                         cpu_core[CPU->cpu_id].cpuc_dtrace_illval = NULL;
     2691                        cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval = NULL;
    26842692                        return (0);
    26852693                }
     
    30133021    dtrace_mstate_t *mstate, dtrace_state_t *state)
    30143022{
    3015         volatile uint16_t *flags = &cpu_core[CPU->cpu_id].cpuc_dtrace_flags;
    3016         volatile uintptr_t *illval = &cpu_core[CPU->cpu_id].cpuc_dtrace_illval;
     3023        volatile uint16_t *flags = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
     3024        volatile uintptr_t *illval = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval;
    30173025        dtrace_vstate_t *vstate = &state->dts_vstate;
    30183026
     
    44814489        dtrace_dstate_t *dstate = &vstate->dtvs_dynvars;
    44824490        dtrace_difv_t *v;
    4483         volatile uint16_t *flags = &cpu_core[CPU->cpu_id].cpuc_dtrace_flags;
    4484         volatile uintptr_t *illval = &cpu_core[CPU->cpu_id].cpuc_dtrace_illval;
     4491        volatile uint16_t *flags = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
     4492        volatile uintptr_t *illval = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval;
    44854493
    44864494        dtrace_key_t tupregs[DIF_DTR_NREGS + 2]; /* +2 for thread and id */
     
    48744882                                sz += sizeof (uint64_t);
    48754883                                ASSERT(svar->dtsv_size == NCPU * sz);
    4876                                 a += CPU->cpu_id * sz;
     4884                                a += VBDT_GET_CPUID() * sz;
    48774885
    48784886                                if (*(uint8_t *)a == UINT8_MAX) {
     
    48924900                        ASSERT(svar->dtsv_size == NCPU * sizeof (uint64_t));
    48934901                        tmp = (uint64_t *)(uintptr_t)svar->dtsv_data;
    4894                         regs[rd] = tmp[CPU->cpu_id];
     4902                        regs[rd] = tmp[VBDT_GET_CPUID()];
    48954903                        break;
    48964904
     
    49134921                                sz += sizeof (uint64_t);
    49144922                                ASSERT(svar->dtsv_size == NCPU * sz);
    4915                                 a += CPU->cpu_id * sz;
     4923                                a += VBDT_GET_CPUID() * sz;
    49164924
    49174925                                if (regs[rd] == NULL) {
     
    49354943                        ASSERT(svar->dtsv_size == NCPU * sizeof (uint64_t));
    49364944                        tmp = (uint64_t *)(uintptr_t)svar->dtsv_data;
    4937                         tmp[CPU->cpu_id] = regs[rd];
     4945                        tmp[VBDT_GET_CPUID()] = regs[rd];
    49384946                        break;
    49394947
     
    54355443        int size, offs = 0, i, j;
    54365444        uintptr_t old = mstate->dtms_scratch_ptr, saved;
    5437         uint16_t *flags = &cpu_core[CPU->cpu_id].cpuc_dtrace_flags;
     5445        uint16_t *flags = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
    54385446        char *sym;
    54395447
     
    55695577        cookie = dtrace_interrupt_disable();
    55705578        probe = dtrace_probes[id - 1];
    5571         cpuid = CPU->cpu_id;
     5579        cpuid = VBDT_GET_CPUID();
    55725580        onintr = CPU_ON_INTR(CPU);
    55735581
     
    1007410082        dtrace_icookie_t cookie = dtrace_interrupt_disable();
    1007510083
    10076         buf = &state->dts_buffer[CPU->cpu_id];
     10084        buf = &state->dts_buffer[VBDT_GET_CPUID()];
    1007710085
    1007810086        if (buf->dtb_tomax != NULL) {
     
    1263912647         */
    1264012648        cookie = dtrace_interrupt_disable();
    12641         *cpu = CPU->cpu_id;
     12649        *cpu = VBDT_GET_CPUID();
    1264212650        ASSERT(state->dts_buffer[*cpu].dtb_flags & DTRACEBUF_INACTIVE);
    1264312651        state->dts_buffer[*cpu].dtb_flags &= ~DTRACEBUF_INACTIVE;
     
    1274012748
    1274112749        cookie = dtrace_interrupt_disable();
    12742         *cpu = CPU->cpu_id;
     12750        *cpu = VBDT_GET_CPUID();
    1274312751        dtrace_probe(dtrace_probeid_end,
    1274412752            (uint64_t)(uintptr_t)state, 0, 0, 0, 0);
     
    1305513063        uint32_t size, next, nnext, i;
    1305613064        dtrace_helptrace_t *ent;
    13057         uint16_t flags = cpu_core[CPU->cpu_id].cpuc_dtrace_flags;
     13065        uint16_t flags = cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
    1305813066
    1305913067        if (!dtrace_helptrace_enabled)
     
    1309613104            mstate->dtms_fltoffs : -1;
    1309713105        ent->dtht_fault = DTRACE_FLAGS2FLT(flags);
    13098         ent->dtht_illval = cpu_core[CPU->cpu_id].cpuc_dtrace_illval;
     13106        ent->dtht_illval = cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_illval;
    1309913107
    1310013108        for (i = 0; i < vstate->dtvs_nlocals; i++) {
     
    1310613114                ASSERT(svar->dtsv_size >= NCPU * sizeof (uint64_t));
    1310713115                ent->dtht_locals[i] =
    13108                     ((uint64_t *)(uintptr_t)svar->dtsv_data)[CPU->cpu_id];
     13116                    ((uint64_t *)(uintptr_t)svar->dtsv_data)[VBDT_GET_CPUID()];
    1310913117        }
    1311013118}
     
    1311413122    dtrace_state_t *state, uint64_t arg0, uint64_t arg1)
    1311513123{
    13116         uint16_t *flags = &cpu_core[CPU->cpu_id].cpuc_dtrace_flags;
     13124        uint16_t *flags = &cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags;
    1311713125        uint64_t sarg0 = mstate->dtms_arg[0];
    1311813126        uint64_t sarg1 = mstate->dtms_arg[1];
  • trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/dtrace.h

    r53634 r53636  
    4545#ifndef _ASM
    4646
     47#ifndef VBOX
    4748#include <sys/types.h>
    4849#include <sys/modctl.h>
     
    5253#include <sys/cyclic.h>
    5354#include <sys/int_limits.h>
     55#else
     56# include <VBoxDTraceTypes.h>
     57#endif
    5458
    5559/*
     
    815819        uint_t dtdo_refcnt;             /* owner reference count */
    816820        uint_t dtdo_destructive;        /* invokes destructive subroutines */
    817 #ifndef _KERNEL
     821#if !defined(_KERNEL) || defined(IN_RING3)
    818822        dof_relodesc_t *dtdo_kreltab;   /* kernel relocations */
    819823        dof_relodesc_t *dtdo_ureltab;   /* user relocations */
     
    12931297#define DTRACEMNRN_CLONE        2               /* first clone minor */
    12941298
    1295 #ifdef _KERNEL
     1299#if defined(_KERNEL) || defined(IN_RING0)
    12961300
    12971301/*
     
    22052209extern void dtrace_toxic_ranges(void (*)(uintptr_t, uintptr_t));
    22062210extern void dtrace_xcall(processorid_t, dtrace_xcall_t, void *);
     2211#ifdef VBOX
     2212extern void dtrace_vpanic(const char *, va_list);
     2213#else
    22072214extern void dtrace_vpanic(const char *, __va_list);
     2215#endif
    22082216extern void dtrace_panic(const char *, ...);
    22092217
     
    22262234#endif
    22272235
     2236#ifndef VBOX
     2237# define VBDT_GET_CPUID()               (CPU->cpu_id)
     2238#else
     2239# define VBDT_GET_CPUID()               (RTMpCpuId())
     2240#endif
     2241
     2242
    22282243#define DTRACE_CPUFLAG_ISSET(flag) \
    2229         (cpu_core[CPU->cpu_id].cpuc_dtrace_flags & (flag))
     2244        (cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags & (flag))
    22302245
    22312246#define DTRACE_CPUFLAG_SET(flag) \
    2232         (cpu_core[CPU->cpu_id].cpuc_dtrace_flags |= (flag))
     2247        (cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags |= (flag))
    22332248
    22342249#define DTRACE_CPUFLAG_CLEAR(flag) \
    2235         (cpu_core[CPU->cpu_id].cpuc_dtrace_flags &= ~(flag))
    2236 
    2237 #endif /* _KERNEL */
     2250        (cpu_core[VBDT_GET_CPUID()].cpuc_dtrace_flags &= ~(flag))
     2251
     2252#endif /* _KERNEL || IN_RING0 */
    22382253
    22392254#endif  /* _ASM */
  • trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/sys/dtrace_impl.h

    r53634 r53636  
    2828#define _SYS_DTRACE_IMPL_H
    2929
     30#ifndef VBOX
    3031#pragma ident   "%Z%%M% %I%     %E% SMI"
     32#endif
    3133
    3234#ifdef  __cplusplus
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette