This commit adds SBSection.GetAlignment(), and SBSection.alignment as a python property to lldb.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I went through the existing tests for SBSection, and there is only one test case for all the getters & props, and that is for target_byte_size. Based on that lack, and the simplicity of the getter, I didn't think a test case was warranted here.
If the reviewers feel a test is necessary here, I can definitely add one.
I'm less concerned about the getter and the property and more about the underlying functionality. It doesn't look like it's being tested, and adding it to the SB API allows us to change that.
If the reviewers feel a test is necessary here, I can definitely add one.
Yes, unless there's a good reason not too, every change should be accompanied by a test.
For the underlying functionality, I think it'd be best to extend lldb-test to print section alignment (dumpSectionList in lldb/tools/lldb-test/lldb-test.cpp) and then write (or extend) some test in test/Shell/ObjectFile/ELF (or your favourite object format).
That won't test the code added here though, as lldb-test does not use the SB API.
Sent this via email, but doesn't look like it showed up here:
I'm less concerned about the getter and the property and more about the underlying functionality. It doesn't look like it's being tested, and adding it to the SB API allows to change that.
Just to clarify, are you asking me to add a test for the underlying
functionality, Section.GetLog2Align()? Or is the goal to add the
test at the SBSection level to ensure we detect if someone ever
changes the underlying api?
We should test any APIs we add in a python test IMHO. Also testing that the ".alignment" property works
We should test any APIs we add in a python test IMHO. Also testing that the ".alignment" property works
Ok, I'll add tests for the added python function and property.
Now for the hard part, what's the recommended way to access elf section details within python without using the function added in this commit? I do not think it is safe to hard code the expected alignment in the test case as the default alignment may vary across architectures. Shelling out to readelf and parsing is possible, but feels clunky; is there an existing function to get this data?
You can use yaml2obj to create sections with known alignments. You should be able to find examples of that in the existing tests (just grep for yaml2obj).
updated to include test cases for SBSection.GetAlignment() and SBSection.alignment property.
@labath Thanks for the yaml2obj pointer.
@JDevlieghere if I'm reading this right, yours is the last approval this review needs. Is there anything else you would like to be updated in this diff?
we normally use the .yaml extension.