From f4985e241d9b36b9c83af97b63fc7dc8d97e0373 Mon Sep 17 00:00:00 2001 From: Omer Khureshi <10109772+OmerKhureshi@users.noreply.github.com> Date: Sun, 29 Jul 2018 20:10:42 -0700 Subject: [PATCH 1/6] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 030675b..422075f 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,15 @@ 3. Ensure that this project is recognized as a Maven project inside IntelliJ. 6. Run the Main java class in `/src/main/java/com/application/Main.java`. +### Instruction to run tool using Maven. +Since this is a Maven project, use the command below to run the tool from root folder of the repo. +`mvn exec:java -Dexec.mainClass=com.csgt.Main` + ### How to use the tool? 1. Click File -> Select Method Definition log file. 2. Click File -> Select Call Trace file. -3. Click Run -> Run. +3. Click Render -> Run. 4. If you want to start over, click Run -> Reset and redo steps 1 through 3 above. ### Generate Log files. From 662e41d1c5bbb6982c2f940a1252a3fb94aa7f28 Mon Sep 17 00:00:00 2001 From: Omer Khureshi <10109772+OmerKhureshi@users.noreply.github.com> Date: Sun, 29 Jul 2018 20:12:06 -0700 Subject: [PATCH 2/6] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 422075f..05cea68 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# CSVFull +# Java Call Stack Graph Tool +#### A tool to generate a graphical representation of the Java call stack. ### Instruction to run tool using intelliJ. 1. Download or clone the repository. @@ -8,6 +9,7 @@ ### Instruction to run tool using Maven. Since this is a Maven project, use the command below to run the tool from root folder of the repo. + `mvn exec:java -Dexec.mainClass=com.csgt.Main` From f9e79381736ac87d9ad0e7a3fef0d06a6d542a0c Mon Sep 17 00:00:00 2001 From: Omer Khureshi <10109772+OmerKhureshi@users.noreply.github.com> Date: Wed, 1 Aug 2018 16:19:05 -0700 Subject: [PATCH 3/6] Update README.md --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 05cea68..e94d16d 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,19 @@ # Java Call Stack Graph Tool #### A tool to generate a graphical representation of the Java call stack. +### Instruction to run tool using Maven. +1. Download or clone the repository.
+`git clone https://github.com/OmerKhureshi/CSVFull.git` + +2. Since this is a Maven project, use the command below to run the tool from root folder of the repo.
+`mvn exec:java -Dexec.mainClass=com.csgt.Main` + ### Instruction to run tool using intelliJ. 1. Download or clone the repository. 2. In IntelliJ, create a new project and choose `Create Project from Existing Sources...`. Choose the cloned repository to improt all the file. 3. Ensure that this project is recognized as a Maven project inside IntelliJ. 6. Run the Main java class in `/src/main/java/com/application/Main.java`. -### Instruction to run tool using Maven. -Since this is a Maven project, use the command below to run the tool from root folder of the repo. - -`mvn exec:java -Dexec.mainClass=com.csgt.Main` - - ### How to use the tool? 1. Click File -> Select Method Definition log file. 2. Click File -> Select Call Trace file. From 556c3ec2073fa9c5c28552b09881cfcf6a3a4228 Mon Sep 17 00:00:00 2001 From: Omer Khureshi <10109772+OmerKhureshi@users.noreply.github.com> Date: Thu, 2 Aug 2018 13:28:43 -0700 Subject: [PATCH 4/6] Update README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 63753c9..1a695ff 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Java Call Stack Graph Tool #### A tool to generate a graphical representation of the Java call stack. -This tool generate a tree graph for the call stack using the information in log files for you code. A specific format of log file is required for the tool to parse and process the logs. Please see _**How to generate Log files for you code**_ section below to generate log files for your own code.
+This tool generate a tree graph for the call stack using the information in log files for you code. A specific format of log files are required for the tool to parse and process the logs. Please see _**How to generate Log files for you code**_ section below to generate log files for your own code.
### Instruction to run tool using Maven. 1. Download or clone the repository.
-`git clone https://github.com/OmerKhureshi/CSVFull.git` +`git clone https://github.com/OmerKhureshi/JavaCallStackGraphTool.git` 2. Since this is a Maven project, use the command below to run the tool from root folder of the repo.
`mvn exec:java -Dexec.mainClass=com.csgt.Main` @@ -15,7 +15,7 @@ This tool generate a tree graph for the call stack using the information in log Or. - Right click pom.xml file and click open with then choose IntelliJ. + Right click `pom.xml` file and click open with then choose IntelliJ. 3. Ensure that this project is recognized as a Maven project inside IntelliJ and all the dependencies are downloaded. 6. Run the Main java class at `/src/main/java/com/csgt/Main.java`. @@ -24,14 +24,14 @@ This tool generate a tree graph for the call stack using the information in log For the first time, the tool requires the log files that should be used to generate the graph. 1. Click `File -> Select Method Definition log file` (⎇ + m). 2. Click `File -> Select Call Trace file` (⎇ + c). -3. Click `Run -> Run` (⎇ + r). -4. To start over, click `Run -> Reset` (⎇ + ⇧ + r) and redo steps 1 to 3 above. +3. Click `Render -> Run` (⎇ + r). +4. To start over, click `Render -> Reset` (⎇ + ⇧ + r) and redo steps 1 to 3 above. #### For consecutive uses: The tool uses an embedded database to store the parsed information from the log files. Therefore for consecutive uses of the same log files, you can point to the previously generated database to generate the graph without processing the log files. The database file can be found at `/Databases`. The file is suffixed with the time stamp. 1. Click `File -> Load existing database` (⎇ + d). -2. Click ` Run -> Run` (⎇ + r) -3. To start over, click `Run -> Reset` (⎇ + ⇧ + r). +2. Click `Render -> Run` (⎇ + r) +3. To start over, click `Render -> Reset` (⎇ + ⇧ + r). ### How to generate Log files for your code? -Call Trace and Method Definition log files can be generated by following the instructions [here](https://github.com/omersalar/LogWeaver). +Call Trace and Method Definition log files can be generated by following the instructions [here](https://github.com/omerkhureshi/LogWeaver). From 8748dcab54ec273b713c371a60c619352afc6d90 Mon Sep 17 00:00:00 2001 From: omerkhureshi Date: Fri, 3 Aug 2018 00:54:00 -0700 Subject: [PATCH 5/6] minor refactoring --- src/main/java/com/csgt/Main.java | 14 ++------------ .../java/com/csgt/controller/EventHandlers.java | 16 ++++++++-------- .../java/com/csgt/controller/MenuController.java | 4 +++- .../csgt/dataaccess/DAO/CallTraceDAOImpl.java | 2 +- .../com/csgt/dataaccess/DAO/ElementDAOImpl.java | 10 ++++------ .../java/com/csgt/dataaccess/DatabaseUtil.java | 6 +++--- 6 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/csgt/Main.java b/src/main/java/com/csgt/Main.java index f43b179..5ad1605 100644 --- a/src/main/java/com/csgt/Main.java +++ b/src/main/java/com/csgt/Main.java @@ -1,21 +1,11 @@ package com.csgt; import com.csgt.controller.ControllerUtil; -import javafx.animation.*; import javafx.application.Application; -import javafx.application.Platform; -import javafx.beans.property.DoubleProperty; -import javafx.beans.property.SimpleDoubleProperty; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; import javafx.fxml.FXMLLoader; -import javafx.scene.*; -import javafx.scene.paint.Color; -import javafx.scene.shape.Circle; -import javafx.scene.shape.Rectangle; -import javafx.scene.shape.RectangleBuilder; +import javafx.scene.Parent; +import javafx.scene.Scene; import javafx.stage.Stage; -import javafx.util.Duration; import java.io.IOException; diff --git a/src/main/java/com/csgt/controller/EventHandlers.java b/src/main/java/com/csgt/controller/EventHandlers.java index 6125083..1d5eb54 100644 --- a/src/main/java/com/csgt/controller/EventHandlers.java +++ b/src/main/java/com/csgt/controller/EventHandlers.java @@ -559,7 +559,7 @@ private void minMaxButtonOnClick(NodeCell clickedCell, String threadId) { // <0 -> not visible AND collapsed if (collapsed == 0) { - System.out.println("Minimizing node: " + clickedCellID); + // System.out.println("Minimizing node: " + clickedCellID); // visible and un-collapsed --> visible and collapsed // this cell only: 0 -> 2 // all other cells: >2 -> ++1 @@ -587,7 +587,7 @@ private void minMaxButtonOnClick(NodeCell clickedCell, String threadId) { new Thread(task).start(); // clickedCell.setCollapsed(2); } else if (collapsed == 2) { - System.out.println("Maximizing node: " + clickedCellID); + // System.out.println("Maximizing node: " + clickedCellID); // visible and collapsed --> visible and un-collapsed // this cell only : 2 -> 0 // all other cells: >2 -> --1 @@ -638,7 +638,7 @@ private void expandParentTreeChain(ElementDTO elementDTO , String threadId) { } public void jumpTo(String cellId, String threadId, int collapsed) { - System.out.println("EventHandlers.jumpTo"); + // System.out.println("EventHandlers.jumpTo"); if (collapsed != 0) { ElementDTO elementDTO = ElementDAOImpl.getElementDTO(cellId); expandParentTreeChain(elementDTO, threadId); @@ -661,10 +661,10 @@ public void jumpTo(String cellId, String threadId, int collapsed) { Platform.runLater(() -> { ControllerLoader.canvasController.clearAndUpdate(); - System.out.println("EventHandlers.jumpTo here."); + // System.out.println("EventHandlers.jumpTo here."); // blink node if (ControllerLoader.canvasController.nodeCellsOnUI.containsKey(cellId)) { - System.out.println("EventHandlers.jumpTo going to blink."); + // System.out.println("EventHandlers.jumpTo going to blink."); ControllerLoader.canvasController.nodeCellsOnUI.get(cellId).blink(); } }); @@ -723,9 +723,9 @@ protected Void call() { addChildrenHighlightResizeQueries(clickedEleDTO, isCollapsing, queryList, nextCellIdNew, threadId); // >> Uncomment to print all the queries in the query list - System.out.println("EventHandlers.call: printing queries"); - queryList.forEach(query -> System.out.println(query)); - System.out.println(); + // System.out.println("EventHandlers.call: printing queries"); + // queryList.forEach(query -> System.out.println(query)); + // System.out.println(); DatabaseUtil.executeQueryList(queryList); diff --git a/src/main/java/com/csgt/controller/MenuController.java b/src/main/java/com/csgt/controller/MenuController.java index 96aef0d..8583a0e 100644 --- a/src/main/java/com/csgt/controller/MenuController.java +++ b/src/main/java/com/csgt/controller/MenuController.java @@ -354,6 +354,8 @@ public void onReset() { ControllerLoader.instructionsPaneController.setErrorGraphics(false); ControllerLoader.mainController.alertShown = false; + + firstTimeSetUpHighlightsWindowCall = true; } private void setUpBookmarksMenu() { @@ -648,7 +650,7 @@ protected Void call() throws Exception { @Override protected void succeeded() { super.succeeded(); - System.out.println("MenuController.showHighlightsWindow.succeeded: "); + // System.out.println("MenuController.showHighlightsWindow.succeeded: "); ControllerLoader.canvasController.clearAndUpdate(); // Stack highlights so that the larger ones are behind smaller ones. diff --git a/src/main/java/com/csgt/dataaccess/DAO/CallTraceDAOImpl.java b/src/main/java/com/csgt/dataaccess/DAO/CallTraceDAOImpl.java index 56548b3..48ec005 100644 --- a/src/main/java/com/csgt/dataaccess/DAO/CallTraceDAOImpl.java +++ b/src/main/java/com/csgt/dataaccess/DAO/CallTraceDAOImpl.java @@ -90,7 +90,7 @@ public static int insert(List val) { "{ts '" + timestamp + "'}" + ")"; - // System.out.println("Inserting into call trace the statement: " + sql); + // System.out.println("Inserting into call trace the statement: " + sql); ps.execute(sql, Statement.RETURN_GENERATED_KEYS); ResultSet rs = ps.getGeneratedKeys(); if (rs.next()) { diff --git a/src/main/java/com/csgt/dataaccess/DAO/ElementDAOImpl.java b/src/main/java/com/csgt/dataaccess/DAO/ElementDAOImpl.java index a5c3381..046992c 100644 --- a/src/main/java/com/csgt/dataaccess/DAO/ElementDAOImpl.java +++ b/src/main/java/com/csgt/dataaccess/DAO/ElementDAOImpl.java @@ -391,7 +391,7 @@ public static int getMaxLeafCount(String threadId) { " from " + TableNames.CALL_TRACE_TABLE + " " + " where THREAD_ID = " + threadId + ")))"; - System.out.println(">>> " + SQLMaxLeafCount); + // System.out.println(">>> " + SQLMaxLeafCount); int leafCount = DatabaseUtil.executeSelectForInt(SQLMaxLeafCount); return leafCount; } @@ -432,27 +432,25 @@ public static double getMaxHeight(String threadId) { "ON CT.ID = E2.ID_ENTER_CALL_TRACE " + "where E2.PARENT_ID = E1.ID and CT.THREAD_ID = " + threadId + ")"; - System.out.println(">>> " + SQLMaxLeafCount); + // System.out.println(">>> " + SQLMaxLeafCount); double height = DatabaseUtil.executeSelectForDouble(SQLMaxLeafCount); return height; } public static int getLowestCellInThread(String threadId) { if (lowestCellInThreadMap.containsKey(threadId)) { - System.out.println("ElementDAOImpl.getLowestCellInThread: in if loop"); return lowestCellInThreadMap.get(threadId); } - System.out.println("ElementDAOImpl.getLowestCellInThread: outside if loop"); + String maxEleIdQuery = "SELECT MAX(E.ID) AS MAXID " + "FROM " + TableNames.ELEMENT_TABLE + " AS E JOIN " + TableNames.CALL_TRACE_TABLE + " AS CT " + "ON E.ID_ENTER_CALL_TRACE = CT.ID " + "WHERE CT.THREAD_ID = " + threadId; - System.out.println("ElementDAOImpl.getLowestCellInThread: maxEleIdQuery: " + maxEleIdQuery); + // System.out.println("ElementDAOImpl.getLowestCellInThread: maxEleIdQuery: " + maxEleIdQuery); try (ResultSet eleIdRS = DatabaseUtil.select(maxEleIdQuery)){ if (eleIdRS.next()) { int eleId = eleIdRS.getInt("MAXID"); - System.out.println("ElementDAOImpl.getLowestCellInThread: put lowestCellInThreadMap: " +threadId + " : " + eleId); lowestCellInThreadMap.put(threadId, eleId); System.out.println("ElementDAOImpl.getLowestCellInThread: eleId = " + eleId); return eleId; diff --git a/src/main/java/com/csgt/dataaccess/DatabaseUtil.java b/src/main/java/com/csgt/dataaccess/DatabaseUtil.java index 192b6fe..9cbb642 100644 --- a/src/main/java/com/csgt/dataaccess/DatabaseUtil.java +++ b/src/main/java/com/csgt/dataaccess/DatabaseUtil.java @@ -33,7 +33,7 @@ public static boolean isTableCreated(String tableName) { } catch (SQLException e) { e.printStackTrace(); } - System.out.println("DatabaseUtil.isTableCreated: table not created tableName: " + tableName); + // System.out.println("DatabaseUtil.isTableCreated: table not created tableName: " + tableName); return false; } @@ -127,7 +127,7 @@ public static boolean createCallTrace() /*" FOREIGN KEY(\"methodID\") REFERENCES METHOD(\"methdID\")"+ */ ")"; - System.out.println("Created call trace table now. "); + // System.out.println("Created call trace table now. "); ps.executeUpdate(sql); ps.close(); ps = null; @@ -193,7 +193,7 @@ public static boolean createMethodDefn() ps = null; cn.close(); cn = null; - System.out.println("Method defn table created."); + // System.out.println("Method defn table created."); methodDefnTableCreated = true; } catch (SQLException e) { String sqlError = e.getSQLState(); From d7725440535a00fb8a9fc70382c809896dd7a067 Mon Sep 17 00:00:00 2001 From: omerkhureshi Date: Fri, 3 Aug 2018 02:07:10 -0700 Subject: [PATCH 6/6] minor refactoring --- .../java/com/csgt/controller/EventHandlers.java | 15 +++++++++++---- .../java/com/csgt/controller/MenuController.java | 11 +++++------ .../com/csgt/dataaccess/DAO/ElementDAOImpl.java | 12 +++--------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/csgt/controller/EventHandlers.java b/src/main/java/com/csgt/controller/EventHandlers.java index 1d5eb54..29ff67b 100644 --- a/src/main/java/com/csgt/controller/EventHandlers.java +++ b/src/main/java/com/csgt/controller/EventHandlers.java @@ -628,6 +628,9 @@ private Task expandTreeAt(ElementDTO clickedEleDTO, String threadId, boole private void expandParentTreeChain(ElementDTO elementDTO , String threadId) { List parentElementDTOs = ElementDAOImpl.getAllParentElementDTOs(elementDTO, threadId); + if (parentElementDTOs == null) { + return; + } ExecutorService es = Executors.newSingleThreadExecutor(); parentElementDTOs.forEach(eleDTO -> { Task task = expandTreeAt(eleDTO, threadId, true); @@ -814,10 +817,14 @@ private List getSubTreeUpdateQueries(ElementDTO elementDTO, boolean isCo "AND ELE.COLLAPSED NOT IN (0, 2) " + ")"; - updateHighlightsQuery = "UPDATE " + TableNames.HIGHLIGHT_ELEMENT + " " + - "SET COLLAPSED = 1 " + - "WHERE ELEMENT_ID > " + startCellId + " " + - "AND ELEMENT_ID < " + endCellId; + updateHighlightsQuery = "UPDATE " + TableNames.HIGHLIGHT_ELEMENT + " AS H " + + "SET H.COLLAPSED = 1 " + + "WHERE H.ELEMENT_ID > " + startCellId + " " + + "AND H.ELEMENT_ID < " + endCellId + " " + + "AND EXISTS (SELECT * FROM " + TableNames.CALL_TRACE_TABLE + " AS CT " + + "JOIN " + TableNames.ELEMENT_TABLE + " AS E ON CT.ID = E.ID_ENTER_CALL_TRACE " + + "WHERE H.ELEMENT_ID = E.ID AND " + + "CT.THREAD_ID = " + threadId + ")"; } else { updateCellQuery = "UPDATE " + TableNames.ELEMENT_TABLE + " AS E " + "SET E.COLLAPSED = " + diff --git a/src/main/java/com/csgt/controller/MenuController.java b/src/main/java/com/csgt/controller/MenuController.java index 8583a0e..e800c79 100644 --- a/src/main/java/com/csgt/controller/MenuController.java +++ b/src/main/java/com/csgt/controller/MenuController.java @@ -117,7 +117,7 @@ public class MenuController { private Button applyButton; private Button cancelButton; - private Map firstCBMap; + // private Map firstCBMap; private Map secondCBMap; private Map colorsMap; private boolean anyColorChange = false; @@ -425,7 +425,7 @@ private void firstTimeSetUpHighlightsWindow() { firstTimeSetUpHighlightsWindowCall = false; - firstCBMap = new HashMap<>(); + // firstCBMap = new HashMap<>(); secondCBMap = new HashMap<>(); colorsMap = new HashMap<>(); anyColorChange = false; @@ -627,14 +627,14 @@ protected Void call() throws Exception { // For each of the selected methods, insert the bound box properties into Highlights table if not already present. Statement statement = DatabaseUtil.getConnection().createStatement(); - firstCBMap.forEach((fullName, checkBox) -> addInsertQueryToStatement(fullName, statement, "SINGLE")); + // firstCBMap.forEach((fullName, checkBox) -> addInsertQueryToStatement(fullName, statement, "SINGLE")); secondCBMap.forEach((fullName, checkBox) -> addInsertQueryToStatement(fullName, statement, "FULL")); // Delete records from HIGHLIGHT_ELEMENT if that method is not checked in the stage. StringJoiner firstSJ = new StringJoiner("','", "'", "'"); - firstCBMap.forEach((fullName, checkBox) -> firstSJ.add(fullName)); - addDeleteQueryToStatement(firstSJ.toString(), statement, "SINGLE"); + // firstCBMap.forEach((fullName, checkBox) -> firstSJ.add(fullName)); + // addDeleteQueryToStatement(firstSJ.toString(), statement, "SINGLE"); StringJoiner secondSJ = new StringJoiner("','", "'", "'"); secondCBMap.forEach((fullName, checkBox) -> secondSJ.add(fullName)); @@ -675,7 +675,6 @@ private void addInsertQueryToStatement(String fullName, Statement statement, Str String[] arr = fullName.split("\\."); String methodName = arr[arr.length - 1]; String packageName = fullName.substring(0, fullName.length() - methodName.length() - 1); - HighlightDAOImpl.insert(startXOffset, startYOffset, widthOffset, heightOffset, methodName, packageName, highlightType, colorsMap, fullName, statement); } diff --git a/src/main/java/com/csgt/dataaccess/DAO/ElementDAOImpl.java b/src/main/java/com/csgt/dataaccess/DAO/ElementDAOImpl.java index 046992c..befc066 100644 --- a/src/main/java/com/csgt/dataaccess/DAO/ElementDAOImpl.java +++ b/src/main/java/com/csgt/dataaccess/DAO/ElementDAOImpl.java @@ -18,8 +18,6 @@ public class ElementDAOImpl { - private static Map lowestCellInThreadMap = new HashMap<>(); - public static boolean isTableCreated() { return DatabaseUtil.isTableCreated(ELEMENT_TABLE); } @@ -231,6 +229,9 @@ public static ElementDTO getElementDTO(String id) { } public static List getElementDTOs(List ids) { + if (ids == null || ids.size() == 0) { + return null; + } List elementDTOs = new ArrayList<>(); StringJoiner stringJoiner = new StringJoiner(",", "(", ")"); @@ -438,21 +439,14 @@ public static double getMaxHeight(String threadId) { } public static int getLowestCellInThread(String threadId) { - if (lowestCellInThreadMap.containsKey(threadId)) { - return lowestCellInThreadMap.get(threadId); - } - String maxEleIdQuery = "SELECT MAX(E.ID) AS MAXID " + "FROM " + TableNames.ELEMENT_TABLE + " AS E JOIN " + TableNames.CALL_TRACE_TABLE + " AS CT " + "ON E.ID_ENTER_CALL_TRACE = CT.ID " + "WHERE CT.THREAD_ID = " + threadId; - // System.out.println("ElementDAOImpl.getLowestCellInThread: maxEleIdQuery: " + maxEleIdQuery); try (ResultSet eleIdRS = DatabaseUtil.select(maxEleIdQuery)){ if (eleIdRS.next()) { int eleId = eleIdRS.getInt("MAXID"); - lowestCellInThreadMap.put(threadId, eleId); - System.out.println("ElementDAOImpl.getLowestCellInThread: eleId = " + eleId); return eleId; } } catch (SQLException e) {