dynamic debug statement of kernel in which file - debugging

I have enabled the CONFIG_DYNAMIC_DEBUG option in kernel. After which we get control file in debug/dynamic_debug directory.
After we enable some debug logs in control file, where this log statements will be printed, in which log file ?

You can check kernel log level by cat /proc/sys/kernel/printk. Default is 4. Log levels are defined here https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/kern_levels.h?id=refs/tags/v4.8-rc8#n7. As a test you can set it to highest to make sure that everything is logged: echo "7" > /proc/sys/kernel/printk.
You can also run cat /proc/kmsg while the dynamic debug statements are running. It /proc/kmsg holds kernel messages for them to be picked up by dmesg or something else.

Related

How do I find the logs of Firefox?

While browsing the Firefox source code, I see that a lot of logs are present. I'd like to find them on runtime to help me understand and debug something.
For example, when taking a look at nsHttpConnection.cpp, Here's what I can find :
...
LOG(("restarting transaction #%p\n", this));
mTunnelProvider = nullptr;
...
Where did the LOG lines go ? How do I find the log file containing all the logs generated by Firefox ?
In the case of the file nsHttpConnection.cpp, the LOG() functions are macros defined in HttpLog.h.
here's an excerpt :
#define LOG1(args) \
MOZ_LOG(mozilla::net::gHttpLog, mozilla::LogLevel::Error, args)
You can see them as shortcuts for the more complete MOZ_LOG functions.
LOG1() -> Error
LOG2() -> Warning
LOG3() -> Info
LOG() = LOG4() -> Debug
LOG5() -> Verbose
If you want to get the logs for the nsHttp module, you can set 2 environment variables, and then run firefox :
set MOZ_LOG=nsHttp:5
set MOZ_LOG_FILE=http.log
firefox
or run firefox with the command line parameters :
firefox -MOZ_LOG=nsHttp:5 -MOZ_LOG_FILE=nsHttp.log
This enables Verbose level information (and higher) and places all output in the file nsHttp.log.
The MOZ_LOG variable is composed of as <module>:level.
You can also use a more general module all to include them all.
i.e. to log all Error level informations in the file all.log:
firefox -MOZ_LOG=all:1 -MOZ_LOG_FILE=all.log
For more information on how the MOZ_LOG variable is configured, you can take a look at prlog.h

How can I output the safepoint log in a specified file?

I am using java8 and I did set JVM argument to set GC log path,but the safepoint log did not output to the specified file and they still in my console output.What should i do to let the safepoint-log output to a file just like GC log?
In java-8 you need two flags : -XX:+LogVMOutput ( internally a safepoint is refered as vmop as in "vm operation", that is why the weird flag name, I guess ). To redirect the output to a file you need -XX:LogFile=path.
Since java-9, there is "unified logging" that makes this far more easy and intuitive, IMO. For example:
-Xlog:safepoint*=debug:file=safepoint.log

Save output of NetworkManager monitor command to text file

How can I save the output of the NetworkManager command that listens for and prints the current activity?
The command is nmcli monitor (https://developer.gnome.org/NetworkManager/stable/nmcli.html).
Logging Messages
I will show how to modify the logging levels by NetworkManager.
NetworkManager supports on the fly changing of the logging levels and allows for a fine control over what is logged.
First check what is the current configuration by below command:
root#hostname ~: nmcli general logging
As a result you will be presented with the information about current conf:
LEVEL DOMAINS INFO PLATFORM,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,IP4,IP6,AUTOIP4,DNS,VPN,SHARING,SUPPLICANT,AGENTS,SETTINGS,SUSPEND,CORE,DEVICE,OLPC,INFINIBAND,FIREWALL,ADSL,BOND,VLAN,BRIDGE,TEAM,CONCHECK,DCB,DISPATCH,AUDIT,SYSTEMD
It is possible to change the level either globally or for each domain separately. The command to achieve this is:
nmcli general logging [level <level> [domain <domain>]]
The < level > is the desired log level, here are some examples:
ERR: will log only critical errors
WARN: will log warnin messages
INFO: will log various informational messages
DEBUG: enables verbose logging for debugging purposes
< domain > is the category of messages that shall be logged with given severity.
WIFI: will include only WiFi related messages, IP4 will include only IPv4 related messages
And so on, i cant provide info for every setting but this is how it works in general.
Other things you may wanna try:
Systemd:
journalctl -u NetworkManager > tomyfile.txt
Use debug mode in general:
sudo /usr/lib/NetworkManager/debug-helper.py --nm debug > tomyfile.txt
I was able to log the output of nmcli monitor to a file using:
nmcli monitor >> log.txt

How can I get DEBUG messages HAWQ in log?

Are there any GUCs or commands which I can get debug messages in HAWQ log? Now, I can only get ERROR or FATAL message but can not get any DEBUG messages. How to print these DEBUG messages in Log file?
You can set log_min_messages level in postgres.conf of hawq master data directory. Log level can be the following values in order of decreasing detail:
# debug5
# debug4
# debug3
# debug2
# debug1
# info
# notice
# warning
# error
# log
# fatal
# panic
It needs to restart cluster if you change the postgres.conf. But you can set GUC log_min_messages in the PSQL session if you just want to log the debug info within this session.
Different component of apache hawq support different level of debugging message.
The overall supported levels are as below. You may refer to https://github.com/apache/incubator-hawq/blob/master/src/include/utils/elog.h for details.
/* Error level codes */
Level Value
------------------
DEBUG5 10
DEBUG4 11
DEBUG3 12
DEBUG2 13
DEBUG1 14
LOG 15
COMMERROR 16
INFO 17
NOTICE 18
WARNING 19
ERROR 20
FATAL 21
PANIC 22
To get the DEBUG message you want, you need to check the component you care about regarding the supported level of debugging. Then before run your query, use below setting to get debug information:
either persistent level of GUC ("hawq config -c log_min_messages -v DEBUG_LEVEL" and then "hawq restart cluster -a")
or use session level debugging ("set log_min_messages = DEBUG_LEVEL")
If you don't find enough log information even with highest level debugging level, you can try to add it in apache hawq source code yourself.
DEBUG you refer to may have two meaning, One is DEBUG log level in hawq code, which is answered by ztao1987, and the other is when you debug using gdb/lldb, where is the output of your print function.
The answer is in the master/segment log too. stdout has been redirected to log file by HAWQ, For example, when you want to print a tupletableslot in lldb, just type"expr print_slot(yourslot)", and tail -f your.log, the slot info will be printed on the screen.

How can I get the value of "%d" variables in dynamic_debug info of Linux kernel?

I enabled config_dynamic_debug=y in the Linux kernel customized by myself, and following the dynamic_debug documentation shipped with kernel source code, I run the following command to enable the output of the debug information in bluetooth subsystem:
echo -n 'file net/bluetooth/bnep/core.c line 722 +p' > /sys/kernel/debug/dynamic_debug/control
which means the debug info in the line 772 of the file net/bluetooth/bnep/core.c will be logged.
After the bnep.ko module is loaded, I checked the output of /sys/kernel/debug/dynamic_debug/control, the debug information is there.
But most of them look like:
> net/bluetooth/bnep/core.c:422 [bnep]bnep_tx_frame - "skb %p dev %p type %d\012"
I really want to know the value represented by %p or %d, but I don't know how to do it.
Thank you very much!
You have enabled that debug statement, which is what reading from /sys/kernel/debug/dynamic_debug/control tells you.
From now on, that debug message will be sent to the normal kernel log, which you can view with dmesg and/or with your syslog daemon (which will normally log to /var/log/messages or /var/log/everything/, or some similar path).

Resources