From e21fc8770ca4900c131f51a749dac480006d6591 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 18 Jul 2019 17:58:04 +0000 Subject: Add offsetof support to expression evaluator. Summary: We currently don't support offsetof in the expression evaluator as it is implemented as a macro (which then calls __builtin_offsetof) in stddef.h. The best solution would be to include that header (or even better, import Clang's builtin module), but header-parsing and (cross-platform) importing modules is not ready yet. Until we get this working with modules I would say we add the macro to our existing macro list as we already do with other macros from stddef.h/stdint.h. We should be able to drop all of them once we can import the relevant modules by default. rdar://26040641 Reviewers: shafik, davide Reviewed By: davide Subscribers: clayborg, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D64917 llvm-svn: 366476 --- lldb/packages/Python/lldbsuite/test/lang/c/offsetof/Makefile | 3 +++ .../Python/lldbsuite/test/lang/c/offsetof/TestOffsetof.py | 3 +++ lldb/packages/Python/lldbsuite/test/lang/c/offsetof/main.c | 12 ++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 lldb/packages/Python/lldbsuite/test/lang/c/offsetof/Makefile create mode 100644 lldb/packages/Python/lldbsuite/test/lang/c/offsetof/TestOffsetof.py create mode 100644 lldb/packages/Python/lldbsuite/test/lang/c/offsetof/main.c (limited to 'lldb/packages/Python/lldbsuite/test/lang/c') diff --git a/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/Makefile b/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/Makefile new file mode 100644 index 00000000000..cd9ca5c86d8 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../../make +C_SOURCES := main.c +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/TestOffsetof.py b/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/TestOffsetof.py new file mode 100644 index 00000000000..1311a149326 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/TestOffsetof.py @@ -0,0 +1,3 @@ +from lldbsuite.test import lldbinline + +lldbinline.MakeInlineTest(__file__, globals()) diff --git a/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/main.c b/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/main.c new file mode 100644 index 00000000000..cbb4a144418 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/c/offsetof/main.c @@ -0,0 +1,12 @@ +#include + +struct Foo { + int8_t a; + int16_t b; +}; + +int main (int argc, char const *argv[]) { + struct Foo f; + return f.a; //% self.expect("expr offsetof(Foo, a)", substrs = ['= 0']) + //% self.expect("expr offsetof(Foo, b)", substrs = ['= 2']) +} -- cgit v1.2.3