Commit | Line | Data |
---|---|---|
0152140d | 1 | package org.eclipse.linuxtools.lttng.jni_v2_5; |
3b7509b0 | 2 | /******************************************************************************* |
a3767fd9 | 3 | * Copyright (c) 2009, 2011 Ericsson, MontaVista Software |
3b7509b0 WB |
4 | * |
5 | * All rights reserved. This program and the accompanying materials are | |
6 | * made available under the terms of the Eclipse Public License v1.0 which | |
7 | * accompanies this distribution, and is available at | |
8 | * http://www.eclipse.org/legal/epl-v10.html | |
9 | * | |
10 | * Contributors: | |
11 | * William Bourque (wbourque@gmail.com) - Initial API and implementation | |
a3767fd9 | 12 | * Yufen Kuo (ykuo@mvista.com) - add support to allow user specify trace library path |
3b7509b0 | 13 | *******************************************************************************/ |
0152140d | 14 | |
a3767fd9 FC |
15 | import org.eclipse.core.runtime.IPath; |
16 | import org.eclipse.core.runtime.Path; | |
0152140d ASL |
17 | import org.eclipse.linuxtools.lttng.jni.JniTrace; |
18 | import org.eclipse.linuxtools.lttng.jni.JniTracefile; | |
c85e8cb2 | 19 | import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; |
0152140d ASL |
20 | import org.eclipse.linuxtools.lttng.jni.exception.JniException; |
21 | ||
3b7509b0 WB |
22 | /** |
23 | * <b><u>JniTrace_v2_5</u></b> | |
24 | * <p> | |
25 | * JniTrace version to support Lttng traceformat of version 2.5.<br> | |
26 | * This class extend abstract class JniTrace with (possibly) version specific implementation (none yet).<br> | |
27 | * | |
28 | * It also make sure the correct library is loaded by liblttvlibraryloader.so | |
29 | * <p> | |
30 | */ | |
0152140d ASL |
31 | public class JniTrace_v2_5 extends JniTrace { |
32 | ||
3b7509b0 WB |
33 | // This is the dynamic library name that is passed to the library loader (liblttvlibraryloader.so) to load. |
34 | // It needs to be a complete name, like "libXYZ.so", unlike java that would take "XYZ". It could also take a complete path. | |
35 | // The library need to be accessible, i.e. LD_LIBRARY_PATH need to be set correctly. | |
3b38ea61 | 36 | private static final String LIBRARY_NAME = "liblttvtraceread-2.5.so"; //$NON-NLS-1$ |
0152140d | 37 | |
3b7509b0 WB |
38 | /* |
39 | * Forbid access to the default constructor | |
40 | */ | |
0152140d ASL |
41 | protected JniTrace_v2_5() { |
42 | super(); | |
43 | } | |
44 | ||
3b7509b0 | 45 | |
0152140d ASL |
46 | public JniTrace_v2_5(String newpath) throws JniException { |
47 | super(newpath); | |
48 | } | |
49 | ||
50 | public JniTrace_v2_5(String newpath, boolean newPrintDebug) throws JniException { | |
51 | super(newpath, newPrintDebug); | |
52 | } | |
53 | ||
54 | ||
55 | public JniTrace_v2_5(JniTrace_v2_5 oldTrace) { | |
56 | super(oldTrace); | |
57 | } | |
58 | ||
c85e8cb2 | 59 | public JniTrace_v2_5(Jni_C_Pointer_And_Library_Id newPtr, boolean newPrintDebug) throws JniException { |
0152140d ASL |
60 | super(newPtr, newPrintDebug); |
61 | } | |
62 | ||
63 | ||
3b7509b0 WB |
64 | /** |
65 | * Initialize the C library.<p> | |
66 | * | |
67 | * Call the library loader with the .so we wish to load. | |
68 | * | |
69 | * @return True if the load went successful, false otherwise. | |
70 | */ | |
b9fb2d51 | 71 | @Override |
c85e8cb2 | 72 | public int initializeLibrary() { |
a3767fd9 FC |
73 | if (getTraceLibPath() == null) |
74 | return ltt_initializeHandle(LIBRARY_NAME); | |
75 | else{ | |
76 | IPath path = new Path(getTraceLibPath()); | |
77 | IPath traceLib = path.append(LIBRARY_NAME); | |
78 | return ltt_initializeHandle(traceLib.toOSString()); | |
79 | } | |
80 | } | |
0152140d | 81 | |
3b7509b0 WB |
82 | /** |
83 | * Allocate (call constructor for) a new JniTracefile.<p> | |
84 | * | |
85 | * This method is made to bypass limitation related to abstract class, see comment in JniTrace | |
86 | * | |
87 | * @return JniTracefile a newly allocated JniTracefile | |
88 | * | |
89 | * @see org.eclipse.linuxtools.lttng.jni.JniTrace | |
90 | */ | |
b9fb2d51 | 91 | @Override |
c85e8cb2 | 92 | public JniTracefile allocateNewJniTracefile(Jni_C_Pointer_And_Library_Id newPtr, JniTrace newParentTrace) throws JniException { |
0152140d ASL |
93 | return new JniTracefile_v2_5(newPtr, newParentTrace); |
94 | } | |
95 | ||
96 | ||
97 | ||
98 | } |