2024-10-14 12:14:01 +03:00
|
|
|
|
package _VisualDVM.Passes.All;
|
2024-10-14 15:19:13 +03:00
|
|
|
|
import Common.Passes.PassState;
|
2025-04-30 21:27:47 +03:00
|
|
|
|
import Common.Utils.Utils_;
|
2024-10-14 15:19:13 +03:00
|
|
|
|
import Common.Visual.Controls.PassControl;
|
2024-10-15 15:13:57 +03:00
|
|
|
|
import Common.Visual.UI;
|
2024-10-07 00:58:29 +03:00
|
|
|
|
import _VisualDVM.Global;
|
2024-10-14 12:14:01 +03:00
|
|
|
|
import _VisualDVM.Passes.PassCode;
|
|
|
|
|
|
import _VisualDVM.Passes.Sapfor.SilentSapforPass;
|
2024-10-14 15:19:13 +03:00
|
|
|
|
import _VisualDVM.ProjectData.Files.DBProjectFile;
|
2025-04-30 21:27:47 +03:00
|
|
|
|
import _VisualDVM.ProjectData.SapforData.GCOV.FileGCOVJson;
|
|
|
|
|
|
import _VisualDVM.ProjectData.SapforData.GCOV.GCOVJson;
|
|
|
|
|
|
import _VisualDVM.ProjectData.SapforData.GCOV.LineGCOVJson;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
public class SPF_GetGCovInfo extends SilentSapforPass {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getIconPath() {
|
2024-10-15 16:58:20 +03:00
|
|
|
|
return "/Common/icons/NotPick.png";
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
protected String getDoneIconPath() {
|
2024-10-15 16:58:20 +03:00
|
|
|
|
return "/Common/icons/Pick.png";
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
2024-10-13 23:55:03 +03:00
|
|
|
|
public boolean hasStats() {
|
2023-09-17 22:13:42 +03:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
2024-10-15 15:13:57 +03:00
|
|
|
|
if (UI.Question("Все анализы будут сброшены.Продолжить")) {
|
2023-09-17 22:13:42 +03:00
|
|
|
|
SPF_ParseFilesWithOrder.silent = true;
|
2024-10-14 15:19:13 +03:00
|
|
|
|
return super.canStart(args) && Global.mainModule.getPass(PassCode.GCOV).Do() && Global.mainModule.getPass(PassCode.SPF_ParseFilesWithOrder).Do();
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void performFinish() throws Exception {
|
|
|
|
|
|
SPF_ParseFilesWithOrder.silent = false;
|
|
|
|
|
|
super.performFinish();
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void performPreparation() throws Exception {
|
|
|
|
|
|
sapfor.cd(target.Home);
|
|
|
|
|
|
target.CleanInterruptFile();
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void body() throws Exception {
|
|
|
|
|
|
sapfor.RunAnalysis(
|
|
|
|
|
|
getSapforPassName(),
|
|
|
|
|
|
-Global.messagesServer.getPort(),
|
2025-01-16 02:26:51 +03:00
|
|
|
|
target.sapforProperties.pack(),
|
2023-09-17 22:13:42 +03:00
|
|
|
|
target.getProjFile().getAbsolutePath());
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void performDone() throws Exception {
|
|
|
|
|
|
if (!sapfor.getResult().isEmpty())
|
|
|
|
|
|
unpack(sapfor.getResult());
|
|
|
|
|
|
}
|
|
|
|
|
|
protected void unpack(String packed) throws Exception {
|
2025-04-30 21:27:47 +03:00
|
|
|
|
GCOVJson allJson = Utils_.gson.fromJson(packed, GCOVJson.class);
|
2025-05-02 22:41:56 +03:00
|
|
|
|
for (FileGCOVJson fileJson: allJson.allGCov){
|
2025-04-30 21:27:47 +03:00
|
|
|
|
fileJson.file = Utils_.toW(fileJson.file);
|
|
|
|
|
|
//--
|
|
|
|
|
|
DBProjectFile projectFile = target.db.files.get(fileJson.file);
|
|
|
|
|
|
for (LineGCOVJson lineJson: fileJson.lines){
|
|
|
|
|
|
if (lineJson.line > 0) {
|
|
|
|
|
|
int v_line = lineJson.line - 1;
|
2025-05-02 22:41:56 +03:00
|
|
|
|
long v_execution = (lineJson.execution >= 0) ? lineJson.execution : 0;
|
2025-04-30 21:27:47 +03:00
|
|
|
|
if (!projectFile.gcov_info.line_info.containsKey(v_line)) {
|
2025-05-02 22:41:56 +03:00
|
|
|
|
projectFile.gcov_info.add_line(v_line, v_execution);
|
2025-05-06 16:26:47 +03:00
|
|
|
|
|
2025-04-30 21:27:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//завешение настроек.
|
|
|
|
|
|
projectFile.gcov_info.setup();
|
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void Reset() {
|
|
|
|
|
|
if (state == PassState.Done) {
|
|
|
|
|
|
state = PassState.Inactive;
|
2024-10-14 15:19:13 +03:00
|
|
|
|
for (PassControl control : controls)
|
2023-09-17 22:13:42 +03:00
|
|
|
|
control.setIcon(getIconPath());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void showDone() throws Exception {
|
2024-10-13 22:08:13 +03:00
|
|
|
|
if (Global.mainModule.HasFile())
|
|
|
|
|
|
Global.mainModule.getFile().form.ShowGCOV();
|
2024-10-14 15:19:13 +03:00
|
|
|
|
for (PassControl control : controls)
|
2023-09-17 22:13:42 +03:00
|
|
|
|
control.setIcon(getDoneIconPath());
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void FocusResult() {
|
2024-10-13 22:08:13 +03:00
|
|
|
|
if (Global.mainModule.HasFile())
|
|
|
|
|
|
Global.mainModule.getFile().form.FocusGCOVLog();
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
2025-05-02 22:41:56 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean isGoodCode() {
|
|
|
|
|
|
return sapfor.getErrorCode() > 0;
|
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|