+
Skip to content

Added LLVM_source attributes to line programs #432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

mitsuhiko
Copy link
Contributor

WIP implementation for #431.

Annoyingly due to how these form descriptors work it means that all files need to have the same format. I wonder if it makes sense to just write an empty string in such cases. Effectively something similar happens with md5 hashes already.

Second issue is that this change required to remove a Copy bound :(

panic!("Can only write LineString::LineStringRef for embedded sources, got {:?}", val);
}
(true, None) => {
panic!("has_embedded_source is true, but no source set");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is highly suboptimal. I am thinking of just writing a empty string reference here.

@philipc
Copy link
Collaborator

philipc commented Jun 18, 2019

I haven't looked in detail yet.

Annoyingly due to how these form descriptors work it means that all files need to have the same format. I wonder if it makes sense to just write an empty string in such cases.

I think that's why the DWARF issue (http://dwarfstd.org/ShowIssue.php?issue=180201.1) includes a DW_LNCT_has_source field. But yes, please write an empty string.

Second issue is that this change required to remove a Copy bound

That's fine.

)?;
}
(true, Some(ref val)) => {
panic!("Can only write LineString::LineStringRef for embedded sources, got {:?}", val);
Copy link
Collaborator

Choose a reason for hiding this comment

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

If LineStringRef is the only option, then no point using LineString? Just use the reference directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was considering that. I wasn't sure if there is already a pattern in gimli for this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looking at the DWARF issue, it doesn't restrict the string form, so probably shouldn't here either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The LLVM extension however is restricted:

image

Which I assume makes sense because with the form descriptor system you need to match them across all files.

Copy link
Collaborator

Choose a reason for hiding this comment

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

LLVM permits DW_FORM_string too: source. I don't see a good reason to restrict the form in gimli when supporting all can be done by simply calling LineString::write.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can do that, but i need to know which type i'm going to emit for the form descriptor before I see the file info. So which one do I pick? The string type of the first file info's source and then require them all to match?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes. That's what the file_form handling above does.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 86.156% when pulling 5b764e0 on mitsuhiko:feature/dw-lnct-llvm-source into 2d8c8e2 on gimli-rs:master.

@mitsuhiko
Copy link
Contributor Author

Heh. Writing the empty string is not so easy because at the point where that would be convenient to do I only have the line string offsets. Not sure if adding a new empty string parameter is a great idea.

@bjorn3
Copy link
Contributor

bjorn3 commented Jun 18, 2019

Commit title: *LLVM_source

@mitsuhiko mitsuhiko changed the title Added LLWM_source attributes to line programs Added LLVM_source attributes to line programs Jun 18, 2019
@philipc
Copy link
Collaborator

philipc commented Jun 18, 2019

Where were you thinking of adding the empty string parameter?

I don't have any great ideas for how to handle this. Maybe something along the lines of requiring an empty string to be added whenever file_has_embedded_source is set to true.

@mitsuhiko
Copy link
Contributor Author

Yeah not sure. First I thought about just adding it as an extra parameter to LineProgram::write but that's really ugly.

@mitsuhiko
Copy link
Contributor Author

Looking at the LLVM implementation a bit more they require source to be set for all files in a program or none. So maybe that's actually the way to go here.

@philipc
Copy link
Collaborator

philipc commented Jun 18, 2019

Let's leave it how you have it then. If the caller sets file_has_embedded_source then they must also set a source for every FileInfo.

@philipc
Copy link
Collaborator

philipc commented Jul 2, 2019

@mitsuhiko Do you want to finish this off before I do another release?

@mitsuhiko
Copy link
Contributor Author

I will come back to that later. I wasn't able to use it myself yet because all the dwarfs I have are dwarf4 so I need to first upgrade them to dwarf5 before I can actually utilize this myself.

@philipc
Copy link
Collaborator

philipc commented Mar 14, 2024

DWARF6 will add support for this in a way that doesn't require all files to have the same format. We can revisit this when DWARF6 support is added.

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.

4 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载