~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/daemon/OprofileDaemonEvent.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2012-06-29 12:07:30 UTC
  • Revision ID: package-import@ubuntu.com-20120629120730-bfri1xys1i71dpn6
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2004,2008 Red Hat, Inc.
 
3
 * All rights reserved. This program and the accompanying materials
 
4
 * are made available under the terms of the Eclipse Public License v1.0
 
5
 * which accompanies this distribution, and is available at
 
6
 * http://www.eclipse.org/legal/epl-v10.html
 
7
 *
 
8
 * Contributors:
 
9
 *    Keith Seitz <keiths@redhat.com> - initial API and implementation
 
10
 *    Kent Sebastian <ksebasti@redhat.com>
 
11
 *******************************************************************************/ 
 
12
 
 
13
package org.eclipse.linuxtools.internal.oprofile.core.daemon;
 
14
 
 
15
import org.eclipse.linuxtools.internal.oprofile.core.Oprofile;
 
16
 
 
17
/**
 
18
 * This class represents an event used to configure the OProfile
 
19
 * daemon.
 
20
 */
 
21
public class OprofileDaemonEvent {
 
22
        public static final int COUNT_UNINITIALIZED = 0;
 
23
        public static final int COUNT_INVALID = -1;
 
24
        
 
25
        // The event to collect on this counter
 
26
        private OpEvent event;
 
27
        
 
28
        // Profile kernel?
 
29
        private boolean profileKernel;
 
30
        
 
31
        // Profile userspace?
 
32
        private boolean profileUser;
 
33
        
 
34
        // Reset counter value
 
35
        private int count;
 
36
 
 
37
        public OprofileDaemonEvent() {
 
38
                profileKernel = true;
 
39
                profileUser = true;
 
40
                count = COUNT_UNINITIALIZED;
 
41
                event = null;
 
42
        }
 
43
 
 
44
        /**
 
45
         * Set the event to collect
 
46
         * @param event the OProfile event
 
47
         */
 
48
        public void setEvent(OpEvent event) {
 
49
                this.event = event;
 
50
        }
 
51
        
 
52
        /**
 
53
         * Get the event to collect
 
54
         * @returns the OProfile event
 
55
         */
 
56
        public OpEvent getEvent() {
 
57
                return event;
 
58
        }
 
59
 
 
60
        /**
 
61
         * Set whether to profile the kernel
 
62
         * @param profileKernel whether to enable kernel profiling
 
63
         */
 
64
        public void setProfileKernel(boolean profileKernel) {
 
65
                this.profileKernel = profileKernel;
 
66
        }
 
67
        
 
68
        /**
 
69
         * Get whether to profile the kernel
 
70
         * @return whether to profile the kernel
 
71
         */
 
72
        public boolean getProfileKernel() {
 
73
                return profileKernel;
 
74
        }
 
75
 
 
76
        /**
 
77
         * Set whether to profile userspace
 
78
         * @param profileUser whether to profile userspace
 
79
         */
 
80
        public void setProfileUser(boolean profileUser) {
 
81
                this.profileUser = profileUser;
 
82
        }
 
83
        
 
84
        /**
 
85
         * Get whether to profile userspace
 
86
         * @return whether to profile userspace
 
87
         */
 
88
        public boolean getProfileUser() {
 
89
                return profileUser;
 
90
        }
 
91
 
 
92
        /**
 
93
         * Set the reset count
 
94
         * @param count the new count
 
95
         */
 
96
        public void setResetCount(int count) {
 
97
                this.count = count;
 
98
        }
 
99
        
 
100
        /**
 
101
         * Get the reset count
 
102
         * @return the reset count
 
103
         */
 
104
        public int getResetCount() {
 
105
                // FIXME: This isn't quite in the right place...
 
106
                if (count == COUNT_UNINITIALIZED) {
 
107
                        // This is what Oprofile does in oprof_start.cpp:
 
108
                        double speed = Oprofile.getCpuFrequency();
 
109
                        if (speed == 0.0) {
 
110
                                count = event.getMinCount() * 30;
 
111
                        } else {
 
112
                                count = (int) speed * 20;
 
113
                        }
 
114
                }
 
115
                
 
116
                return count;
 
117
        }
 
118
}