Граф коммитов

18 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 27173e3735
Allow `RUBY_DEBUG_LOG` format to be empty
GCC warns of empty format strings, perhaps because they have no
effects in printf() and there are better ways than sprintf().
However, ruby_debug_log() adds informations other than the format,
this warning is not the case.
2022-08-06 10:52:00 +09:00
Nobuyoshi Nakada 2b9374768f
`RUBY_DEBUG_LOG2` should filter against the given `file` 2022-07-28 16:05:48 +09:00
Kazuhiro NISHIYAMA 67a9845a7a
Fix compile error
```
compiling ../debug.c
../debug.c:452:1: error: conflicting types for 'ruby_debug_log_filter'
ruby_debug_log_filter(const char *func_name, const char *file_name)
^
../vm_debug.h:87:6: note: previous declaration is here
bool ruby_debug_log_filter(const char *func_name);
     ^
1 error generated.
make: *** [debug.o] Error 1
```
2022-06-09 09:35:08 +09:00
Koichi Sasada c9af8a32a0 `USE_RUBY_DEBUG_LOG` doesn't check `RUBY_DEVEL`
`USE_RUBY_DEBUG_LOG` was only defined when `RUBY_DEVEL` is defined.
This patch removes this dependency (`USE_RUBY_DEBUG_LOG` is defined
independently from `RUBY_DEVEL`).

Do not commit a patch which enables `USE_RUBY_DEBUG_LOG`.
2021-12-29 00:22:02 +09:00
Nobuyoshi Nakada 975a6efd7e Suppress undef warnings for USE_RUBY_DEBUG_LOG 2021-12-25 18:04:25 +09:00
Nobuyoshi Nakada 566bdaef31 Define fallback RUBY_DEVEL to suppress undef warnings 2021-12-25 18:04:25 +09:00
Nobuyoshi Nakada cbfd5249d4
Stop including node.h from vm_debug.h only for `NODE` 2021-11-21 16:21:18 +09:00
Nobuyoshi Nakada 0c15752556
Use `RUBY_FUNCTION_NAME_STRING` for old Visual C++
Probably `__func__` is supported since Visual C++ 2015 (= 14.0,
`_MSC_VER` = 1900).
2021-10-20 11:22:33 +09:00
Nobuyoshi Nakada 8bf33a6fbb
Ensure the format argument of RUBY_DEBUG_LOG is a string literal 2021-10-20 07:57:54 +09:00
Kazuhiro NISHIYAMA 9b18f1bffe Supress `warning: data argument not used by format string [-Wformat-extra-args]` 2021-10-20 07:48:30 +09:00
卜部昌平 dddc618d30 suppress GCC's -Wsuggest-attribute=format
I was not aware of this because I use clang these days.
2021-09-10 20:00:06 +09:00
Koichi Sasada b4f58ea300 support multiple filters by RUBY_DEBUG_LOG_FILTER
Now you can specify multiple filters for RUBY_DEBUG_LOG output
by RUBY_DEBUG_LOG_FILTER=a,b,c (in this case, logs that the
function name contains a, b or c).
2020-08-02 04:24:47 +09:00
Kazuhiro NISHIYAMA addbb7d16e
Fix typos [ci skip] 2020-07-09 18:14:53 +09:00
Koichi Sasada 8655c2e690
RUBY_DEBUG_LOG: Logging debug information mechanism (#3279)
* RUBY_DEBUG_LOG: Logging debug information mechanism

This feature provides a mechanism to store logging information
to a file, stderr or memory space with simple macros.

The following information will be stored.
  * (1) __FILE__, __LINE__ in C
  * (2) __FILE__, __LINE__ in Ruby
  * (3) __func__ in C (message title)
  * (4) given string with sprintf format
  * (5) Thread number (if multiple threads are running)

This feature is enabled only USE_RUBY_DEBUG_LOG is enabled.
Release version should not enable it.

Running with the `RUBY_DEBUG_LOG` environment variable enables
this feature.

  # logging into a file
  RUBY_DEBUG_LOG=/path/to/file STDERR

  # logging into STDERR
  RUBY_DEBUG_LOG=stderr

  # logging into memory space (check with a debugger)
  # It will help if the timing is important.
  RUBY_DEBUG_LOG=mem

RUBY_DEBUG_LOG_FILTER environment variable can specify the fileter string.
If "(3) __func__ in C (message title)" contains the specified string, the
infomation will be stored (example: RUBY_DEBUG_LOG_FILTER=str will enable
only on str related information).

In a MRI source code, you can use the following macros:
  * RUBY_DEBUG_LOG(fmt, ...): Above (1) to (4) will be logged.
  * RUBY_DEBUG_LOG2(file, line, fmt, ...):
    Same as RUBY_DEBUG_LOG(), but (1) will be replaced with given file, line.
2020-07-03 16:55:54 +09:00
卜部昌平 4ff3f20540 add #include guard hack
According to MSVC manual (*1), cl.exe can skip including a header file
when that:

- contains #pragma once, or
- starts with #ifndef, or
- starts with #if ! defined.

GCC has a similar trick (*2), but it acts more stricter (e. g. there
must be _no tokens_ outside of #ifndef...#endif).

Sun C lacked #pragma once for a looong time.  Oracle Developer Studio
12.5 finally implemented it, but we cannot assume such recent version.

This changeset modifies header files so that each of them include
strictly one #ifndef...#endif.  I believe this is the most portable way
to trigger compiler optimizations. [Bug #16770]

*1: https://docs.microsoft.com/en-us/cpp/preprocessor/once
*2: https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html
2020-04-13 16:06:00 +09:00
Koichi Sasada 6bf8db9a07 add rp() and bp() in internal.h.
debug utility macro rp() (rp_m()) and bp() are introduced.
* rp(obj) shows obj information w/o any side-effect to STDERR.
* rp_m(m, obj) is similar to rp(obj), but show m before.
* bp() is alias of ruby_debug_breakpoint(), which is registered
  as a breakpoint in run.gdb (used by `make gdb` or make gdb-ruby`).
2019-08-09 14:01:15 +09:00
nobu bff997e02b defines.h: RUBY_SYMBOL_EXPORT_{BEGIN,END}
* include/ruby/defines.h (RUBY_SYMBOL_EXPORT_{BEGIN,END}): visibility
  control macros.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-05 10:29:38 +00:00
ko1 cea7600b52 * include/ruby/debug.h: introdudced.
Debugging/profiling features will be located.
* vm_trace.c: expose C-level TracePoint APIs.
  Note that they are experimental.
* vm_trace.c, include/ruby/debug.h: rename `rb_hook_flag_t'
  to `rb_event_hook_flag_t'.
  Macro names `RUBY_HOOK_FLAG_*' are also renamed to
  `RUBY_EVENT_HOOK_FLAG_*'.
* debug.h, vm_debug.h: rename debug.h to vm_debug.h.
* common.mk: ditto.
* debug.c, main.c, vm_core.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20 12:57:49 +00:00