Skip to content
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

i#2485: Update DR to use elfutils for DWARF-5 support #2490

Merged
merged 9 commits into from
Jan 14, 2024
15 changes: 8 additions & 7 deletions .github/workflows/ci-aarchxx.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# **********************************************************
# Copyright (c) 2020-2022 Google, Inc. All rights reserved.
# Copyright (c) 2020-2024 Google, Inc. All rights reserved.
# **********************************************************

# Dr. Memory: the memory debugger
Expand Down Expand Up @@ -66,13 +66,14 @@ jobs:
sudo apt-get -y install doxygen jsonlint \
g++-arm-linux-gnueabihf g++-aarch64-linux-gnu
sudo add-apt-repository 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports focal main'
apt download libunwind8:armhf libunwind-dev:armhf liblzma5:armhf \
zlib1g:armhf zlib1g-dev:armhf
mkdir ../extract
pushd ../extract
apt download libunwind8:armhf libunwind-dev:armhf liblzma5:armhf
for i in *.deb; do dpkg-deb -x $i .; done
for i in include lib; do sudo rsync -av ./usr/${i}/arm-linux-gnueabihf/ /usr/arm-linux-gnueabihf/${i}/; done
sudo rsync -av ./lib/arm-linux-gnueabihf/ /usr/arm-linux-gnueabihf/lib/
popd
for i in *.deb; do dpkg-deb -x $i ../extract; done
for i in include lib; do sudo rsync -av ../extract/usr/${i}/arm-linux-gnueabihf/ /usr/arm-linux-gnueabihf/${i}/; done
sudo rsync -av ../extract/usr/include/ /usr/arm-linux-gnueabihf/include/
sudo rsync -av ../extract/lib/arm-linux-gnueabihf/ /usr/arm-linux-gnueabihf/lib/
rm *.deb

- name: Run Suite
working-directory: ${{ github.workspace }}
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/ci-clang.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# **********************************************************
# Copyright (c) 2020-2021 Google, Inc. All rights reserved.
# Copyright (c) 2020-2024 Google, Inc. All rights reserved.
# **********************************************************

# Dr. Memory: the memory debugger
Expand Down Expand Up @@ -63,16 +63,21 @@ jobs:
- name: Create Build Environment
run: |
sudo apt-get update
sudo apt-get -y install doxygen jsonlint g++-multilib libunwind-dev
sudo apt-get -y install doxygen jsonlint g++-multilib libunwind-dev \
zlib1g zlib1g-dev
sudo add-apt-repository 'deb [arch=i386] http://us.archive.ubuntu.com/ubuntu focal main'
apt download libunwind8:i386 libunwind-dev:i386 liblzma5:i386 \
zlib1g:i386 zlib1g-dev:i386
mkdir ../extract
pushd ../extract
apt download libunwind8:i386 libunwind-dev:i386 liblzma5:i386
for i in *.deb; do dpkg-deb -x $i .; done
sudo rsync -av ./usr/lib/i386-linux-gnu/ /lib32/
sudo rsync -av ./lib/i386-linux-gnu/ /lib32/
sudo rsync -av ./usr/include/i386-linux-gnu/ /usr/include/
popd
for i in *.deb; do dpkg-deb -x $i ../extract; done
# find_package(ZLIB) doesn't find /lib32, yet ld.so seems to need lib32,
# so we do both:
sudo rsync -av ../extract/usr/lib/i386-linux-gnu/ /usr/lib/i386-linux-gnu/
sudo rsync -av ../extract/lib/i386-linux-gnu/ /usr/lib/i386-linux-gnu/
sudo rsync -av ../extract/usr/lib/i386-linux-gnu/ /lib32/
sudo rsync -av ../extract/lib/i386-linux-gnu/ /lib32/
sudo rsync -av ../extract/usr/include/i386-linux-gnu/ /usr/include/
rm *.deb

# Downgrade from cmake 3.20 to avoid 32-bit toolchain problems (DRi#4830).
- name: Downgrade cmake
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-docs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# **********************************************************
# Copyright (c) 2020-2021 Google, Inc. All rights reserved.
# Copyright (c) 2020-2024 Google, Inc. All rights reserved.
# **********************************************************

# Dr. Memory: the memory debugger
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Create Build Environment
run: |
sudo apt-get update
sudo apt-get -y install doxygen jsonlint libunwind-dev
sudo apt-get -y install doxygen jsonlint libunwind-dev zlib1g zlib1g-dev

