Skip to content

Commit

Permalink
Fixes several issues with the latest DR and recent Linux platforms:
Browse files Browse the repository at this point in the history
+ DWARF5 is now the gcc default but is not supported (#2485) so we add
  -gdwarf-4 to our test flags and the docs.

+ Adds Linux syscall entries for rseq and getrandom, seen on tiny apps now.

+ Fixes a bug in the size of kernel_sigset_t which was resulting in
  false positive uninitialized errors in rt_sigaction.

+ Updates drltrace code for droption now being in a namespace.

+ Adds --recursive to the git submodule commands to get minizip for
  the DR build.

+ Relaxes the drltrace tests to allow __IO_puts and __open.
  • Loading branch information
derekbruening committed Sep 21, 2023
1 parent f116307 commit 793053e
Show file tree
Hide file tree
Showing 19 changed files with 116 additions and 58 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-aarchxx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
submodules: true
submodules: recursive

# Cancel any prior runs for a PR (but do not cancel master branch runs).
- uses: n1hility/cancel-previous-runs@v2
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
submodules: true
submodules: recursive

# Cancel any prior runs for a PR (but do not cancel master branch runs).
- uses: n1hility/cancel-previous-runs@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
submodules: true
submodules: recursive

# Cancel any prior runs for a PR (but do not cancel master branch runs).
- uses: n1hility/cancel-previous-runs@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
submodules: true
submodules: recursive

- name: Fetch Sources
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
submodules: true
submodules: recursive

# Cancel any prior runs for a PR (but do not cancel master branch runs).
- uses: n1hility/cancel-previous-runs@v2
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
submodules: true
submodules: recursive

- name: Fetch Sources
run: git fetch --no-tags --depth=1 origin master
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
submodules: true
submodules: recursive

- name: Fetch Sources
run: git fetch --no-tags --depth=1 origin master
Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
submodules: true
submodules: recursive

- name: Fetch Sources
run: git fetch --no-tags --depth=1 origin master
Expand Down Expand Up @@ -246,7 +246,7 @@ jobs:
# We need a checkout to run git log for the version.
- uses: actions/checkout@v2
with:
submodules: true
submodules: recursive

- name: Get Version
id: version
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
submodules: true
submodules: recursive

# Cancel any prior runs for a PR (but do not cancel master branch runs).
- uses: n1hility/cancel-previous-runs@v2
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
submodules: true
submodules: recursive

# Cancel any prior runs for a PR (but do not cancel master branch runs).
- uses: n1hility/cancel-previous-runs@v2
Expand Down Expand Up @@ -127,7 +127,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
submodules: true
submodules: recursive

# Cancel any prior runs for a PR (but do not cancel master branch runs).
- uses: n1hility/cancel-previous-runs@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
submodules: true
submodules: recursive

# Cancel any prior runs for a PR (but do not cancel master branch runs).
- uses: n1hility/cancel-previous-runs@v2
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# **********************************************************
# Copyright (c) 2010-2022 Google, Inc. All rights reserved.
# Copyright (c) 2010-2023 Google, Inc. All rights reserved.
# Copyright (c) 2009-2010 VMware, Inc. All rights reserved.
# **********************************************************

Expand Down Expand Up @@ -336,6 +336,11 @@ 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")
endif ()
# We use C++11.
set(EXTRA_CXXFLAGS "-std=c++11")
set(CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER}
Expand Down
10 changes: 5 additions & 5 deletions drltrace/CMakeLists.txt
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-2023 Google, Inc. All rights reserved.
# Copyright (c) 2009-2010 VMware, Inc. All rights reserved.
# **********************************************************

Expand Down Expand Up @@ -194,11 +194,11 @@ else ()
set(libcall_both_variants " arg 0: done \\(type=char\\*, size=0x([0-9a-f]+)\\)\n")
set(libcall_args1_01 ${libcall_both_variants})

set(libcall_args2_0 " arg 0: /dev/null \\(type=char \\*\\*, size=0x([0-9a-f]+)\\)\n")
set(libcall_args2_1 " arg 1: 0x([0-9a-f]+) \\(type=<unknown>\\*, size=0x([0-9a-f]+)\\)\n")
set(libcall_args2_0 " arg 0: /dev/null \\(type=char\\*, size=0x([0-9a-f]+)\\)\n")
set(libcall_args2_1 " arg 1: 0x([0-9a-f]+) \\(type=int, size=0x([0-9a-f]+)\\)\n")

set(libcall_name1 "~~([0-9a-f]+)~~ libc.so.6!puts\n")
set(libcall_name2 "~~([0-9a-f]+)~~ libc.so.6!open\n")
set(libcall_name1 "~~([0-9a-f]+)~~ libc.so.6!.*puts\n")
set(libcall_name2 "~~([0-9a-f]+)~~ libc.so.6!.*open\n")
endif(WIN32)
set_tests_properties(drltrace_libcalls PROPERTIES PASS_REGULAR_EXPRESSION
${libcall_name1}${libcall_args1_01}${libcall_args1_02}${libcall_ret})
Expand Down
5 changes: 4 additions & 1 deletion drltrace/drltrace.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ***************************************************************************
* Copyright (c) 2013-2019 Google, Inc. All rights reserved.
* Copyright (c) 2013-2023 Google, Inc. All rights reserved.
* ***************************************************************************/

/*
Expand Down Expand Up @@ -59,6 +59,9 @@
* the library entries.
*/

using ::dynamorio::droption::droption_parser_t;
using ::dynamorio::droption::DROPTION_SCOPE_CLIENT;

/* Where to write the trace */
static file_t outf;

Expand Down
6 changes: 5 additions & 1 deletion drltrace/drltrace_frontend.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ***************************************************************************
* Copyright (c) 2017-2019 Google, Inc. All rights reserved.
* Copyright (c) 2017-2023 Google, Inc. All rights reserved.
* ***************************************************************************/

/*
Expand Down Expand Up @@ -46,6 +46,10 @@
#include "utils.h"
#include <string.h>

using ::dynamorio::droption::droption_parser_t;
using ::dynamorio::droption::DROPTION_SCOPE_ALL;
using ::dynamorio::droption::DROPTION_SCOPE_FRONTEND;

#define MAX_DR_CMDLINE (MAXIMUM_PATH*6)

#define DRLTRACE_ERROR(msg, ...) do { \
Expand Down
6 changes: 4 additions & 2 deletions drltrace/drltrace_linux.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ***************************************************************************
# Copyright (c) 2017 Google, Inc. All rights reserved.
# Copyright (c) 2017-2023 Google, Inc. All rights reserved.
# ***************************************************************************
#
#
Expand Down Expand Up @@ -47,4 +47,6 @@ int|strcmp|char *|char *
int|wcscmp|wchar *|wchar *
int|printf|char *
int|puts|char *

int|_IO_puts|char *
int|open|char *|int
int|__open|char *|int
10 changes: 9 additions & 1 deletion drltrace/drltrace_options.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ***************************************************************************
* Copyright (c) 2013-2019 Google, Inc. All rights reserved.
* Copyright (c) 2013-2023 Google, Inc. All rights reserved.
* ***************************************************************************/

/*
Expand Down Expand Up @@ -33,6 +33,14 @@
#include "droption.h"
#include "drltrace_options.h"

using ::dynamorio::droption::DROPTION_FLAG_ACCUMULATE;
using ::dynamorio::droption::DROPTION_FLAG_INTERNAL;
using ::dynamorio::droption::DROPTION_FLAG_SWEEP;
using ::dynamorio::droption::DROPTION_SCOPE_ALL;
using ::dynamorio::droption::DROPTION_SCOPE_CLIENT;
using ::dynamorio::droption::DROPTION_SCOPE_FRONTEND;
using ::dynamorio::droption::droption_t;

/* Frontend scope is defined here because if logdir is a forbidden path we have to change
* it and provide for our client manually.
*/
Expand Down
36 changes: 18 additions & 18 deletions drltrace/drltrace_options.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ***************************************************************************
* Copyright (c) 2013-2019 Google, Inc. All rights reserved.
* Copyright (c) 2013-2023 Google, Inc. All rights reserved.
* ***************************************************************************/

/*
Expand Down Expand Up @@ -32,20 +32,20 @@

#include "droption.h"

extern droption_t<std::string> op_logdir;
extern droption_t<bool> op_only_from_app;
extern droption_t<bool> op_follow_children;
extern droption_t<bool> op_print_ret_addr;
extern droption_t<unsigned int> op_unknown_args;
extern droption_t<int> op_max_args;
extern droption_t<bool> op_config_file_default;
extern droption_t<std::string> op_config_file;
extern droption_t<std::string> op_sysnum_file;
extern droption_t<std::string> op_symcache_dir;
extern droption_t<bool> op_ignore_underscore;
extern droption_t<std::string> op_only_to_lib;
extern droption_t<bool> op_help;
extern droption_t<bool> op_version;
extern droption_t<unsigned int> op_verbose;
extern droption_t<bool> op_use_config;
extern droption_t<std::string> op_ltracelib_ops;
extern dynamorio::droption::droption_t<std::string> op_logdir;
extern dynamorio::droption::droption_t<bool> op_only_from_app;
extern dynamorio::droption::droption_t<bool> op_follow_children;
extern dynamorio::droption::droption_t<bool> op_print_ret_addr;
extern dynamorio::droption::droption_t<unsigned int> op_unknown_args;
extern dynamorio::droption::droption_t<int> op_max_args;
extern dynamorio::droption::droption_t<bool> op_config_file_default;
extern dynamorio::droption::droption_t<std::string> op_config_file;
extern dynamorio::droption::droption_t<std::string> op_sysnum_file;
extern dynamorio::droption::droption_t<std::string> op_symcache_dir;
extern dynamorio::droption::droption_t<bool> op_ignore_underscore;
extern dynamorio::droption::droption_t<std::string> op_only_to_lib;
extern dynamorio::droption::droption_t<bool> op_help;
extern dynamorio::droption::droption_t<bool> op_version;
extern dynamorio::droption::droption_t<unsigned int> op_verbose;
extern dynamorio::droption::droption_t<bool> op_use_config;
extern dynamorio::droption::droption_t<std::string> op_ltracelib_ops;
16 changes: 9 additions & 7 deletions drmemory/docs/using.dox
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2011-2022 Google, Inc. All rights reserved.
* Copyright (c) 2011-2023 Google, Inc. All rights reserved.
* Copyright (c) 2009-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -228,29 +228,31 @@ but should eliminate skipped frames.
********************
\section sec_prep_linux Linux

Dr. Memory currently only supports DWARF2 line information, not stabs.
DWARF2 is the default for modern versions of \p gcc.
Dr. Memory currently only supports DWARF2 through DWARF4 line information, not
stabs nor DWARF5. DWARF4 can be requested from the compiler with the `-gdwarf-4`
flag.

Here is a sample command line for compiling your application that combines
all of the above recommendations:

\verbatim
g++ -g -fno-inline -fno-omit-frame-pointer myfile1.cpp myfile2.cpp -o myapp
g++ -g -gdwarf-4 -fno-inline -fno-omit-frame-pointer myfile1.cpp myfile2.cpp -o myapp
\endverbatim

********************
\section sec_prep_mac Mac

Ensure your compiler is able to build 32-bit applications.

Dr. Memory currently only supports DWARF2 line information, not stabs.
DWARF2 is the default for modern versions of \p gcc as well as \p clang.
Dr. Memory currently only supports DWARF2 through DWARF4 line information, not
stabs nor DWARF5. DWARF4 can be requested from the compiler with the `-gdwarf-4`
flag.

Here is a sample command line for compiling your application that combines
all of the above recommendations:

\verbatim
c++ -m32 -g -fno-inline -fno-omit-frame-pointer myfile1.cpp myfile2.cpp -o myapp
c++ -m32 -g -gdwarf-4 -fno-inline -fno-omit-frame-pointer myfile1.cpp myfile2.cpp -o myapp
\endverbatim

********************
Expand Down
15 changes: 13 additions & 2 deletions drsyscall/linux_defines.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2011-2022 Google, Inc. All rights reserved.
* Copyright (c) 2011-2023 Google, Inc. All rights reserved.
* Copyright (c) 2007-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -226,7 +226,18 @@ struct rlimit64 {
* each (-> 8 bytes vs. 128 bytes)
*/
#define MAX_SIGNUM 64
#define _NSIG_WORDS (MAX_SIGNUM / sizeof(unsigned long))
/* size of long */
#ifdef X64
# define _NSIG_BPW 64
#else
# define _NSIG_BPW 32
#endif
#ifdef LINUX
# define _NSIG_WORDS (MAX_SIGNUM / _NSIG_BPW)
#else
# define _NSIG_WORDS 1 /* avoid 0 */
#endif

typedef struct _kernel_sigset_t {
unsigned long sig[_NSIG_WORDS];
} kernel_sigset_t;
Expand Down
27 changes: 25 additions & 2 deletions drsyscall/table_linux.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2010-2022 Google, Inc. All rights reserved.
* Copyright (c) 2010-2023 Google, Inc. All rights reserved.
* Copyright (c) 2009-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -1100,7 +1100,14 @@ syscall_info_t syscall_info[] = {
{{PACKNUM(299,337,365,AARCH64_recvmmsg),0},"recvmmsg", UNKNOWN, RLONG, 0, },
{{PACKNUM(300,338,367,AARCH64_fanotify_init),0},"fanotify_init", UNKNOWN, RLONG, 0, },
{{PACKNUM(301,339,368,AARCH64_fanotify_mark),0},"fanotify_mark", UNKNOWN, RLONG, 0, },
{{PACKNUM(302,340,369,AARCH64_prlimit64),0},"prlimit64", UNKNOWN, RLONG, 0, },
{{PACKNUM(302,340,369,AARCH64_prlimit64),0},"prlimit64", OK, RLONG, 4,
{
{0, sizeof(pid_t), SYSARG_INLINED, DRSYS_TYPE_SIGNED_INT},
{1, sizeof(int), SYSARG_INLINED, DRSYS_TYPE_SIGNED_INT},
{2, sizeof(struct rlimit), R},
{3, sizeof(struct rlimit), W},
}
},
{{PACKNUM(303,341,370,AARCH64_name_to_handle_at),0},"name_to_handle_at", UNKNOWN, RLONG, 0, },
{{PACKNUM(304,342,371,AARCH64_open_by_handle_at),0},"open_by_handle_at", UNKNOWN, RLONG, 0, },
{{PACKNUM(305,343,372,AARCH64_clock_adjtime),0},"clock_adjtime", UNKNOWN, RLONG, 0, },
Expand Down Expand Up @@ -1139,6 +1146,22 @@ syscall_info_t syscall_info[] = {
{2, sizeof(int), SYSARG_INLINED, DRSYS_TYPE_SIGNED_INT},
}
},
/* TODO: Fill in the ones in between. */
{{PACKNUM(318,355,384,AARCH64_getrandom),0},"getrandom", OK, RLONG, 3,
{
{0, -1, W},
{1, sizeof(size_t), SYSARG_INLINED, DRSYS_TYPE_SIGNED_INT},
{2, sizeof(int), SYSARG_INLINED, DRSYS_TYPE_SIGNED_INT},
}
},
{{PACKNUM(334,386,398,AARCH64_rseq),0},"rseq", OK, RLONG, 4,
{
{0, -1, R},
{1, sizeof(int), SYSARG_INLINED, DRSYS_TYPE_SIGNED_INT},
{2, sizeof(int), SYSARG_INLINED, DRSYS_TYPE_SIGNED_INT},
{3, sizeof(int), SYSARG_INLINED, DRSYS_TYPE_SIGNED_INT},
}
},

/**************************************************/
/* 64-bit only (some are on ARM too) */
Expand Down
Loading

0 comments on commit 793053e

Please sign in to comment.