Commit Graph

199 Commits

Author SHA1 Message Date
Sergiu Deitsch
f3bd836de4
Merge pull request #281 from sergiud/msvc-error-define
Fixed undeclared identifier error
2018-01-02 02:21:51 +01:00
Sergiu Deitsch
85d49f7a47 logging_unittest: fixed undeclared identifier error (fixes #267) 2018-01-02 02:18:00 +01:00
Fumitoshi Ukai
2063b38708
Merge pull request #261 from pcc/fix3
Compute base addresses from program headers while reading /proc/self/maps.
2017-11-10 16:55:27 +09:00
Peter Collingbourne
c4d37a78cc Compute base addresses from program headers while reading /proc/self/maps.
We previously had logic to compute the base address from program
headers as part of symbolization. The problem is that we need a correct
base address earlier in order to adjust a PC into the image's address
space, as these addresses can appear in unsymbolized output.

There was previously an assumption that only the mapping that
was lowest in the address space did not need to be adjusted. This
assumption is not guaranteed (for example, the kernel may choose to
map an ET_DYN lowest) and in fact turned out to be wrong in binaries
linked with lld because the first mapping is read-only.

The solution is to move the program header reading logic into the
code that reads /proc/self/maps.

There is a change in semantics for clients that install a callback
using the InstallSymbolizeOpenObjectFileCallback function. Any such
clients will need to return a correct base address from the callback
by reading program headers using code similar to that in the function
OpenObjectFileContainingPcAndGetStartAddress.
2017-11-08 14:15:02 -08:00
Sergiu Deitsch
bac8811710
Merge pull request #106 from dimhotepus/master
Cache strlen outside of cycles (PVS-Studio)
2017-11-04 16:22:21 +01:00
Fumitoshi Ukai
9f8a9a9a0d Shell escape arguments to /bin/mail. 2017-10-31 13:04:26 +09:00
Shinichiro Hamaji
56b81ea796 Style fixes for consistency 2017-10-20 16:11:31 +09:00
Shinichiro Hamaji
ebf81ac476 Merge pull request #245 from DariuszOstolski/issue211
Fix username lookup in case of missing USER environment variable
2017-10-20 16:09:28 +09:00
Dariusz Ostolski
4912af30f9 #253: Use MS preprocessor idiom to disable warning 2017-10-18 20:56:49 +02:00
Shinichiro Hamaji
d0531421fd Merge pull request #226 from sergiud/zero-allocation-log-failure
Zero allocation fix
2017-10-12 00:25:02 +09:00
Sergiu Deitsch
2fe6508e53 fixed gcc logging failure 2017-10-11 00:45:08 +02:00
Dariusz Ostolski
2d3cf2681d Fix username lookup in case of missing USER environment variable 2017-09-19 22:23:53 +02:00
Shinichiro Hamaji
2a6df66252 Merge pull request #228 from sergiud/dll-export-fix
Fix for missing exports (fixes #227)
2017-08-10 00:06:08 +09:00
Sergiu Deitsch
1bfae38300 added missing exports (fixes #227) 2017-08-09 15:21:32 +02:00
Shinichiro Hamaji
246a5896f1 Merge pull request #225 from jray272/remove-log-every-n-assert
Fix LOG_EVERY_N with clang -Wunused-local-typedef
2017-08-09 16:35:05 +09:00
Jim Ray
dd19fb2466 Remove GOOGLE_GLOG_COMPILE_ASSERT
This compile time assert is no longer used anywhere in glog. Remove
it.
2017-08-09 00:09:16 -07:00
Jim Ray
8b3023f7e4 Fix LOG_EVERY_N with clang -Wunused-local-typedef
Glog uses a pre-C++11 compile time assert to verify the validity of
the severity parameter for LOG_EVERY_N. Unfortunately, some compilers
will complain about the usage of LOG_EVERY_N with
"-Wunused-local-typedef" due to the way the compile time assert is
constructed. This makes it impossible to use LOG_EVERY_N with this
warning treated as an error.

The fix simply removes the assert entirely. This is safe to do since
you can't put anything invalid into the severity parameters without
generating a compile error elsewhere. This has been safe to do ever
since the GLOG_ prefixes were added as part of 6febec361e.

Fixes #223
2017-08-06 00:17:50 -07:00
Jim Ray
8ed1668cdb Update Windows logging.h based on 2df0ca34aa
Commit changes to src/windows/glog/logging.h that were missed in
2df0ca34aa. Because a change to src/glog/logging.h.in was made,
src/windows/preprocess.sh needed to be run.
2017-08-06 00:13:30 -07:00
Shinichiro Hamaji
a808e435b7 Merge pull request #157 from sergiud/cygwin-support
Cygwin support
2017-07-06 15:00:06 +09:00
Shinichiro Hamaji
a835da8e08 Merge pull request #158 from sergiud/zero-allocation
[RFC] reduce heap memory allocations to zero
2017-07-06 14:58:37 +09:00
Shinichiro Hamaji
96f6656551 Merge pull request #145 from pixelb/rate-limit-posix-fadvise
rate limit calls to posix_fadvise()
2017-07-06 14:52:13 +09:00
Hans-Andreas Engel
2df0ca34aa reduce memory allocations to zero 2017-07-06 00:02:38 +02:00
Andrew Schwartzmeyer
d1f49ba5aa Support signal handler on Windows 2017-06-27 10:50:20 -07:00
Andrew Schwartzmeyer
7f95ecfdc7 Link to DbgHelp using pre-processor directive
This method ensure that all users of glog get automatically linked to
the DbgHelp library without needing to set compiler flags.
2017-06-27 10:50:20 -07:00
Andrew Schwartzmeyer
e2caf9876e Export GetStackTrace
Necessary when building with BUILD_SHARED_LIBS=1.
2017-06-27 10:50:20 -07:00
Andrew Schwartzmeyer
f1d64f7deb Support symbolizer and demangler on Windows 2017-06-27 10:50:20 -07:00
Andrew Schwartzmeyer
e5d36443c6 Support stacktrace on Windows 2017-06-26 18:47:34 -07:00
Andrew Schwartzmeyer
9c1d0e6f6e Copy stacktrace_generic-inl.h for Windows 2017-06-26 16:21:10 -07:00
Shinichiro Hamaji
a6266db97a Add a hack for naive include scanners 2017-05-09 17:35:18 +09:00
Shinichiro Hamaji
ee9d487782 Define OS_LINUX only if it's not defined yet 2017-05-09 17:22:38 +09:00
Shinichiro Hamaji
c4814b729a symbolize: Allow 4kB stack consumption on PPC64 2017-05-09 17:21:16 +09:00
Shinichiro Hamaji
f278d734c1 x86 stacktrace: Use __builtin_frame_address if possible 2017-05-09 17:14:15 +09:00
Shinichiro Hamaji
0d78884a22 Relax test for symbolize
Don't rely on an internal-linkage extern "C" function having an
unmangled name. This isn't required by the ABI, and in fact is not
valid for a conforming compiler(!). Instead, allow symbolization to
produce either a mangled or an unmangled name here.
2017-05-09 17:14:15 +09:00
Shinichiro Hamaji
7314fa3f86 Use LOG(FATAL) instead of CHECK(false) 2017-05-09 17:14:12 +09:00
Shinichiro Hamaji
f012836db1 Run src/windows/preprocess.sh 2017-05-09 16:41:58 +09:00
Ning Ren
0d8c6340f8 CHECK_NOTNULL works with smart pointers when compiled in C++11. 2017-04-20 15:32:24 -07:00
mayah
8fa778aa12 Add __declspec(noreturn) on Win
Currently cl.exe doesn't know LOG(FATAL) exits the program. Set
__declspec(noreturn).
2017-03-07 11:22:24 +09:00
Yoshisato Yanagisawa
027332ffac DCHECK_ALWAYS_ON to make D* enabled under NDEBUG
The macro NDEBUG could be automatically defined for release build on
some build environments (e.g. MSVC).  If we use NDEBUG as a key to
distinguish using DCHECK as CHECK (I call this DCHECK is enabled) or
not, we cannot make DCHECK enabled for release build on such
environments.

Considering people use a program with glog for presubmit testing or
dogfooding, they should need to do release build with DCHECK enabled.
2017-02-08 17:23:37 +09:00
Sergiu Deitsch
96a09ae01a fixed cygwin compilation errors 2017-01-17 12:47:11 +01:00
Pádraig Brady
dacd296796 rate limit calls to posix_fadvise()
There can be a large kernel overhead involved in POSIX_FADV_DONTNEED.
There is no point in calling this per item logged, so rate limit
to at most once per 2MiB written.

With a simple test program that logs 100K items at WARNING level:

Before:

  $ time strace -c -e fadvise64 log.test \
    -log_dir=/dev/shm -logtofiles=true -logtostderr=false
  % time     seconds  usecs/call     calls    errors syscall
  ------ ----------- ----------- --------- --------- ----------------
  100.00   12.522509         125     99957           fadvise64
  ------ ----------- ----------- --------- --------- ----------------
  real    0m52.671s
  user    0m2.194s
  sys     0m44.022s

After:

  $ time strace -c -e fadvise64 log.test \
    -log_dir=/dev/shm -logtofiles=true -logtostderr=false

  % time     seconds  usecs/call     calls    errors syscall
  ------ ----------- ----------- --------- --------- ----------------
  100.00    0.000759         152         5           fadvise64
  ------ ----------- ----------- --------- --------- ----------------
  real    0m4.206s
  user    0m1.436s
  sys     0m3.153s

Fixes issue #84
2016-12-09 19:45:34 +00:00
Fumitoshi Ukai
cf36dabd8e Merge pull request #127 from MinGW-caffe/master
try to avoid the error "conflicting declaration 'typedef DWORD pthread_t'" etc. in MinGW
2016-10-19 16:29:34 +09:00
Fumitoshi Ukai
bf766fac4f Merge pull request #123 from yying/master
Set sinks_ to NULL after deletion in LogDestination::DeleteLogDestinations
2016-10-19 16:10:39 +09:00
Fumitoshi Ukai
7cff62028c Merge pull request #116 from pcc/fix2
Fix autotools build.
2016-10-19 16:06:38 +09:00
MiniLight
9c584dd2ed try to avoid the error "conflicting declaration 'typedef DWORD
pthread_t'" etc.
2016-10-03 08:00:09 +08:00
Andy Ying
a00dfdfc53 NULL sinks_ after deletion to prevent dangling pointer 2016-09-11 01:16:32 -04:00
Peter Collingbourne
8e98eb2a5a Fix autotools build.
It looks like commit 3c49b93 modified the auto-generated file src/config.h.in
to add a definition of macro GOOGLE_GLOG_DLL_DECL. One of the autotools
reverts this change upon running "make", causing the build to fail when a
source file includes demangle.h.

To fix the problem, revert the change to src/config.h.in and include
glog/logging.h from demangle.h which provides a definition of that macro.
2016-06-22 18:48:32 -07:00
Peter Collingbourne
a93a4511ec symbolize: Calculate a module's zero VA using program headers.
Previously we were using a module's "start address", i.e. the
address at which the module's executable region was mapped, as the
zero virtual address, i.e. the address from which the DSO's virtual
addresses are calculated. This works fine for DSOs created by the
bfd and gold linkers, which will emit a PT_LOAD directive into the
program header which loads the executable region at virtual address
(p_vaddr) and file offset (p_offset) 0.

However, the lld linker may place a read-only region before the
executable region, meaning that both p_vaddr and p_offset for the
executable region are non-zero. This means that any symbols resolved
by the symbolizer are resolved to an incorrect virtual address. To
correctly calculate the address corresponding to virtual address zero,
we need to take into account p_vaddr and p_offset.

Specifically, the calculation starts with the "base address", i.e. the
start address minus the file offset. To get from the base address to
virtual address zero, we first add p_offset. This gives us the mapped
address of the start of the segment, or in other words the mapped
address corresponding to the virtual address of the segment. (Note
that this is distinct from the start address, as p_offset is not
guaranteed to be page aligned.) We then subtract p_vaddr, which takes
us to virtual address zero.
2016-06-22 18:41:43 -07:00
dimhotepus
4544e968ab Cache strlen outside of cycles (PVS-Studio) 2016-04-30 14:24:12 +03:00
Fumitoshi Ukai
de6149ef8e Merge pull request #101 from yasushi-saito/master
Allow permission line in /proc/self/map to be "rwx", not just "r-x".
2016-04-15 17:05:30 +09:00
Fumitoshi Ukai
202b395c04 Merge pull request #91 from abdasgupta/master
Added support for PowerPC.
2016-04-13 14:00:49 +09:00