Bug 160275 - [patch] dtrace(1): dtrace -lv causes "unknown function" warnings
Summary: [patch] dtrace(1): dtrace -lv causes "unknown function" warnings
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-29 08:20 UTC by ambrose
Modified: 2019-01-19 20:07 UTC (History)
1 user (show)

See Also:


Attachments
ctf.ERROR (18.09 KB, application/octet-stream)
2011-10-06 03:42 UTC, ambrose
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description ambrose 2011-08-29 08:20:10 UTC
dtrace -lv;
the output seems all right; but the dmesg has warnings like this:

fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
fbt_getargdesc(1302): Unknown function!
ctf_lookup_by_id(998): type 2363 exceeds max 2363
ctf_lookup_by_id(998): type 2363 exceeds max 2363

I notice the 'dtrace -l' output has something like this 
.......................
19324    syscall         freebsd32                              #518 entry
19325    syscall         freebsd32                              #518 return
19326    syscall         freebsd32                              #519 entry
19327    syscall         freebsd32                              #519 return
19328    syscall         freebsd32                              #520 entry
19329    syscall         freebsd32                              #520 return
19330    syscall         freebsd32                              #521 entry
19331    syscall         freebsd32                              #521 return
19332    syscall         freebsd32                 freebsd32_pselect entry
19333    syscall         freebsd32                 freebsd32_pselect return
19334    syscall         freebsd32                     getloginclass entry
19335    syscall         freebsd32                     getloginclass return
19336    syscall         freebsd32                     setloginclass entry
19337    syscall         freebsd32                     setloginclass return
19338    syscall         freebsd32                    rctl_get_racct entry
19339    syscall         freebsd32                    rctl_get_racct return
19340    syscall         freebsd32                    rctl_get_rules entry
19341    syscall         freebsd32                    rctl_get_rules return
19342    syscall         freebsd32                   rctl_get_limits entry
19343    syscall         freebsd32                   rctl_get_limits return
19344    syscall         freebsd32                     rctl_add_rule entry
19345    syscall         freebsd32                     rctl_add_rule return
19346    syscall         freebsd32                  rctl_remove_rule entry
19347    syscall         freebsd32                  rctl_remove_rule return
19348    syscall         freebsd32         freebsd32_posix_fallocate entry
19349    syscall         freebsd32         freebsd32_posix_fallocate return
19350    syscall         freebsd32                              #531 entry
19351    syscall         freebsd32                              #531 return

some of function column of syscall provider is #num, not the function
name, I checked the syscalls.c, It seems the warning come from 
unimplemented syscall (the num is the syscall number),  this syscall
exists in the syscall table, and dtrace produce relevant probe for it,
but these syscall has no implementation, so 'dtrace -lv' found no ctf
info 

plus, on 8.2-stable, the dtrace -lv cause page fault on fbt_getargdesc
in fbt.c
 
	/* Check if this module hasn't been initialised yet. */
	if (*lc.ctfoffp == NULL) {                                                   //it seems ctfoffp == NULL
		/*
		 * Initialise the CTF object and function symindx to
		 * byte offset array.
		 */
		if (fbt_ctfoff_init(ctl, &lc) != 0)
			return;

		/* Initialise the CTF type to byte offset array. */
		if (fbt_typoff_init(&lc) != 0)
			return;
	}

How-To-Repeat: dtrace -lv with dtrace enabled;
Comment 1 ambrose 2011-10-11 13:12:07 UTC
Among the previous update,  some fbt probe function has NO  CTF info,
and I found the config (8)

can not generate right Makefile for "in_proto.c" and "if_ethersubr.c"
in sys/conf/files[,.ARCH],

/usr/obj/usr/src/MYKERNEL/Makefile
...
in_proto.ln: $S/netinet/in_proto.c
    ${NORMAL_LINT}

in_proto.o: $S/netinet/in_proto.c
    ${NORMAL_C} -I$S/contrib/pf
      //without @${NORMAL_CTFCONVERT}

in_rmx.ln: $S/netinet/in_rmx.c
    ${NORMAL_LINT}

in_rmx.o: $S/netinet/in_rmx.c
    ${NORMAL_C}
    @${NORMAL_CTFCONVERT}
...

which has a "compile-with" command,  see here:
------------------------------------------------------------------
src/usr.sbin/config/mkmakefile.c Line 746

      }
      compilewith = ftp->f_compilewith;
      if (compilewith == 0) {        // no compile-with
         const char *ftype = NULL;

         switch (ftp->f_type) {
         case NORMAL:
            ftype = "NORMAL";
            break;
         case PROFILING:
            if (!profiling)
               continue;
            ftype = "PROFILE";
            break;
         default:
            fprintf(stderr,
                "config: don't know rules for %s\n", np);
            break;
         }
                       //no compile-with get here, with CTFCONVERT post-process
         snprintf(cmd, sizeof(cmd),
             "${%s_%c%s}\n\t@${NORMAL_CTFCONVERT}", ftype,
             toupper(och),
             ftp->f_flags & NOWERROR ? "_NOWERROR" : "");
         compilewith = cmd;
      }
      *cp = och;
      if (strlen(ftp->f_objprefix))
         fprintf(f, "\t%s $S/%s\n\n", compilewith, np);
      else
         fprintf(f, "\t%s\n\n", compilewith);
   }
}
---------------------------------------------------
here is a patch for  STABLE-8

diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index 55367be..59914c4 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -749,6 +749,14 @@ do_rules(FILE *f)
                            ftp->f_flags & NOWERROR ? "_NOWERROR" : "");
                        compilewith = cmd;
                }
+               else if (!strncmp(compilewith, "${NORMAL_C", 10)) {
+                       if (ftp->f_type == NORMAL)
+                                snprintf(cmd, sizeof(cmd),
+                                       "%s\n.if defined(NORMAL_CTFCONVERT) && "
+                                       "!empty(NORMAL_CTFCONVERT)\n"
+
"\t${NORMAL_CTFCONVERT}\n.endif", compilewith);
+                                       compilewith = cmd;
+               }
+
                *cp = och;
                fprintf(f, "\t%s\n\n", compilewith);
        }
and this is a patch for STABLE-9

diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index 2372839..25a85de 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -767,6 +767,14 @@ do_rules(FILE *f)
                            ftp->f_flags & NOWERROR ? "_NOWERROR" : "");
                        compilewith = cmd;
                }
+                       //handle CTF issule with NORMAL_C and NORMAL_C_NOERROR
+               else if (!strncmp(compilewith, "${NORMAL_C", 10)) {
+                       if (ftp->f_type == NORMAL)
+                               snprintf(cmd, sizeof(cmd),
+                                       "%s\n\t@${NORMAL_CTFCONVERT}",
+                                       compilewith);
+                       compilewith = cmd;
+               }
                *cp = och;
                if (strlen(ftp->f_objprefix))
                        fprintf(f, "\t%s $S/%s\n\n", compilewith, np);
Comment 2 ambrose 2011-10-17 15:03:55 UTC
I think I get it.

1. The page fault error is due to the santiy check error for ctf
section of kernel module built without WITH_CTF=1,
and it is fixed by r226082

2 The first part of the "unknown function" warning came from the
in_proto.c and if_ethersubr.c built without ctfconvert
post-processing. When config(8) generates make rules  source files
with compile-with command in
src/sys/conf/files, it DOES NOT append ${NORMAL_CTFCONVERT} to the
rules. Here is the fix


diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index 2372839..25a85de 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -767,6 +767,14 @@ do_rules(FILE *f)
                            ftp->f_flags & NOWERROR ? "_NOWERROR" : "");
                        compilewith = cmd;
                }
+                       //handle CTF issule with NORMAL_C and NORMAL_C_NOERROR
+               else if (!strncmp(compilewith, "${NORMAL_C",
sizeof("${NORMAL_C"))) {
+                               snprintf(cmd, sizeof(cmd),
+                                       "%s\n\t@${NORMAL_CTFCONVERT}",
+                                       compilewith);
+                               compilewith = cmd;
+               }


3 The second part of "unknown function" came from the clang compiler.
When building kernel with  clang, some modules
failed to be post-processed by ctfconvert and ctfmerge tools . If you
build kernel with gcc, this warning is gone.


4 The last part of warning came from the "x11/nvidia-driver".

If you build it without WITH_CTF=1,  you would trigger the page fault
error until r226082.

If you build it with DEBUG_FLAGS="-g" and WITH_CTF=1, you may get less
warning from nvidia.ko, the remaining warning
came from the nv_freebsd.o object released by nvidia, I think this
object is NOT built "-g", so even though you add
WITH_CTF=1, you can not get correct ctf section.


So, I think my work is done with this PR
Comment 3 dfilter service freebsd_committer freebsd_triage 2011-11-10 21:07:28 UTC
Author: rstone
Date: Thu Nov 10 21:07:14 2011
New Revision: 227429
URL: http://svn.freebsd.org/changeset/base/227429

