-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[lldb] [scripting bridge] 167388 chore: add api to return arch name for target #168273
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
base: main
Are you sure you want to change the base?
[lldb] [scripting bridge] 167388 chore: add api to return arch name for target #168273
Conversation
Signed-off-by: Nikita B <n2h9z4@gmail.com>
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
…et.GetArchName() instead of target.arch_name in script Signed-off-by: Nikita B <n2h9z4@gmail.com>
|
@llvm/pr-subscribers-lldb Author: None (n2h9) ChangesThis pr fixes #167388 . DescriptionThis pr adds new method TestingAll from
|
…_name readonly property to the binding Signed-off-by: Nikita B <n2h9z4@gmail.com>
…et.arch_name instead of target.GetArchName() in script Signed-off-by: Nikita B <n2h9z4@gmail.com>
…omment in test Signed-off-by: Nikita B <n2h9z4@gmail.com>
|
✅ With the latest revision this PR passed the Python code formatter. |
|
Please run |
…ormatting according to darker Signed-off-by: Nikita B <n2h9z4@gmail.com>
|
|
||
| # Test consistency with triple. | ||
| triple = target.triple | ||
| if triple: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a scenario where there wouldn't be a triple? Should we assert that there is one instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated ✅ thank you 🙇♀️
| target = self.create_simple_target("b.out") | ||
|
|
||
| arch_name = target.arch_name | ||
| self.assertNotEqual(len(arch_name), 0, "Got an arch name string") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better test would check for a specific arch name. Since the binary doesn't need to run, can we target a specific arg in the build dictionary and then check for that, rather than the fact that we have "something"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
I tried to specify architecture when calling self.build, like in this commit 329aec5
but it does not work as expected, looks like the architecture is still the runtime one (if I put arm there GetArchName still returns x86_64, which is what I use to run the test).
Or how one properly specifies the specific architecture?
So, I used the value from self.getArchitecture() to assert the value from arch_name, it is working fine on my platform, will it be ok to use this value for assertion?
Also we could probably just assert that the arch_name is eq to the first element of the `triple, as this is probably we expect from this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No this is not a correct one, if I run test specifying a different arch, like this
./build/bin/lldb-dotest \
-v -p TestTargetAPI.py \
-f test_get_arch_name_dwarf \
-f test_get_arch_name_dwo \
-f test_get_arch_name_dsym \
--arch aarch64 \
lldb/test/API/python_api/target
arch_name returns me x86_64 😢
let me double check why . . .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think right now when performing build in tests, it does not take into account architecture from --arch or from self.build.
I assume it prepares build command in builder.py:293 which uses builder.py::getTriple which does not take into account provided arch and always use arch from configuration.
I can suggest for now to only check that arch_name is eq to first part of triple.
And I could probably create a ticket to investigate / solve this issue with taking into account architecture during test build, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated for now to only compare that arch_name is same as triple first element ✅ .
And created and issue from above comment #168286
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you specify the ARCH in the build dictionary?
dictionary={
"EXE": "b.out",
"arch": arch,
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case build also does not take architecture into account, tried both arch and architecture 😢 .
expected_arch = "aarch64"
d = {
"EXE": "b.out",
"arch": expected_arch,
}
self.build(dictionary=d)
....
print(">>>>")
print(f"target.arch_name = {target.arch_name}")
print("<<<<")
test command output with traces
./build/bin/lldb-dotest \
-v -t -p TestTargetAPI.py \
-f test_get_arch_name_dwarf \
-f test_get_arch_name_dwo \
-f test_get_arch_name_dsym \
--arch aarch64 \
lldb/test/API/python_api/target
/usr/bin/python3 /home/ubuntu/code/llvm-project/lldb/test/API/dotest.py --arch x86_64 -u CXXFLAGS -u CFLAGS --build-dir /home/ubuntu/code/llvm-project/build/lldb-test-build.noindex --executable /home/ubuntu/code/llvm-project/build/./bin/lldb --compiler /home/ubuntu/code/llvm-project/build/./bin/clang --dsymutil /home/ubuntu/code/llvm-project/build/./bin/dsymutil --make /usr/bin/gmake --lldb-libs-dir /home/ubuntu/code/llvm-project/build/./lib --llvm-tools-dir /home/ubuntu/code/llvm-project/build/./bin --lldb-obj-root /home/ubuntu/code/llvm-project/build/tools/lldb --cmake-build-type Debug -v -t -p TestTargetAPI.py -f test_get_arch_name_dwarf -f test_get_arch_name_dwo -f test_get_arch_name_dsym --arch aarch64 lldb/test/API/python_api/target
lldb version 22.0.0git (https://github.com/n2h9/fork-llvm-project revision 0dfb712313fa7689e936e572fde6ac99197806df)
clang revision 0dfb712313fa7689e936e572fde6ac99197806df
llvm revision 0dfb712313fa7689e936e572fde6ac99197806df
libc++ tests will not be run because: API tests require a locally built libc++.
msvcstl tests will not be run because: Don't know how to build with MSVC's STL on linux
objc tests will be skipped because of unsupported platform
Skipping the following test categories: ['libc++', 'msvcstl', 'dsym', 'pdb', 'gmodules', 'debugserver', 'objc']
adding filter spec TargetAPITestCase.test_get_arch_name_dwarf to module <module 'TestTargetAPI' from '/home/ubuntu/code/llvm-project/lldb/test/API/python_api/target/TestTargetAPI.py'>
adding filter spec TargetAPITestCase.test_get_arch_name_dwo to module <module 'TestTargetAPI' from '/home/ubuntu/code/llvm-project/lldb/test/API/python_api/target/TestTargetAPI.py'>
adding filter spec TargetAPITestCase.test_get_arch_name_dsym to module <module 'TestTargetAPI' from '/home/ubuntu/code/llvm-project/lldb/test/API/python_api/target/TestTargetAPI.py'>
compiler=/home/ubuntu/code/llvm-project/build/bin/clang
Configuration: arch=aarch64 compiler=/home/ubuntu/code/llvm-project/build/bin/clang
----------------------------------------------------------------------
Collected 3 tests
Change dir to: /home/ubuntu/code/llvm-project/lldb/test/API/python_api/target
1: test_get_arch_name_dwarf (TestTargetAPI.TargetAPITestCase.test_get_arch_name_dwarf) ... runCmd: settings clear --all
output:
runCmd: settings set symbols.enable-external-lookup false
output:
runCmd: settings set target.inherit-tcc true
output:
runCmd: settings set target.disable-aslr false
output:
runCmd: settings set target.detach-on-error false
output:
runCmd: settings set target.auto-apply-fixits false
output:
runCmd: settings set plugin.process.gdb-remote.packet-timeout 60
output:
runCmd: settings set symbols.clang-modules-cache-path "/home/ubuntu/code/llvm-project/build/lldb-test-build.noindex/module-cache-lldb"
output:
runCmd: settings set use-color false
output:
runCmd: settings set show-statusline false
output:
/usr/bin/gmake VPATH=/home/ubuntu/code/llvm-project/lldb/test/API/python_api/target -C /home/ubuntu/code/llvm-project/build/lldb-test-build.noindex/python_api/target/TestTargetAPI.test_get_arch_name_dwarf -I /home/ubuntu/code/llvm-project/lldb/test/API/python_api/target -I /home/ubuntu/code/llvm-project/lldb/packages/Python/lldbsuite/test/make -f /home/ubuntu/code/llvm-project/lldb/test/API/python_api/target/Makefile MAKE_DSYM=NO all ARCH=aarch64 CC=/home/ubuntu/code/llvm-project/build/bin/clang CC_TYPE=clang CXX=/home/ubuntu/code/llvm-project/build/bin/clang++ LLVM_AR=/home/ubuntu/code/llvm-project/build/./bin/llvm-ar AR=/home/ubuntu/code/llvm-project/build/./bin/llvm-ar OBJCOPY=/home/ubuntu/code/llvm-project/build/./bin/llvm-objcopy STRIP=/home/ubuntu/code/llvm-project/build/./bin/llvm-strip ARCHIVER=/home/ubuntu/code/llvm-project/build/./bin/llvm-ar DWP=/home/ubuntu/code/llvm-project/build/./bin/llvm-dwp CLANG_MODULE_CACHE_DIR=/home/ubuntu/code/llvm-project/build/lldb-test-build.noindex/module-cache-clang LLDB_OBJ_ROOT=/home/ubuntu/code/llvm-project/build/tools/lldb EXE=b.out arch=aarch64 OS=Linux HOST_OS=Linux
gmake: Entering directory '/home/ubuntu/code/llvm-project/build/lldb-test-build.noindex/python_api/target/TestTargetAPI.test_get_arch_name_dwarf'
/home/ubuntu/code/llvm-project/build/bin/clang -g -O0 -I/home/ubuntu/code/llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../..//include -I/home/ubuntu/code/llvm-project/build/tools/lldb/include -I/home/ubuntu/code/llvm-project/lldb/test/API/python_api/target -I/home/ubuntu/code/llvm-project/lldb/packages/Python/lldbsuite/test/make -include /home/ubuntu/code/llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h -fno-limit-debug-info -D_DEFAULT_SOURCE -MT main.o -MD -MP -MF main.d -c -o main.o /home/ubuntu/code/llvm-project/lldb/test/API/python_api/target/main.c
/home/ubuntu/code/llvm-project/build/bin/clang main.o -g -O0 -I/home/ubuntu/code/llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../..//include -I/home/ubuntu/code/llvm-project/build/tools/lldb/include -I/home/ubuntu/code/llvm-project/lldb/test/API/python_api/target -I/home/ubuntu/code/llvm-project/lldb/packages/Python/lldbsuite/test/make -include /home/ubuntu/code/llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h -fno-limit-debug-info -D_DEFAULT_SOURCE --driver-mode=g++ -o "b.out"
gmake: Leaving directory '/home/ubuntu/code/llvm-project/build/lldb-test-build.noindex/python_api/target/TestTargetAPI.test_get_arch_name_dwarf'
>>>>
target.arch_name = x86_64
<<<<
ok
PASS: LLDB (/home/ubuntu/code/llvm-project/build/bin/clang-aarch64) :: test_get_arch_name_dwarf (TestTargetAPI.TargetAPITestCase.test_get_arch_name_dwarf)
2: test_get_arch_name_dwo (TestTargetAPI.TargetAPITestCase.test_get_arch_name_dwo) ... runCmd: settings clear --all
output:
runCmd: settings set symbols.enable-external-lookup false
output:
runCmd: settings set target.inherit-tcc true
output:
runCmd: settings set target.disable-aslr false
output:
runCmd: settings set target.detach-on-error false
output:
runCmd: settings set target.auto-apply-fixits false
output:
runCmd: settings set plugin.process.gdb-remote.packet-timeout 60
output:
runCmd: settings set symbols.clang-modules-cache-path "/home/ubuntu/code/llvm-project/build/lldb-test-build.noindex/module-cache-lldb"
output:
runCmd: settings set use-color false
output:
runCmd: settings set show-statusline false
output:
/usr/bin/gmake VPATH=/home/ubuntu/code/llvm-project/lldb/test/API/python_api/target -C /home/ubuntu/code/llvm-project/build/lldb-test-build.noindex/python_api/target/TestTargetAPI.test_get_arch_name_dwo -I /home/ubuntu/code/llvm-project/lldb/test/API/python_api/target -I /home/ubuntu/code/llvm-project/lldb/packages/Python/lldbsuite/test/make -f /home/ubuntu/code/llvm-project/lldb/test/API/python_api/target/Makefile MAKE_DSYM=NO MAKE_DWO=YES all ARCH=aarch64 CC=/home/ubuntu/code/llvm-project/build/bin/clang CC_TYPE=clang CXX=/home/ubuntu/code/llvm-project/build/bin/clang++ LLVM_AR=/home/ubuntu/code/llvm-project/build/./bin/llvm-ar AR=/home/ubuntu/code/llvm-project/build/./bin/llvm-ar OBJCOPY=/home/ubuntu/code/llvm-project/build/./bin/llvm-objcopy STRIP=/home/ubuntu/code/llvm-project/build/./bin/llvm-strip ARCHIVER=/home/ubuntu/code/llvm-project/build/./bin/llvm-ar DWP=/home/ubuntu/code/llvm-project/build/./bin/llvm-dwp CLANG_MODULE_CACHE_DIR=/home/ubuntu/code/llvm-project/build/lldb-test-build.noindex/module-cache-clang LLDB_OBJ_ROOT=/home/ubuntu/code/llvm-project/build/tools/lldb EXE=b.out arch=aarch64 OS=Linux HOST_OS=Linux
gmake: Entering directory '/home/ubuntu/code/llvm-project/build/lldb-test-build.noindex/python_api/target/TestTargetAPI.test_get_arch_name_dwo'
/home/ubuntu/code/llvm-project/build/bin/clang -g -O0 -I/home/ubuntu/code/llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../..//include -I/home/ubuntu/code/llvm-project/build/tools/lldb/include -I/home/ubuntu/code/llvm-project/lldb/test/API/python_api/target -I/home/ubuntu/code/llvm-project/lldb/packages/Python/lldbsuite/test/make -include /home/ubuntu/code/llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h -fno-limit-debug-info -gsplit-dwarf -D_DEFAULT_SOURCE -MT main.o -MD -MP -MF main.d -c -o main.o /home/ubuntu/code/llvm-project/lldb/test/API/python_api/target/main.c
/home/ubuntu/code/llvm-project/build/bin/clang main.o -g -O0 -I/home/ubuntu/code/llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../..//include -I/home/ubuntu/code/llvm-project/build/tools/lldb/include -I/home/ubuntu/code/llvm-project/lldb/test/API/python_api/target -I/home/ubuntu/code/llvm-project/lldb/packages/Python/lldbsuite/test/make -include /home/ubuntu/code/llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h -fno-limit-debug-info -gsplit-dwarf -D_DEFAULT_SOURCE --driver-mode=g++ -o "b.out"
gmake: Leaving directory '/home/ubuntu/code/llvm-project/build/lldb-test-build.noindex/python_api/target/TestTargetAPI.test_get_arch_name_dwo'
>>>>
target.arch_name = x86_64
<<<<
ok
PASS: LLDB (/home/ubuntu/code/llvm-project/build/bin/clang-aarch64) :: test_get_arch_name_dwo (TestTargetAPI.TargetAPITestCase.test_get_arch_name_dwo)
3: test_get_arch_name_dsym (TestTargetAPI.TargetAPITestCase.test_get_arch_name_dsym) ... skipped 'test case does not fall in any category of interest for this run'
UNSUPPORTED: LLDB (/home/ubuntu/code/llvm-project/build/bin/clang-aarch64) :: test_get_arch_name_dsym (TestTargetAPI.TargetAPITestCase.test_get_arch_name_dsym) (test case does not fall in any category of interest for this run)
Restore dir to: /home/ubuntu/code/llvm-project
----------------------------------------------------------------------
Ran 3 tests in 0.659s
OK (skipped=1)
Session logs for test failures/errors/unexpected successes can be found in the test build directory
Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
…est to check exact arch name string, repalce check if triple exists with assertion Signed-off-by: Nikita B <n2h9z4@gmail.com>
…ith darker Signed-off-by: Nikita B <n2h9z4@gmail.com>
…est to check exact arch name string, use current arch Signed-off-by: Nikita B <n2h9z4@gmail.com>
…o check only that arch_name is eq to triple first element Signed-off-by: Nikita B <n2h9z4@gmail.com>

This pr fixes #167388 .
Description
This pr adds new method
GetArchNametoSBTargetso that no need to parse triple to get arch name in client code.Testing
All from
TestTargetAPI.pyrun test with
existing tests (without newly added)
existing tests (with newly added)
Only
test_get_arch_namerun test with
only newly added