Hi,
I'm interested in porting LLDB to PowerPC 64 little endian (e.g: POWER8 machines) on Linux platform but before starting such work, I wanted to know if somebody is already doing it or also if there is anything prohibitive in doing so (Probably relevant to this question: clang supports POWER8 already, which is good).
The interesting resources I found at the moment are: the special debug registers as described on the ISA [1]; dealing with Ptrace API[2]; and also a presentation pointing out how LLDB was ported to MSP430 architecture[3].
Are there any other resources you'd recommend? I tried searching in the mailing list but I didn't find more relevant information.
Thanks. Comments are welcome 
[1] Home - OpenPOWER Foundation (Book III, chapter 8, page 1103)
[2] How debugger works - Alex on Linux
[3] http://llvm.org/devmtg/2016-03/Tutorials/LLDB-tutorial.pdf
Hi Gustavo,
I don't see anything which should prevent you from doing that.
Probably the first place you should look at is
"source/Plugins/Process/Linux/NativeRegisterContext_***". This is the
thing which defines what a "register" is and how to read/write it, and
it's the main thing you will need to implement.
Hi Pavel,
From: Pavel Labath [mailto:labath@google.com]
Sent: quinta-feira, 6 de julho de 2017 07:13
To: Gustavo Serra Scalet <gustavo.scalet@eldorado.org.br>
Cc: lldb-dev@lists.llvm.org
Subject: Re: [lldb-dev] Port LLDB to ppc64le (ABIv2) on linux
Hi Gustavo,
I don't see anything which should prevent you from doing that.
Probably the first place you should look at is
"source/Plugins/Process/Linux/NativeRegisterContext_***". This is the
thing which defines what a "register" is and how to read/write it, and
it's the main thing you will need to implement.
Great. I noticed these classes missing on link time so I'm taking a closer look.
Thanks
Hi Gustavo,
Were you interested in support for live debugging via ptrace or reading from core files? (Or both!)
I did have a look at what it would take to add support for Power PC little endian core files. I didn’t seem too bad as the existing code for PPC 64 support just needed to be aware of LE as well. I may be able to resurrect the patch if master hasn’t diverged too much.
Live debugging looked a bit more complicated but that’s probably because most of my experience has been with post-mortem debugging. I think I stopped work on the core file support because I didn’t have the time to learn about the live debugging side and it didn’t seem to make sense to add core file support without live debug.
Howard Hellyer
J9 RAS Developer
IBM Runtime Technologies, IBM Systems
Hi,
From: Howard Hellyer [mailto:HHELLYER@uk.ibm.com]
Sent: quinta-feira, 6 de julho de 2017 09:59
To: Gustavo Serra Scalet <gustavo.scalet@eldorado.org.br>
Cc: lldb-dev@lists.llvm.org
Subject: Re: [lldb-dev] Port LLDB to ppc64le (ABIv2) on linux
Hi Gustavo,
Were you interested in support for live debugging via ptrace or reading
from core files? (Or both!)
Mainly live debugging, but I have the feeling that implementing post-mortem wouldn't be such a hassle afterwards. (register read/write, stack walk... they would all be done at this point).
I did have a look at what it would take to add support for Power PC
little endian core files. I didn't seem too bad as the existing code for
PPC 64 support just needed to be aware of LE as well. I may be able to
resurrect the patch if master hasn't diverged too much.
Live debugging looked a bit more complicated but that's probably because
most of my experience has been with post-mortem debugging. I think I
stopped work on the core file support because I didn't have the time to
learn about the live debugging side and it didn't seem to make sense to
add core file support without live debug.
Wait. As far as I understood, LLDB already supports ppc64 big endian, right? (particularly the ppc970 model) Plenty of things changed since then but I guess I can use it as a reference (despite endianness, of course).
Hi Gustavo,
Were you interested in support for live debugging via ptrace or reading
from core files? (Or both!)
Mainly live debugging, but I have the feeling that implementing
post-mortem wouldn’t be such a hassle afterwards. (register read/
write, stack walk… they would all be done at this point).
I think on Linux ELF and DWARF take care of most of the issues, my changes were mostly to do with making LLDB aware that ppc64 and little endian was an option and sending it down the right code paths. Once it knew the registers for that combination I think it could cope with walking the stacks.
Live debugging looked a bit more complicated but that’s probably because
most of my experience has been with post-mortem debugging. I think I
stopped work on the core file support because I didn’t have the time to
learn about the live debugging side and it didn’t seem to make sense to
add core file support without live debug.
Wait. As far as I understood, LLDB already supports ppc64 big
endian, right? (particularly the ppc970 model) Plenty of things
changed since then but I guess I can use it as a reference (despite
endianness, of course).
Yes, but I think it supports ppc64 on FreeBSD. The register context code in source/Plugins/Process/Linux and source/Plugins/Process/FreeBSD suggests that’s the case. I suspect you can use the FreeBSD code as a reference. However this is where it goes outside what I’m familiar with and you are probably better off asking someone else for more details. There’s a RegisterContextCorePOSIX_powerpc in source/Plugins/Process/elf-core/ on the post-mortem side already which made the Linux core dump support easier.
Howard Hellyer
J9 RAS Developer
IBM Runtime Technologies, IBM Systems
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU