# Some symbols not showing up in dtrace(1)



## Farhan Khan (Jul 26, 2018)

I am trying to tap "ieee80211_ioctl_get80211", but it does not come up when I run `dtrace -l`.
I have put `CFLAGS+=-O0`, ran `make clean`, and but it doesn't come up. What gives?


----------



## Farhan Khan (Jul 27, 2018)

A few folks gave me the advice to add `-fno-inline-functions` which I went ahead and did. I see it in a lot of places, but not on the exact line that I need

That appears on multiple other compile lines, but not ieee80211_ioctl.c, as you can see from the build line:
`--- ieee80211_ioctl.o ---

cc -target x86_64-unknown-freebsd12.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin -c -O2 -pipe -fno-strict-aliasing  -g -nostdinc  -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -I/usr/src/sys/contrib/libfdt -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -MD  -MF.depend.ieee80211_ioctl.o -MTieee80211_ioctl.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -gdwarf-2 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -Werror  /usr/src/sys/net80211/ieee80211_ioctl.c`

I can confirm the flags appear elsewhere, but not here.
Anyone know where in the /usr/src/conf/* system it reads from /etc/make.conf?


----------



## Farhan Khan (Jul 27, 2018)

I have not been able to figure out how this works. It seems that some of the 30 or so options is causing inlining to occur.
Also, seemingly neither make.conf nor src.conf allow you to have compiler flags *after *all others.
Is this a bug in the build process? Or am I doing something wrong?


----------



## Farhan Khan (Jul 27, 2018)

Still no dice.
Notice the -O0 and -fno-function-inline references in this line:

`cc -target x86_64-unknown-freebsd12.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin  -O2 -pipe -O0 -fno-inline-functions -O0 -fno-inline-functions  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -DKLD_TIED -nostdinc   -DHAVE_KERNEL_OPTION_HEADERS -include /usr/obj/usr/src/amd64.amd64/sys/GENERIC/opt_global.h -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common -g -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/obj/usr/src/amd64.amd64/sys/GENERIC   -MD  -MF.depend.ieee80211_ioctl.o -MTieee80211_ioctl.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -gdwarf-2 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c /usr/src/sys/net80211/ieee80211_ioctl.c -o ieee80211_ioctl.o`

What's breaking?


----------



## ShelLuser (Jul 27, 2018)

Just for the record: after all your posts I still fail to understand your actual problem because you're very vague about it. When you have a problem never assume that your target audience knows what you did. Because we can't.



Farhan Khan said:


> I am trying to tap "ieee80211_ioctl_get80211", but it does not come up when I run `dtrace -l`.


So what did you do to try and make this work?



Farhan Khan said:


> I have put `CFLAGS+=-O0`, ran `make clean`, and but it doesn't come up. What gives?


What does this even mean? Ran `make clean`? You do realize that this doesn't perform any build operations? Also: _where_ did you run that command?

When reading even further I'm slowly beginning to understand that you're messing with the base system, probably the kernel, and that you're trying to provide DTrace support for a specific module (?) but you're not even telling us what module that is supposed to be. You're only talking about a probe which you can't find, but why assume that it should be there in the first place?


----------



## Farhan Khan (Jul 28, 2018)

I apologize for not being clear.

Bit of background: I am writing a WiFi device driver and a certain part of the code is malfunctioning. I do not know why/where, so I am tracing the code through using dtrace. I am currently at the function ieee80211_ioctl_get80211. This is part of net80211 (AFAIK, this does not compile as a stand-alone module). However, if you run `dtrace -l`, ieee80211_ioctl_get80211 is not listed.

This appears to be due to some sort of optimization, I am not certain.



ShelLuser said:


> So what did you do to try and make this work?



A few things. I added the options `CFLAGS+=-O0 -fno-inline-functions` to /etc/make.conf and /etc/src.conf. I also added these to makeoptions     `DEBUG="-g -O0 -fno-inline-function"` in /usr/src/sys/amd64/conf/GENERIC, which just caused the kernel to panic at boot.



ShelLuser said:


> What does this even mean? Ran  make clean? You do realize that this doesn't perform any build operations? Also: _where_ did you run that command?



This was out of frustration, I figured maybe my NO_CLEAN=1 that I originally had in make.conf was causing problems when adjusting my CFLAGS.



ShelLuser said:


> You're only talking about a probe which you can't find, but why assume that it should be there in the first place?



I presumed that all kernel functions were there by default, no? Why would ieee80211_ioctl_set80211 be present as a probe but not ieee80211_ioctl_get80211? It seems to me that both should be present. Am I mistaken?

Thanks again!


----------



## Farhan Khan (Jul 28, 2018)

Semi-Solved! But I'm getting weirdly inconsistent results.

If I build after a `make clean` it will not use the settings from make.conf while producing the object file for ieee80211_ioctl.o.

Then, if I trivially modify the ieee80211_ioctl.c source file then re-run the build process, it will include the -O0 and -fno-inline-functions flags. I manually reran the same command and when I used nm(1), I saw that it contained the intended symbols.

Then I reran `make buildkernel` and the resulting kernel included the kernel symbol and subsequently dtrace(1) probe. That seems like some sort of inconsistency with the build process, but I cannot narrow down where or why this is happening.

This seems like a bug in the build process. I could figure it out if someone could kindly point me to where it uses make.conf.


----------