- name: Get Version
id: version
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/ci-package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# **********************************************************
# Copyright (c) 2020-2023 Google, Inc. All rights reserved.
# Copyright (c) 2020-2024 Google, Inc. All rights reserved.
# **********************************************************

# Dr. Memory: the memory debugger
Expand Down Expand Up @@ -62,16 +62,21 @@ jobs:
- name: Create Build Environment
run: |
sudo apt-get update
sudo apt-get -y install doxygen jsonlint g++-multilib libunwind-dev
sudo apt-get -y install doxygen jsonlint g++-multilib libunwind-dev \
zlib1g zlib1g-dev
sudo add-apt-repository 'deb [arch=i386] http://us.archive.ubuntu.com/ubuntu focal main'
apt download libunwind8:i386 libunwind-dev:i386 liblzma5:i386 \
zlib1g:i386 zlib1g-dev:i386
mkdir ../extract
pushd ../extract
apt download libunwind8:i386 libunwind-dev:i386 liblzma5:i386
for i in *.deb; do dpkg-deb -x $i .; done
sudo rsync -av ./usr/lib/i386-linux-gnu/ /lib32/
sudo rsync -av ./lib/i386-linux-gnu/ /lib32/
sudo rsync -av ./usr/include/i386-linux-gnu/ /usr/include/
popd
for i in *.deb; do dpkg-deb -x $i ../extract; done
# find_package(ZLIB) doesn't find /lib32, yet ld.so seems to need lib32,
# so we do both:
sudo rsync -av ../extract/usr/lib/i386-linux-gnu/ /usr/lib/i386-linux-gnu/
sudo rsync -av ../extract/lib/i386-linux-gnu/ /usr/lib/i386-linux-gnu/
sudo rsync -av ../extract/usr/lib/i386-linux-gnu/ /lib32/
sudo rsync -av ../extract/lib/i386-linux-gnu/ /lib32/
sudo rsync -av ../extract/usr/include/i386-linux-gnu/ /usr/include/
rm *.deb

# Downgrade from cmake 3.20 to avoid 32-bit toolchain problems (DRi#4830).
- name: Downgrade cmake
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/ci-x86.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# **********************************************************
# Copyright (c) 2020-2021 Google, Inc. All rights reserved.
# Copyright (c) 2020-2024 Google, Inc. All rights reserved.
# **********************************************************

# Dr. Memory: the memory debugger
Expand Down Expand Up @@ -68,16 +68,21 @@ jobs:
- name: Create Build Environment
run: |
sudo apt-get update
sudo apt-get -y install doxygen jsonlint g++-multilib libunwind-dev
sudo apt-get -y install doxygen jsonlint g++-multilib libunwind-dev \
zlib1g zlib1g-dev
sudo add-apt-repository 'deb [arch=i386] http://us.archive.ubuntu.com/ubuntu focal main'
apt download libunwind8:i386 libunwind-dev:i386 liblzma5:i386 \
zlib1g:i386 zlib1g-dev:i386
mkdir ../extract
pushd ../extract
apt download libunwind8:i386 libunwind-dev:i386 liblzma5:i386
for i in *.deb; do dpkg-deb -x $i .; done
sudo rsync -av ./usr/lib/i386-linux-gnu/ /lib32/
sudo rsync -av ./lib/i386-linux-gnu/ /lib32/
sudo rsync -av ./usr/include/i386-linux-gnu/ /usr/include/
popd
for i in *.deb; do dpkg-deb -x $i ../extract; done
# find_package(ZLIB) doesn't find /lib32, yet ld.so seems to need lib32,
# so we do both:
sudo rsync -av ../extract/usr/lib/i386-linux-gnu/ /usr/lib/i386-linux-gnu/
sudo rsync -av ../extract/lib/i386-linux-gnu/ /usr/lib/i386-linux-gnu/
sudo rsync -av ../extract/usr/lib/i386-linux-gnu/ /lib32/
sudo rsync -av ../extract/lib/i386-linux-gnu/ /lib32/
sudo rsync -av ../extract/usr/include/i386-linux-gnu/ /usr/include/
rm *.deb

# Downgrade from cmake 3.20 to avoid 32-bit toolchain problems (DRi#4830).
- name: Downgrade cmake
Expand Down
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# **********************************************************
# Copyright (c) 2010-2023 Google, Inc. All rights reserved.
# Copyright (c) 2010-2024 Google, Inc. All rights reserved.
# Copyright (c) 2009-2010 VMware, Inc. All rights reserved.
# **********************************************************

