Skip to content

[AIX] Port to 64-bit AIX #75

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

Merged
merged 9 commits into from
Sep 24, 2022
Merged

[AIX] Port to 64-bit AIX #75

merged 9 commits into from
Sep 24, 2022

Conversation

bzEq
Copy link
Contributor

@bzEq bzEq commented Sep 15, 2022

We are porting Rust to AIX, see rust-lang/compiler-team#553. This PR adds corresponding assembly in psm for AIX.

@bzEq bzEq marked this pull request as draft September 15, 2022 08:17
@bzEq bzEq marked this pull request as ready for review September 15, 2022 08:17
Copy link
Member

@nagisa nagisa left a comment

Choose a reason for hiding this comment

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

Please also adjust the support table in the README.

.vbyte 8, .rust_psm_stack_direction
.vbyte 8, TOC[TC0]
.vbyte 8, 0
.csect .text[PR],2
Copy link
Member

Choose a reason for hiding this comment

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

This appears to be using tabs for whitespace. Is it actually required by the assembler? If not, please replace with spaces to keep this consistent with the rest of the project.

(also applies across this file)

@bzEq
Copy link
Contributor Author

bzEq commented Sep 16, 2022

Testing the PR and filling the README.

@bzEq
Copy link
Contributor Author

bzEq commented Sep 16, 2022

@nagisa For the traceback table part, can add @xingxue-ibm who implemented the libunwind of LLVM on AIX, as reviewer.

@bzEq
Copy link
Contributor Author

bzEq commented Sep 16, 2022

running 5 tests
test catch_panic_leaf ... ok
test deep ... ok
test catch_panic ... ok
test catch_panic_inside ... ok
test panic ... ok

test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.08s

@nagisa Is it sufficient to set Callstack as Yes?

@bzEq bzEq requested a review from nagisa September 16, 2022 11:34
@nagisa
Copy link
Member

nagisa commented Sep 16, 2022

For the traceback table part, can add xingxue-ibm who implemented the libunwind of LLVM on AIX, as reviewer.

I think it is fine as long as it is confirmed these are largely working. Given that unwinding appears to work okay (this is tested by unit tests), I’m happy to not block this on additional reviews.


Is it sufficient to set Callstack as Yes?

Unfortunately no, we don’t have unit tests for that currently.

The kind of testing I did for this was stepping through each instruction of the rust_psm_on_stack functions in one of the examples running under a debugger and seeing if a backtrace (bt) produces meaningful output. Another test is seeing if backtrace can be obtained from the function running on the new stack. The meaningful output in this sense should include frames from the old stack as well. So the expected output is someething along the lines of:

$ gdb target/debug/examples/on_stack_fibo
(gdb) br *0x000055555555e600   -- the first instruction of rust_psm_on_stack
(gdb) run
(gdb) bt
#0  0x000055555555e600 in rust_psm_on_stack ()
#1  0x000055555555c374 in psm::rust_psm_on_stack (...) at src/lib.rs:120
#2  psm::on_stack<core::option::Option<u64>, on_stack_fibo::main::{closure_env#0}> (...) at src/lib.rs:201
#3  0x000055555555e2d1 in on_stack_fibo::main (...) at examples/on_stack_fibo.rs:49
(gdb) ni
(gdb) bt
...
(gdb) ni
(gdb) bt

repeating until the exit of the function.

@bzEq
Copy link
Contributor Author

bzEq commented Sep 22, 2022

Here's my gdb script and result

b rust_psm_on_stack
r
while 1
  ni
  bt
end

Run with gdb target/debug/examples/on_stack_fibo < dbg_cmd >debug.log 2>&1
debug.log outputs(only head and tail pasted)

Thread 2 hit Breakpoint 1, 0x000000010014cd60 in rust_psm_on_stack ()
(gdb)  > > >0x000000010014cd64 in rust_psm_on_stack ()
#0  0x000000010014cd64 in rust_psm_on_stack ()
#1  0x000000010014cf20 in psm::on_stack<core::option::Option<u64>, on_stack_fibo::main::{closure_env#0}> (base=0x11007a000, size=131072, callback=
...)
    at src/lib.rs:193
#2  0x0000000100000d2c in on_stack_fibo::main ()
    at examples/on_stack_fibo.rs:49
0x000000010014cd68 in rust_psm_on_stack ()
...
#0  0x000000010014cd80 in rust_psm_on_stack ()
#1  0x000000010014d064 in psm::rust_psm_on_stack (data=1152921504606842056,
    return_ptr=1152921504606842072,
    callback=@0x11001ad20: 0x10014ce00 <psm::on_stack::with_on_stack<core::option::Option<u64>, on_stack_fibo::main::{closure_env#0}>>, sp=0x11009a000)
    at src/lib.rs:118
#2  psm::on_stack<core::option::Option<u64>, on_stack_fibo::main::{closure_env#0}> (base=0x11007a000, size=131072, callback=...) at src/lib.rs:199
#3  0x0000000100000d2c in on_stack_fibo::main ()
    at examples/on_stack_fibo.rs:49
0x000000010014d064 in psm::rust_psm_on_stack (data=1152921504606842056,
    return_ptr=1152921504606842072,
    callback=@0x11001ad20: 0x10014ce00 <psm::on_stack::with_on_stack<core::option::Option<u64>, on_stack_fibo::main::{closure_env#0}>>, sp=0x11009a000)
    at src/lib.rs:118
...
#0  0x090000000005ffa8 in exit () from /usr/lib/libc.a(shr_64.o)
#1  0x0000000100000554 in __start ()
[Inferior 1 (process 11666350) exited normally]
No stack.
(gdb) quit

@nagisa
Copy link
Member

nagisa commented Sep 24, 2022

Yeah, seems fine to mark that as supported in that case. In an effort to save some time for yourself and myself, I’ll merge this now and I’ll adjust the table as a follow-up. Thanks for contributing!

nagisa added a commit that referenced this pull request Sep 24, 2022
@nagisa nagisa merged commit ef5bbd7 into rust-lang:master Sep 24, 2022
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