Skip to content

Support parsing mergedClasses metadata to better de-obfuscate heap dumps. - #6911

Open
MichaelFQuigley wants to merge 5 commits into
mainfrom
dev/michaelquigley/dev/michaelquigley/deobfuscator-merged-classes
Open

Support parsing mergedClasses metadata to better de-obfuscate heap dumps.#6911
MichaelFQuigley wants to merge 5 commits into
mainfrom
dev/michaelquigley/dev/michaelquigley/deobfuscator-merged-classes

Conversation

@MichaelFQuigley

Copy link
Copy Markdown

This supports parsing of JSON comments in the Proguard mapping (.map) files, such as:

# {"id":"com.android.tools.r8.mergedClasses", "class_id_field": "$cid", "merged_classes": [{ "name": "ClassA", "class_id": 0 }, { "name": "ClassB", "class_id": 1 }]}

This will allow for disambiguation of de-obfuscated classes in heap dumps.

Move implementation of array helper methods into simple_json_parser.h
to make simple_json_parser a header-only source set and avoid ODR
violations when included by multiple components.

This is in preparation for an upcoming change to parse JSON comments from
Proguard mapping (.map) files, such as:
# {"id":"com.android.tools.r8.mergedClasses", "class_id_field": "$cid", "merged_classes": [{ "name": "ClassA", "class_id": 0 }, { "name": "ClassB", "class_id": 1 }]}
Add parsing for R8 mergedClasses JSON comments in Proguard mapping files
to extract class merging information into ObfuscatedClass.
@MichaelFQuigley
MichaelFQuigley requested a review from a team as a code owner July 28, 2026 19:05
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

if (current_class_ == nullptr) {
return base::Status();
}
size_t json_start = line.find('{');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There can be other metadata with this prefix # { .
So, trying to parse this json can be costly. What about a early substring check for the kMergedClassesId?

std::string_view json_sv = std::string_view(line).substr(json_start);
base::Status s = ParseMergedClassesComment(json_sv, *current_class_);
if (!s.ok()) {
PERFETTO_DLOG("Failed to parse merged classes comment: %s\non line %s",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, push a import_logs like RecordAnalysisLog instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants