llvm / llvm/llvm-project

LLDB parsing of Target XML does not handle duplicate id= properly

Open
#214,444 4 comments 0 reactions 0 assignees View on GitHub
lldb
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

From discussion on https://github.com/llvm/llvm-project/pull/213887.

Problem 1: IDs are intended to be unique within a `` element but not between them, or between XML documents.

https://sourceware.org/gdb/current/onlinedocs/gdb.html/Target-Description-Format.html

> Each feature’s name should be unique within the description. The name of a feature does not matter unless GDB has some special knowledge of the contents of that feature; if it does, the feature should have its standard name. See [Standard Target Features](https://sourceware.org/gdb/current/onlinedocs/gdb.html/Standard-Target-Features.html#Standard-Target-Features).

Problem 2: LLDB parses all enums, then all flags. This means that an enum with id of X will always win over a flags with id X, even if the enum is later in the document. We should parse each element as we get to it, rather than all elements of one type.

Problem 3: How should we surface these issues, if at all, to users? Currently they are logged but you have to know to enable the `gdb-remote process` log. Should we surface each one in full, or a single message directing the user to dump the log history?

Currently the logging is scattered around different functions. If we converted to llvm::Error, we could collect them all together to make a neater report.

Contributor guide

Open the contributing guide

Research direction

Start by tracing LLDB's Target XML parser and the scattered logging in the functions that process enum and flag elements. Compare the current behavior with the Target Description Format rules, then determine how duplicate IDs should be scoped and processed in document order. Done also requires a decided user-facing error-reporting behavior, since the issue leaves that design question open.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, xml
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.