Expand Down Expand Up @@ -336,10 +336,12 @@ if (UNIX)
"${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie -Wl,--export-dynamic")
endif ()
endif ()
# TODO i#2485: Add DWARF-5 support.
CHECK_C_COMPILER_FLAG("-gdwarf-5" have_dwarf5)
if (have_dwarf5)
set(EXTRA_FLAGS "${EXTRA_FLAGS} -gdwarf-4")
if (APPLE)
# TODO i#2485: Add DWARF-5 support to Mac.
CHECK_C_COMPILER_FLAG("-gdwarf-5" have_dwarf5)
if (have_dwarf5)
set(EXTRA_FLAGS "${EXTRA_FLAGS} -gdwarf-4")
endif ()
endif ()
# We use C++11.
set(EXTRA_CXXFLAGS "-std=c++11")
Expand Down
50 changes: 25 additions & 25 deletions common/alloc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2010-2021 Google, Inc. All rights reserved.
* Copyright (c) 2010-2024 Google, Inc. All rights reserved.
* Copyright (c) 2008-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -138,7 +138,7 @@ set_brk(byte *new_val)
#endif

static void
alloc_hook(void *wrapcxt, INOUT void **user_data);
alloc_hook(void *wrapcxt, DR_PARAM_INOUT void **user_data);

static void
handle_alloc_post(void *wrapcxt, void *user_data);
Expand Down Expand Up @@ -967,7 +967,7 @@ replace_realloc_size_app(void *p)
}

