reference console_loglevel ERROR in kernel module - linux

I have a Linux module, which has a debug function and I just want to call that function in debug mode.
Now I have code like this:
if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
dump_my_message(dev, my_msg);
But when build this code in linux-next, it will throw below error:
CHK include/generated/uapi/linux/version.h
Kernel: arch/x86/boot/bzImage is ready (#2)
Building modules, stage 2.
MODPOST 2738 modules
ERROR: "console_printk" [drivers/mymodule.ko] undefined!
scripts/Makefile.modpost:91: recipe for target '__modpost' failed
make[1]: *** [__modpost] Error 1
Makefile:1117: recipe for target 'modules' failed
make: *** [modules] Error 2
Can you help to find out how to make this work? thanks!!!

The compilation error is caused by the fact that console_printk symbol is not exported so it cannot be used by modules.
What you really should use, however, is Dynamic debug functionality and its pr_debug()/dev_dbg() functions.
Basically what you need is to ensure that CONFIG_DYNAMIC_DEBUG is enabled in your kernel, use dev_dbg() in all places where you want to write some debugging code and then dynamically enable your debug messages, for example:
To enable all the messages in your module, add dyndbg=+p at the end of your insmod/modprobe call.
To selectively enable only some of the messages, use query language described in the documentation. For example, to only enable messages from functions foo() and bar() in your module, use:
insmod mymodule.ko dyndbg="func foo +p; func bar +p"

Related

building glibc-2.25 error : FAIL: nptl/tst-cond17

I've been reading through LFS while following the instructions till I got to the point where I needed to compile glibc-2.25 for the actual system.
After running make check, have encountered the following failures:
FAIL: nptl/tst-cond17
FAIL: posix/tst-getaddrinfo4
FAIL: posix/tst-getaddrinfo5
Summary of test results:
3 FAIL
2640 PASS
26 UNSUPPORTED
43 XFAIL
2 XPASS
make[1]: *** [Makefile:355: tests] Error 1
make[1]: Leaving directory '/sources/glibc-2.25'
make: *** [Makefile:9: check] Error 2
Both posix/tst-getaddrinfo4 and posix/tst-getaddrinfo5 failures should pose no real threat as indicated by LFS, but I am not sure about the first failure nptl/tst-cond17.
I have checked the source file and found out that all it does is defining some sort of variable. Here's the code.
#define UNLOCK_AFTER_BROADCAST 1
#include "tst-cond16.c"
Is it not critical to the build process? or should I try to fix it somehow?
EDIT:
The files nptl/tst-cond17.o, nptl/tst-cond17.o.d and nptl/tst-cond17.out are empty, while the contents of the file nptl/tst-cond17.test-result are:
FAIL: nptl/tst-cond17
original exit status 127
I have checked our records, and tst-cond17 is not generally known to generate spurious failures (or as being affected by unfixed kernel bugs). I found a reference to a tst-cond17 failure in the glibc 2.20 release notes, but the submitter comments that, ‘The NPTL failures not mentioned as architecture-independent are thought to result from general unreliability of the board being used for testing.’, so I assume that this does not count.
I would say the tst-cond17 failure is worth investigating further, especially if you can reproduce it.

How can i make the busybox1.23.2 Compile success?

package: busybox
version: 1.23.2
when i make busybox , it produces unexpected results.
the crosschaintool i use is ARM/uClinux Toolchain arm-2010q1-189-arm- uclinuxeabi-i686-pc-linux-gnu,but i can't make the busybox,like this:
root#ubuntu:/busybox/busybox-1.23.2# make
SPLIT include/autoconf.h -> include/config/*
GEN include/bbconfigopts.h
HOSTCC applets/usage
applets/usage.c: In function ‘main’:
applets/usage.c:52:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(STDOUT_FILENO, usage_array[i].usage, strlen(usage_array[i].usage) + 1);
^
GEN include/usage_compressed.h
HOSTCC applets/applet_tables
applets/applet_tables.c: In function ‘main’:
applets/applet_tables.c:161:4: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
fgets(line_old, sizeof(line_old), fp);
^
GEN include/applet_tables.h
CC applets/applets.o
LD applets/built-in.o
HOSTCC applets/usage_pod
applets/usage_pod.c: In function ‘main’:
applets/usage_pod.c:74:3: warning: format not a string literal and no format arguments [-Wformat-security]
printf(usage_array[i].aname);
^
CC libbb/appletlib.o
CC libbb/vfork_daemon_rexec.o
AR libbb/lib.a
CC shell/hush.o
shell/hush.c: In function 'builtin_source':
shell/hush.c:8901: warning: 'sv.sv_g_malloced' may be used uninitialized in this function
shell/hush.c:8901: warning: 'sv.sv_g_argc' may be used uninitialized in this function
shell/hush.c:8901: warning: 'sv.sv_g_argv' may be used uninitialized in this function
shell/hush.c:8901: warning: 'sv.sv_argv0' may be used uninitialized in this function
AR shell/lib.a
LINK busybox_unstripped
Trying libraries: crypt m
Library crypt is not needed, excluding it
Library m is not needed, excluding it
Final link with: <none>
arm-uclinuxeabi-strip:busybox_unstripped: File format not recognized
Makefile:723: recipe for target 'busybox' failed
make: *** [busybox] Error 1
how should i do? is the busybox can't use the ARM/uClinux Toolchain? how should i do ?we'll really appreciate it if you can give us some advice and some pieces of guidance,thanks!
LINK busybox_unstripped Trying libraries: crypt m Library crypt
is not needed, excluding it Library m is not needed, excluding it
Final link with: arm-uclinuxeabi-strip:busybox_unstripped: File
format not recognized Makefile:723: recipe for target 'busybox' failed
make: *** [busybox] Error 1
As there is only a piece of the whole compiling log, some suggestions are:
1) Please check the compiling log from the beginning whether there are other important warnings or errors.
2) busybox_unstripped file is generated or not? Check the makefile dependencies to find out whether all dependencies files are successfully generated. From the log, some libraries are excluded so that you may have to check the busybox configuration file.
3) If busybox_unstripped file is generated, check the makefile about the link grammar of "Final link with:". For the cross-tool chain to link successfully, please make sure the link command is correct.
Good luck!

Missing soft link to linux source tree

In /lib/modules/xx.xx.xx-xx there is supposed to be two soft links one called source and one called build. The source one is there and its fine but the build one is missing and I have no idea where it is supposed to point to and I need to install a driver for my video card. Is there any way to find out where that is supposed to point if so how and where. I know there are a lot of other questions out there but not of them actually discribe where they are supposed to be pointing in the end.
Updated the link and now it is having build errors that I can't fix because I can't even find the struct its talking about
make -C /lib/modules/3.16.0-4-amd64/build M=/home/gibsont/gpuTempDriver modules
make[1]: Entering directory '/usr/src/linux-headers-3.16.0-4-amd64'
Makefile:10: *** mixed implicit and normal rules: deprecated syntax
make[1]: Entering directory `/usr/src/linux-headers-3.16.0-4-amd64'
CC [M] /home/gibsont/gpuTempDriver/base.o
/home/gibsont/gpuTempDriver/base.c: In function ‘_rtl_init_mac80211’:
/home/gibsont/gpuTempDriver/base.c:319:6: error: ‘IEEE80211_HW_BEACON_FILTER’ undeclared (first use in this function)
IEEE80211_HW_BEACON_FILTER |
^
/home/gibsont/gpuTempDriver/base.c:319:6: note: each undeclared identifier is reported only once for each function it appears in
/home/gibsont/gpuTempDriver/base.c:349:4: error: ‘struct ieee80211_hw’ has no member named ‘channel_change_time’
hw->channel_change_time = 100;
^
/home/gibsont/gpuTempDriver/base.c: In function ‘rtl_action_proc’:
/home/gibsont/gpuTempDriver/base.c:858:32: error: ‘struct ieee80211_conf’ has no member named ‘channel’
rx_status.freq = hw->conf.channel->center_freq;
^
/home/gibsont/gpuTempDriver/base.c:859:32: error: ‘struct ieee80211_conf’ has no member named ‘channel’
rx_status.band = hw->conf.channel->band;
^
/home/gibsont/gpuTempDriver/base.c:861:25: error: ‘RX_FLAG_MACTIME_MPDU’ undeclared (first use in this function)
rx_status.flag |= RX_FLAG_MACTIME_MPDU;
^
/home/gibsont/gpuTempDriver/base.c: In function ‘rtl_beacon_statistic’:
/home/gibsont/gpuTempDriver/base.c:1132:2: error: implicit declaration of function ‘compare_ether_addr’ [-Werror=implicit-function-declaration]
if (compare_ether_addr(hdr->addr3, rtlpriv->mac80211.bssid))
^
/home/gibsont/gpuTempDriver/base.c: In function ‘rtl_send_smps_action’:
/home/gibsont/gpuTempDriver/base.c:1414:16: error: ‘struct <anonymous>’ has no member named ‘sta’
info->control.sta = sta;
^
/home/gibsont/gpuTempDriver/base.c:1415:24: error: ‘struct ieee80211_conf’ has no member named ‘channel’
info->band = hw->conf.channel->band;
^
cc1: some warnings being treated as errors
/usr/src/linux-headers-3.16.0-4-common/scripts/Makefile.build:262: recipe for target '/home/gibsont/gpuTempDriver/base.o' failed
make[4]: *** [/home/gibsont/gpuTempDriver/base.o] Error 1
/usr/src/linux-headers-3.16.0-4-common/Makefile:1350: recipe for target '_module_/home/gibsont/gpuTempDriver' failed
make[3]: *** [_module_/home/gibsont/gpuTempDriver] Error 2
Makefile:181: recipe for target 'sub-make' failed
make[2]: *** [sub-make] Error 2
Makefile:8: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-3.16.0-4-amd64'
Makefile:27: recipe for target 'all' failed
make: *** [all] Error 2
I copied it from the disk because it was a read only and placed it into my home directory.
I feel like this has become a whole new issues or possibly the link is wrong and is causing this issue.
this is mine:
2509142 lrwxrwxrwx 1 root root 37 Apr 24 15:02 build -> /usr/src/linux-headers-3.16.0-4-amd64
actually it's managed by package manager. I install linux headers using apt-get. I think you should do the same, unless you are advanced kernel developer.

dmake: Error code 137, while making 'Shell escape' after using -Wl,-Ttext-segment=0x855555000000 and /proc/sys/kernel/randomize_va_space value is 2

I am getting following error message while running my thread-sanitized executable. (I have used -fPIC and -fsanitized=thread flag at compilation , -fsanitize=thread -Wland '-pie' flag during executable time):
FATAL: ThreadSanitizer can not mmap the shadow memory (something is mapped at 0x2aab6c8a7000 < 0x7cf000000000)
FATAL: Make sure to compile with -fPIE and to link with -pie.
dmake: Error code 1, while making 'Shell escape'
However after going through this BugZilla link, I have checked /proc/sys/kernel/randomize_va_space and enabled randomization with value 2. I have also specified where to load PIE via a linker switch -Ttext-segment 0x855555000000.
Now I have no more FATAL error but I have encountered with new error message :
dmake: Error code 137, while making 'Shell escape'
I don't know where I am making mistake with flags. Any idea?

Install OpenCV-2.4.9 on CentOS 7 (PC)

I'm trying to install OpenCV-2.4.9 on CentOS 7 (PC) however getting error after 16% when running "make" command. I leave default configuration for OpenCV.
make
...
[ 16%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_v4l.cpp.o /opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp:306:29: error: field ‘capability’ has incomplete type
struct video_capability capability;
^ /opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp:307:29: error: field ‘captureWindow’ has incomplete type
struct video_window captureWindow;
....
....
/opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp: In function ‘void icvCloseCAM_V4L(CvCaptureCAM_V4L*)’:
/opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp:2812:46: error: ‘CvCaptureCAM_V4L’ has no member named ‘memoryBuffer’
It seems that the define HAVE_CAMV4L has the value 1, if you look in the file modules/highgui/src/cap_v4l.cpp looking for the structure definition at the row 306. If the compilation fails at that point this means that the video4linux development configuration is corrupted.
Using google I have found that the OpenCV Bug #1357 is described as follow:
CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L) succeeds even though linux/videodev.h doesn't exist on the system. (Bug #1357)
http://code.opencv.org/issues/1357
Anyway the solution is described at the same URL for "HAVE_CAMV4L gets set incorrectly": "Setting it to FALSE in CMakeLists.txt fixes the problem".

Resources