Log:
  The generated Makefile for the kernel was not running ctfconvert on
  object files corresponding to source files that had the compile-with
  option set in conf/files.  This means that any fbt probes for functions
  in that object file would not have correct argument types.
  
  The fix is to run ctfconvert on any target file that does not have the
  no-obj option set in files.
  
  PR:		bin/160275
  Reported by:	Paul Ambrose (ambrosehua AT gmail DOT com)
  MFC after:	1 week

Modified:
  head/usr.sbin/config/mkmakefile.c

Modified: head/usr.sbin/config/mkmakefile.c
==============================================================================
--- head/usr.sbin/config/mkmakefile.c	Thu Nov 10 20:28:30 2011	(r227428)
+++ head/usr.sbin/config/mkmakefile.c	Thu Nov 10 21:07:14 2011	(r227429)
@@ -762,16 +762,21 @@ do_rules(FILE *f)
 				break;
 			}
 			snprintf(cmd, sizeof(cmd),
-			    "${%s_%c%s}\n\t@${NORMAL_CTFCONVERT}", ftype,
+			    "${%s_%c%s}\n", ftype,
 			    toupper(och),
 			    ftp->f_flags & NOWERROR ? "_NOWERROR" : "");
 			compilewith = cmd;
 		}
 		*cp = och;
 		if (strlen(ftp->f_objprefix))
-			fprintf(f, "\t%s $S/%s\n\n", compilewith, np);
+			fprintf(f, "\t%s $S/%s\n", compilewith, np);
 		else
-			fprintf(f, "\t%s\n\n", compilewith);
+			fprintf(f, "\t%s\n", compilewith);
+
+		if (!(ftp->f_flags & NO_OBJ))
+			fprintf(f, "\t@${NORMAL_CTFCONVERT}\n\n");
+		else
+			fprintf(f, "\n");
 	}
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 4 George V. Neville-Neil freebsd_committer freebsd_triage 2012-04-13 21:29:01 UTC
Responsible Changed
From-To: freebsd-bugs->rstone

Ryan, if this is no longer a bug, and it seems that this is not an 
issue on HEAD, then please close this.
Comment 5 dfilter service freebsd_committer freebsd_triage 2012-05-27 01:35:17 UTC
Author: rstone
Date: Sun May 27 00:34:56 2012
New Revision: 236132
URL: http://svn.freebsd.org/changeset/base/236132

Log:
  MFC 227429
  
   The generated Makefile for the kernel was not running ctfconvert on
   object files corresponding to source files that had the compile-with
   option set in conf/files.  This means that any fbt probes for functions
   in that object file would not have correct argument types.
  
   The fix is to run ctfconvert on any target file that does not have the
   no-obj option set in files.
  
  PR:           bin/160275
  Reported by:  Paul Ambrose (ambrosehua AT gmail DOT com)

Modified:
  stable/8/usr.sbin/config/mkmakefile.c
Directory Properties:
  stable/8/usr.sbin/config/   (props changed)

Modified: stable/8/usr.sbin/config/mkmakefile.c
==============================================================================
--- stable/8/usr.sbin/config/mkmakefile.c	Sun May 27 00:21:27 2012	(r236131)
+++ stable/8/usr.sbin/config/mkmakefile.c	Sun May 27 00:34:56 2012	(r236132)
@@ -742,15 +742,20 @@ do_rules(FILE *f)
 				break;
 			}
 			snprintf(cmd, sizeof(cmd),
-			    "${%s_%c%s}\n.if defined(NORMAL_CTFCONVERT) && "
-			    "!empty(NORMAL_CTFCONVERT)\n"
-			    "\t${NORMAL_CTFCONVERT}\n.endif", ftype,
+			    "${%s_%c%s}\n", ftype,
 			    toupper(och),
 			    ftp->f_flags & NOWERROR ? "_NOWERROR" : "");
 			compilewith = cmd;
 		}
 		*cp = och;
-		fprintf(f, "\t%s\n\n", compilewith);
+		fprintf(f, "\t%s\n", compilewith);
+
+		if (!(ftp->f_flags & NO_OBJ))
+			fprintf(f, ".if defined(NORMAL_CTFCONVERT) && "
+			    "!empty(NORMAL_CTFCONVERT)\n"
+			    "\t${NORMAL_CTFCONVERT}\n.endif\n\n");
+		else
+			fprintf(f, "\n");
 	}
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 6 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:47 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 7 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-01-19 20:07:54 UTC
There was a commit referencing this bug, but it's still not closed and has been inactive for some time. Closing as "fixed". Please re-open it if the issue hasn't been completely resolved.