static void
replace_realloc_size_pre(void *wrapcxt, OUT void **user_data)
replace_realloc_size_pre(void *wrapcxt, DR_PARAM_OUT void **user_data)
{
cls_alloc_t *pt = (cls_alloc_t *)
drmgr_get_cls_field(dr_get_current_drcontext(), cls_idx_alloc);
Expand Down Expand Up @@ -1594,7 +1594,7 @@ modname_is_libc_or_libcpp(const char *modname)

static bool
distinguish_operator_by_decoding(routine_type_t generic_type,
routine_type_t *specific_type OUT,
routine_type_t *specific_type DR_PARAM_OUT,
const char *name, const module_data_t *mod,
size_t modoffs)
{
Expand Down Expand Up @@ -1691,7 +1691,7 @@ distinguish_operator_by_decoding(routine_type_t generic_type,
*/
static bool
distinguish_operator_no_argtypes(routine_type_t generic_type,
routine_type_t *specific_type OUT,
routine_type_t *specific_type DR_PARAM_OUT,
const char *name, const module_data_t *mod,
size_t modoffs)
{
Expand Down Expand Up @@ -2588,10 +2588,10 @@ malloc_wrap__unintercept(app_pc pc, routine_type_t type, alloc_routine_entry_t *
*/

#ifdef WINDOWS
typedef size_t (__stdcall *rtl_size_func_t)(IN reg_t /*really HANDLE*/ Heap,
IN ULONG flags,
IN PVOID ptr);
typedef size_t (*dbg_size_func_t)(IN byte *pc, int blocktype);
typedef size_t (__stdcall *rtl_size_func_t)(DR_PARAM_IN reg_t /*really HANDLE*/ Heap,
DR_PARAM_IN ULONG flags,
DR_PARAM_IN PVOID ptr);
typedef size_t (*dbg_size_func_t)(DR_PARAM_IN byte *pc, int blocktype);
#else
/* points at libc's version, used in initial heap walk */
alloc_size_func_t libc_malloc_usable_size;
Expand Down Expand Up @@ -2944,7 +2944,7 @@ malloc_entry_redzone_size(malloc_entry_t *e)
}

static void
malloc_entry_to_info(malloc_entry_t *e, malloc_info_t *info OUT)
malloc_entry_to_info(malloc_entry_t *e, malloc_info_t *info DR_PARAM_OUT)
{
info->struct_size = sizeof(*info);
info->base = e->start;
Expand Down Expand Up @@ -6391,23 +6391,23 @@ handle_userinfo_pre(void *drcontext, cls_alloc_t *pt, void *wrapcxt,
/* 3 related routines here:
* BOOLEAN NTAPI
* RtlGetUserInfoHeap(
* IN PVOID HeapHandle,
* IN ULONG Flags,
* IN PVOID BaseAddress,
* OUT PVOID *UserValue,
* OUT PULONG UserFlags);
* DR_PARAM_IN PVOID HeapHandle,
* DR_PARAM_IN ULONG Flags,
* DR_PARAM_IN PVOID BaseAddress,
* DR_PARAM_OUT PVOID *UserValue,
* DR_PARAM_OUT PULONG UserFlags);
* BOOLEAN NTAPI
* RtlSetUserValueHeap(
* IN PVOID HeapHandle,
* IN ULONG Flags,
* IN PVOID BaseAddress,
* IN PVOID UserValue);
* DR_PARAM_IN PVOID HeapHandle,
* DR_PARAM_IN ULONG Flags,
* DR_PARAM_IN PVOID BaseAddress,
* DR_PARAM_IN PVOID UserValue);
* BOOLEAN NTAPI
* RtlSetUserFlagsHeap(
* IN PVOID HeapHandle,
* IN ULONG Flags,
* IN PVOID BaseAddress,
* IN ULONG UserFlags);
* DR_PARAM_IN PVOID HeapHandle,
* DR_PARAM_IN ULONG Flags,
* DR_PARAM_IN PVOID BaseAddress,
* DR_PARAM_IN ULONG UserFlags);
*/
app_pc base = (app_pc) drwrap_get_arg(wrapcxt, 2);
if (malloc_is_native(base, pt, true))
Expand Down Expand Up @@ -6526,7 +6526,7 @@ handle_alloc_pre_ex(void *drcontext, cls_alloc_t *pt, void *wrapcxt,
alloc_routine_entry_t *routine);

static void
alloc_hook(void *wrapcxt, INOUT void **user_data)
alloc_hook(void *wrapcxt, DR_PARAM_INOUT void **user_data)
{
app_pc pc = drwrap_get_func(wrapcxt);
/* XXX: for -conservative we should do a lookup and not trust *user_data
Expand Down Expand Up @@ -6957,7 +6957,7 @@ malloc_large_remove(byte *start)
}

bool
malloc_large_lookup(byte *addr, byte **start OUT, size_t *size OUT)
malloc_large_lookup(byte *addr, byte **start DR_PARAM_OUT, size_t *size DR_PARAM_OUT)
{
bool res = false;
rb_node_t *node;
Expand Down
14 changes: 7 additions & 7 deletions common/alloc.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2010-2020 Google, Inc. All rights reserved.
* Copyright (c) 2010-2024 Google, Inc. All rights reserved.
* Copyright (c) 2008-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -194,7 +194,7 @@ malloc_add(app_pc start, app_pc end, app_pc real_end,

/* Looks up mallocs in the "large malloc table" (for mallocs used as stacks) */
bool
malloc_large_lookup(byte *addr, byte **start OUT, size_t *size OUT);
malloc_large_lookup(byte *addr, byte **start DR_PARAM_OUT, size_t *size DR_PARAM_OUT);

bool
malloc_is_pre_us_ex(app_pc start, bool ok_if_invalid);
Expand Down Expand Up @@ -275,17 +275,17 @@ alloc_replace_in_cur_arena(byte *addr);
/* overlap check includes redzone */
bool
alloc_replace_overlaps_delayed_free(byte *start, byte *end,
malloc_info_t *info INOUT);
malloc_info_t *info DR_PARAM_INOUT);

/* overlap check includes redzone */
bool
alloc_replace_overlaps_any_free(byte *start, byte *end,
malloc_info_t *info INOUT);
malloc_info_t *info DR_PARAM_INOUT);

/* overlap check includes redzone */
bool
alloc_replace_overlaps_malloc(byte *start, byte *end,
malloc_info_t *info INOUT);
malloc_info_t *info DR_PARAM_INOUT);

/* Allocate application memory for clients.
* This function can only be used with -replace_malloc and
Expand Down Expand Up @@ -379,7 +379,7 @@ client_handle_realloc_null(app_pc pc, dr_mcontext_t *mc);
* For wrapping:
* Up to the caller to delay, via its return value.
* Returns the value to pass to free(). Return "tofree" for no change.
* The Windows heap param is INOUT so it can be changed as well.
* The Windows heap param is DR_PARAM_INOUT so it can be changed as well.
* client_data is from client_add_malloc_routine().
* For replacing:
* The return value is ignored. Frees are always delayed, unless
Expand All @@ -394,7 +394,7 @@ client_handle_realloc_null(app_pc pc, dr_mcontext_t *mc);
app_pc
client_handle_free(malloc_info_t *info, byte *tofree, dr_mcontext_t *mc,
app_pc free_routine, void *routine_set_data, bool for_reuse
_IF_WINDOWS(ptr_int_t *auxarg INOUT));
_IF_WINDOWS(ptr_int_t *auxarg DR_PARAM_INOUT));

/* For wrapping:
* Never called.
Expand Down
Loading
Loading