Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 1b1b0e1

Browse files
authored
Merge pull request #32 from HPCToolkit/develop
- Enhance portability - Remove "no acitivity" in top-down view - Add button to clear logs - refine scripts to build and test
2 parents 97b286a + 2ada8c0 commit 1b1b0e1

File tree

6 files changed

+139
-54
lines changed

6 files changed

+139
-54
lines changed

build.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ repackage_nonLinux(){
8383
repackage_linux linux.gtk x86_64
8484
repackage_linux linux.gtk ppc64le
8585

86-
# copy and rename mac file
86+
# copy and rename windows package
8787
output="hpcviewer-${release}-win32.win32.x86_64.zip"
8888
input=edu.rice.cs.hpcviewer.product/target/products/edu.rice.cs.hpcviewer-win32.win32.x86_64.zip
8989
repackage_nonLinux $input $output
9090

91-
# copy and rename windows file
91+
# copy and rename mac package
9292
output="hpcviewer-${release}-macosx.cocoa.x86_64.zip"
9393
input=edu.rice.cs.hpcviewer.product/target/products/edu.rice.cs.hpcviewer-macosx.cocoa.x86_64.zip
94-
cp $input $output
94+
repackage_nonLinux $input $output
9595

9696
echo "=================================="
9797
echo " Done"

edu.rice.cs.hpcviewer.ui/release.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Release 2020.11.12. Commit 08a21e7
1+
Release 2020.11.13. Commit 21167c0

edu.rice.cs.hpcviewer.ui/src/edu/rice/cs/hpcviewer/ui/dialogs/InfoLogDialog.java

+70-47
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
package edu.rice.cs.hpcviewer.ui.dialogs;
22

3-
import java.io.File;
4-
import java.io.FileInputStream;
53
import java.io.IOException;
64
import java.util.List;
75

86
import org.eclipse.core.internal.runtime.Activator;
97
import org.eclipse.core.runtime.Platform;
108
import org.eclipse.jface.dialogs.Dialog;
119
import org.eclipse.jface.dialogs.IDialogConstants;
10+
import org.eclipse.jface.dialogs.MessageDialog;
1211
import org.eclipse.swt.SWT;
13-
import org.eclipse.swt.browser.Browser;
1412
import org.eclipse.swt.graphics.Point;
1513
import org.eclipse.swt.layout.FillLayout;
1614
import org.eclipse.swt.widgets.Composite;
1715
import org.eclipse.swt.widgets.Control;
1816
import org.eclipse.swt.widgets.Display;
1917
import org.eclipse.swt.widgets.Shell;
18+
import org.eclipse.swt.widgets.Text;
2019

2120
import edu.rice.cs.hpclog.LogProperty;
21+
import edu.rice.cs.hpcviewer.ui.util.FileUtility;
2222

2323
public class InfoLogDialog extends Dialog
2424
{
25+
private Text wText;
26+
2527
public InfoLogDialog(Shell shell) {
2628
super(shell);
2729
}
@@ -35,34 +37,10 @@ protected boolean isResizable() {
3537
@Override
3638
protected Control createDialogArea(Composite parent) {
3739
Composite content = (Composite) super.createDialogArea(parent);
38-
39-
String text = "<pre>\n<h3>Log files used by hpcviewer</h3>";
4040

41-
List<String> logUser = LogProperty.getLogFile();
42-
for (String log: logUser) {
43-
text += "File: " + log + "\n";
44-
try {
45-
text += getFileContent(log);
46-
} catch (IOException e) {
47-
// do nothing
48-
}
49-
}
50-
text += "\n\n";
51-
try {
52-
Activator activator = Activator.getDefault();
53-
if (activator != null) {
54-
String locUser = Platform.getLogFileLocation().toOSString();
55-
text += "<b>File: " + locUser + "</b>\n";
56-
text += getFileContent(locUser);
57-
}
58-
} catch (IOException e) {
59-
// do nothing
60-
}
61-
text += "</pre>";
41+
wText = new Text(content, SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
42+
fillText();
6243

63-
Browser browser = new Browser(content, SWT.MULTI);
64-
browser.setText(text);
65-
6644
content.setLayout(new FillLayout());
6745

6846
return content;
@@ -81,30 +59,75 @@ protected void configureShell(Shell newShell) {
8159

8260
@Override
8361
protected void createButtonsForButtonBar(Composite parent) {
62+
createButton(parent, IDialogConstants.HELP_ID, "Clear logs", true);
8463
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
8564
}
8665

87-
/***
88-
* Read the content of the file
89-
* @param filename
90-
* @return String
91-
* @throws IOException
92-
*/
93-
private String getFileContent(String filename) throws IOException {
94-
File file = new File(filename);
95-
if (!file.canRead())
96-
return "";
97-
98-
FileInputStream fis = new FileInputStream(file);
99-
byte[] data = new byte[(int) file.length()];
100-
fis.read(data);
101-
102-
String content = new String(data, "UTF-8");
103-
fis.close();
66+
67+
@Override
68+
protected void buttonPressed(int buttonId) {
69+
if (buttonId == IDialogConstants.HELP_ID) {
70+
if (!MessageDialog.openConfirm(getShell(), "Removing log files", "Are you sure to clear log files?")) {
71+
return;
72+
}
73+
List<String> logUser = LogProperty.getLogFile();
74+
75+
// get the content for each log files
76+
for (String log: logUser) {
77+
try {
78+
FileUtility.clearFileContent(log);
79+
} catch (IOException e) {
80+
}
81+
}
82+
Activator activator = Activator.getDefault();
83+
if (activator != null) {
84+
String locUser = Platform.getLogFileLocation().toOSString();
85+
try {
86+
FileUtility.clearFileContent(locUser);
87+
} catch (IOException e) {
88+
}
89+
}
90+
fillText();
91+
92+
} else {
93+
super.buttonPressed(buttonId);
94+
}
95+
}
96+
97+
private void fillText() {
98+
99+
// set the title
100+
String text = "Log files used by hpcviewer\n";
101+
102+
List<String> logUser = LogProperty.getLogFile();
103+
104+
// get the content for each log files
105+
for (String log: logUser) {
106+
text += "File: " + log + "\n";
107+
try {
108+
text += FileUtility.getFileContent(log);
109+
} catch (IOException e) {
110+
// do nothing
111+
}
112+
}
113+
text += "\n\n";
104114

105-
return content;
115+
try {
116+
Activator activator = Activator.getDefault();
117+
if (activator != null) {
118+
String locUser = Platform.getLogFileLocation().toOSString();
119+
text += "File: " + locUser + "\n";
120+
text += FileUtility.getFileContent(locUser);
121+
}
122+
} catch (IOException e) {
123+
// do nothing
124+
}
125+
text += "\n";
126+
wText.setText(text);
127+
106128
}
107129

130+
108131
static public void main(String argv[]) {
109132
Display d = new Display();
110133
InfoLogDialog dlg = new InfoLogDialog(new Shell(d));

edu.rice.cs.hpcviewer.ui/src/edu/rice/cs/hpcviewer/ui/parts/bottomup/BottomUpContentProvider.java

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public BottomUpContentProvider(ScopeTreeViewer viewer) {
3232
*/
3333
@Override
3434
public Object[] getChildren(Object parentElement) {
35+
if (parentElement == null)
36+
return null;
37+
3538
Object []results = null;
3639

3740
if(parentElement instanceof IMergedScope) {

edu.rice.cs.hpcviewer.ui/src/edu/rice/cs/hpcviewer/ui/parts/topdown/TopDownContentViewer.java

+24-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import edu.rice.cs.hpc.data.experiment.Experiment;
2727
import edu.rice.cs.hpc.data.experiment.extdata.IThreadDataCollection;
2828
import edu.rice.cs.hpc.data.experiment.metric.IMetricManager;
29+
import edu.rice.cs.hpc.data.experiment.scope.ProcedureScope;
2930
import edu.rice.cs.hpc.data.experiment.scope.RootScope;
3031
import edu.rice.cs.hpc.data.experiment.scope.Scope;
3132
import edu.rice.cs.hpc.filter.dialog.FilterDataItem;
@@ -172,10 +173,30 @@ protected AbstractContentProvider getContentProvider(ScopeTreeViewer treeViewer)
172173

173174
@Override
174175
public Object[] getChildren(Object node) {
175-
if (node instanceof Scope) {
176-
return ((Scope)node).getChildren();
176+
if (node == null || !(node instanceof Scope)) {
177+
return null;
177178
}
178-
return null;
179+
if (node instanceof RootScope) {
180+
// TODO: hack to remove nodes that are not part of top-down view
181+
// We'll return the children of the root except the "to-be-elided" flaq nodes
182+
// We should handle this early during the parsing, but unfortunately it will
183+
// cause problems with the trace view since we share the tree.
184+
185+
Object []children = ((RootScope)node).getChildren();
186+
ArrayList<Object> listChildren = new ArrayList<>(children.length);
187+
188+
for(Object child: children) {
189+
if (child instanceof ProcedureScope) {
190+
if (((ProcedureScope)child).toBeElided()) {
191+
// this node shouldn't appear in the top-down view
192+
continue;
193+
}
194+
}
195+
listChildren.add(child);
196+
}
197+
return listChildren.toArray();
198+
}
199+
return ((Scope)node).getChildren();
179200
}
180201
};
181202
return contentProvider;

scripts/test.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#/bin/bash
2+
3+
release=`date +"%Y.%m.%d"`
4+
5+
dir="/tmp/hpcvtest-$release"
6+
rm -rf $dir
7+
mkdir -p $dir
8+
cd $dir
9+
10+
git clone https://github.com/hpctoolkit/hpcviewer.e4
11+
12+
[[ -z hpcviewer.e4 ]] && { echo "hpcviewer.e4 doesn't exist"; exit 1; }
13+
14+
cd hpcviewer.e4
15+
./build.sh 2> log.err
16+
17+
platform=`uname -m`
18+
prefix="linux.gtk"
19+
extension="tgz"
20+
21+
output="hpcviewer-${release}-${prefix}.${platform}.$extension"
22+
23+
if [ -e $output ]; then
24+
tmpdir="hpcviewer.tmp"
25+
rm -rf $tmpdir; mkdir $tmpdir; cd $tmpdir
26+
tar xzf ../$output
27+
28+
cd hpcviewer
29+
30+
dirinstall="/home/$USER/pkgs/hpctoolkit"
31+
./install $dirinstall
32+
33+
echo "has bin installed at $dirinstall successfully"
34+
#$dirinstall/bin/hpcviewer
35+
else
36+
echo "File doesn't exist: $output"
37+
cat log.err
38+
fi

0 commit comments

Comments
 (0)