diff --git a/analysis/heap-dump/api/src/main/java/org/eclipse/jifa/hda/api/HeapDumpAnalyzer.java b/analysis/heap-dump/api/src/main/java/org/eclipse/jifa/hda/api/HeapDumpAnalyzer.java index 5ad49148..9a5dfd3f 100644 --- a/analysis/heap-dump/api/src/main/java/org/eclipse/jifa/hda/api/HeapDumpAnalyzer.java +++ b/analysis/heap-dump/api/src/main/java/org/eclipse/jifa/hda/api/HeapDumpAnalyzer.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -34,6 +34,8 @@ public interface HeapDumpAnalyzer { Map getSystemProperties(); + Map getEnvVariables(); + List getBiggestObjects(); @ApiMeta(aliases = "object") diff --git a/analysis/heap-dump/impl/src/main/java/org/eclipse/jifa/hda/impl/HeapDumpAnalyzerImpl.java b/analysis/heap-dump/impl/src/main/java/org/eclipse/jifa/hda/impl/HeapDumpAnalyzerImpl.java index c59a2e16..01b6f83e 100644 --- a/analysis/heap-dump/impl/src/main/java/org/eclipse/jifa/hda/impl/HeapDumpAnalyzerImpl.java +++ b/analysis/heap-dump/impl/src/main/java/org/eclipse/jifa/hda/impl/HeapDumpAnalyzerImpl.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -72,17 +72,7 @@ import java.lang.ref.SoftReference; import java.net.URL; import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.StringTokenizer; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Pattern; @@ -271,6 +261,27 @@ public Map getSystemProperties() { }); } + @Override + public Map getEnvVariables() { + return $(() -> { + Map env = new HashMap<>(); + Collection classes = context.snapshot.getClassesByName("java.lang.ProcessEnvironment", true); + if(classes == null || classes.isEmpty()){ + return env; + } + IClass systemClass = classes.iterator().next(); + IObject iObject = (IObject) systemClass.resolveValue("theEnvironment"); + IResultTable result = (IResultTable) SnapshotQuery.lookup("hash_entries", context.snapshot) + .setArgument("objects", iObject).execute(new ProgressListenerImpl(NoOpProgressListener)); + int rowCount = result.getRowCount(); + for(int i = 0; i< rowCount; i++){ + Object row = result.getRow(i); + env.put((String) result.getColumnValue(row, 1), (String) result.getColumnValue(row, 2)); + } + return env; + }); + } + @Override public JavaObject getObjectInfo(int objectId) { return $(() -> { diff --git a/frontend/src/components/heapdump/EnvVariables.vue b/frontend/src/components/heapdump/EnvVariables.vue new file mode 100644 index 00000000..12e48c2c --- /dev/null +++ b/frontend/src/components/heapdump/EnvVariables.vue @@ -0,0 +1,85 @@ + + + diff --git a/frontend/src/components/heapdump/HeapDump.vue b/frontend/src/components/heapdump/HeapDump.vue index 16b06bba..568dbeda 100644 --- a/frontend/src/components/heapdump/HeapDump.vue +++ b/frontend/src/components/heapdump/HeapDump.vue @@ -18,6 +18,7 @@ import DominatorTree from '@/components/heapdump/DominatorTree.vue'; import Histogram from '@/components/heapdump/Histogram.vue'; import Threads from '@/components/heapdump/Threads.vue'; import SystemProperties from '@/components/heapdump/SystemProperties.vue'; +import EnvVariables from '@/components/heapdump/EnvVariables.vue'; import Query from '@/components/heapdump/Query.vue'; import GCRoots from '@/components/heapdump/GCRoots.vue'; import UnreachableObjects from '@/components/heapdump/UnreachableObjects.vue'; @@ -56,7 +57,8 @@ const tabs = { DirectByteBuffers, DuplicateClasses, UnreachableObjects, - SystemProperties + SystemProperties, + EnvVariables }; const width = useDebouncedRef(window.innerWidth); diff --git a/frontend/src/i18n/heapdump/en.ts b/frontend/src/i18n/heapdump/en.ts index f5a5226e..d41e425d 100644 --- a/frontend/src/i18n/heapdump/en.ts +++ b/frontend/src/i18n/heapdump/en.ts @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -40,6 +40,7 @@ export default { threads: 'Threads', unreachableObjects: 'Unreachable Objects', systemProperties: 'System Properties', + envVariables: 'Environment Variables', directByteBuffers: 'Direct Byte Buffers', classLoaders: 'Class Loaders', duplicateClasses: 'Duplicated Classes', diff --git a/frontend/src/i18n/heapdump/zh.ts b/frontend/src/i18n/heapdump/zh.ts index 58e011ee..215d24ec 100644 --- a/frontend/src/i18n/heapdump/zh.ts +++ b/frontend/src/i18n/heapdump/zh.ts @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -40,6 +40,7 @@ export default { threads: '线程', unreachableObjects: '不可达对象', systemProperties: '系统属性', + envVariables: '环境变量', directByteBuffers: '堆外内存', classLoaders: '类加载器', duplicateClasses: '重复类',