[Lldb-commits] [PATCH] D92063: [LLDB] RegisterInfoPOSIX_arm64 remove unused bytes from g/G packet

Muhammad Omair Javaid via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 25 14:23:21 PST 2020


omjavaid added a comment.

In D92063#2416162 <https://reviews.llvm.org/D92063#2416162>, @labath wrote:

> + at mgorny, as he's been navigating these waters lately...
>
> So... I presume we can't just slap `__attribute__((packed))` on the structure, because the kernel actually expects that the data structure will have the extra space for the padding. Is that so?
>
> Even if we can't, I'm wondering if it wouldn't be cleaner to use two structures for this. Something like:
>
>   LLVM_PACKED_START
>   struct GPR {
>     // as before...
>   };
>   /// Big comment explaining the purpose of padding
>   struct GPRBuffer: GPR {
>     uint32_t pad;
>   };
>   LLVM_PACKED_END
>
> and then using GPR or GPRBuffer accordingly. What do you think?

So I didnt check this before but FreeBSD and Linux have different ptrace GPR size expectation. Here is what FreeBSD struct looks like:

struct reg {
	uint64_t x[30];
	uint64_t lr;
	uint64_t sp;
	uint64_t elr;
	uint32_t spsr;
};

While on Linux it looks something like this:

struct {
	u64 regs[31];
	u64 sp;
	u64 pc;
	u64 pstate;
};

So I am going to put a __attribute__((packed)) and use the same for FreeBSD while going to isolate Linux implementation in my next update.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92063/new/

https://reviews.llvm.org/D92063



More information about the lldb-commits mailing list