Bug 573591

Summary: Feature request: Support multiple headless queries
Product: [Tools] MAT Reporter: Kevin Grigorenko <kevin.grigorenko>
Component: CoreAssignee: Project Inbox <mat.core-inbox>
Status: CLOSED MOVED QA Contact:
Severity: enhancement    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Kevin Grigorenko CLA 2021-05-17 15:29:53 EDT
It doesn't seem that more than one query can be run in headless mode. For example:

./mat.app/Contents/MacOS/MemoryAnalyzer -consoleLog -nosplash -application org.eclipse.mat.api.parse core.dmp -command=histogram org.eclipse.mat.api:query -command=thread_overview org.eclipse.mat.api:query -vmargs -Xmx4g
Comment 1 Andrew Johnson CLA 2021-05-28 03:55:54 EDT
You can run more than one report, but the options and report specifications are collected together, so the second command setting will overwrite the first.

See org.eclipse.mat.internal.apps.ParseSnapshotApp

It gets tricky to see how to do what you want in a compatible fashion.
1. Only take options up to the reports.
    - breaks people who specify options after the reports
2. Also add options if they are the last on the line (no more report)
    - complicated to explain
3. If an option is redefined, run the reports and options specified so far before continuing
    - complicated
    Consider
    MemoryAnalyzer org.eclipse.mat.api.parse core.dmp -command=histogram org.eclipse.mat.api:query -format=txt -command=thread_overview org.eclipse.mat.api:query
    The -format=txt would also apply to the histogram
4. If an option is redefined, run the reports and options specified up to the last report before continuing
    Consider
    MemoryAnalyzer org.eclipse.mat.api.parse core.dmp -command=histogram org.eclipse.mat.api:query -format=txt -format-csv
    MemoryAnalyzer org.eclipse.mat.api.parse core.dmp -command=histogram org.eclipse.mat.api:query -format=txt -format-csv org.eclipse.api:leak_suspects
5. Have an argument which means process everything up to this point
    E.g.
    MemoryAnalyzer -consoleLog -nosplash -application org.eclipse.mat.api.parse core.dmp -command=histogram org.eclipse.mat.api:query -: -command=thread_overview org.eclipse.mat.api:query
    Semicolon is bad as it needs to be escaped on Linux
6. Write your own report with a different option, say command2
7. Run two separate commands - HPROF parser is pretty quick at reloading

Is there any Linux / Unix command that behaves like any of these. E.g. can you run a C compiler with one command on two files, defining the same macro from the command line differently for both?
Comment 2 Kevin Grigorenko CLA 2021-06-01 12:45:17 EDT
Hey Andrew,
Good point that we don't want to break existing users/scripts.
I'm not aware of any command line programs with this sort of use case.
I like option 5.
Option 6 is a good workaround.
Thanks
Comment 3 Eclipse Webmaster CLA 2024-05-08 15:50:59 EDT
This issue has been migrated to https://github.com/eclipse-mat/org.eclipse.mat/issues/35.