diff --git a/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/resources/schema.sql b/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/resources/schema.sql --- a/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/resources/schema.sql +++ b/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/resources/schema.sql @@ -1,6 +1,7 @@ CREATE TABLE Func ( func_id INT NOT NULL, func_name VARCHAR(16384) NOT NULL, + context_id BIGINT NOT NULL DEFAULT -1, func_source_file_id INT NOT NULL DEFAULT -1, line_number INT NOT NULL DEFAULT -1, -- FOREIGN KEY (func_source_file_id) REFERENCES (SourceFiles.id) diff --git a/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/storage/impl/SQLStackDataStorage.java b/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/storage/impl/SQLStackDataStorage.java --- a/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/storage/impl/SQLStackDataStorage.java +++ b/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/storage/impl/SQLStackDataStorage.java @@ -556,10 +556,10 @@ } synchronized (funcCache) { - Long funcId = funcCache.get(funcName); + Long funcId = funcCache.get("_"+ context_id + "" + funcName); if (funcId == null) { funcId = ++funcIdSequence; - AddFunctionRequest cmd = requestsProvider.addFunction(funcId, funcName, source_file_index, line_number); + AddFunctionRequest cmd = requestsProvider.addFunction(funcId, funcName, source_file_index, line_number, context_id); requestsProcessor.queueRequest(cmd); funcCache.put(funcName, funcId); } diff --git a/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/storage/impl/SQLStackRequestsProvider.java b/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/storage/impl/SQLStackRequestsProvider.java --- a/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/storage/impl/SQLStackRequestsProvider.java +++ b/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/storage/impl/SQLStackRequestsProvider.java @@ -74,8 +74,8 @@ return new AddNodeRequest(nodeId, callerId, funcId, offset, lineNumber); } - public AddFunctionRequest addFunction(Long funcId, String funcName, int source_file_index, int line_number) { - return new AddFunctionRequest(funcId, funcName, source_file_index, line_number); + public AddFunctionRequest addFunction(Long funcId, String funcName, int source_file_index, int line_number, long context_id) { + return new AddFunctionRequest(funcId, funcName, source_file_index, line_number, context_id); } public SQLRequest updateNodeMetrics(long id, long bucket) { @@ -127,24 +127,27 @@ public final CharSequence name; public final int sourceFileIndex; public final int line_number; + public final long context_id; - public AddFunctionRequest(long id, CharSequence name, int sourceFileIndex, int line_number) { + public AddFunctionRequest(long id, CharSequence name, int sourceFileIndex, int line_number, long context_id) { this.id = id; this.name = name; this.sourceFileIndex = sourceFileIndex; this.line_number = line_number; + this.context_id = context_id; } @Override public void execute() throws SQLException { PreparedStatement stmt = cache.getPreparedStatement( "INSERT INTO Func " + // NOI18N - "(func_id, func_name, func_source_file_id, line_number) " + // NOI18N - "VALUES (?, ?, ?, ?)"); // NOI18N + "(func_id, func_name, func_source_file_id, line_number, context_id) " + // NOI18N + "VALUES (?, ?, ?, ?, ?)"); // NOI18N stmt.setLong(1, id); stmt.setString(2, truncateString(name.toString())); stmt.setInt(3, sourceFileIndex); stmt.setLong(4, line_number); + stmt.setLong(5, context_id); stmt.executeUpdate(); } }