Reputation: 2323
Please see the UPDATE at the botton of this post for more info.
Below is the _pqos_api_lock program from cap.c from the Intel CMT-CAT distribution (cache management technology - cache allocation technology) at https://github.com/intel/intel-cmt-cat.
The function _pqos_api_lock calls lockf, which is defined in unistd.h, and unistd.h is included with the includes at the top of the file. However, debugging with gdb, I get "lockf.c: No such file or directory" at the line:
if (lockf(m_apilock, F_LOCK, 0) != 0)
err = 1;
Going back to the command line, "locate lockf.c" and "find lockf.c brings up:
find: ‘lockf.c’: No such file or directory
I have unistd.h included, so why do I get this error? I found source for lockf.c at https://code.woboq.org/userspace/glibc/io/lockf.c.html -- perhaps I can link this into my executable, although that sounds like a kludge.
Here is the source code for _pqos_api_lock:
#include <stdlib.h>
[ other includes omitted ]
void _pqos_api_lock(void)
{
int err = 0;
if (lockf(m_apilock, F_LOCK, 0) != 0)
err = 1;
if (pthread_mutex_lock(&m_apilock_mutex) != 0)
err = 1;
if (err)
LOG_ERROR("API lock error!\n");
}
The full source code for cap.c is 1,722 lines long, so I did not include all of it here, but it's available at the github link above -- if needed, please ask and I'll post it all.
I'm on Ubuntu 18.04, and I compiled with Clang.
Thanks for any ideas.
UPDATE:
In his answer below, Employed Russian shows that the "cannot find source lockf.c" is a gdb message stating that it has no access to lockf.c. However, error is now here:
void _pqos_api_lock(void)
{
int err = 0;
if (lockf(m_apilock, F_LOCK, 0) != 0)
err = 1;
if (pthread_mutex_lock(&m_apilock_mutex) != 0)
err = 1;
if (err)
LOG_ERROR("API lock error!\n");
}
The line "if (lockf(m_apilock, F_LOCK, 0) != 0)" fails because according to gdb:
p (int) F_LOCK No symbol "F_LOCK" in current context.
That looks like an error in the program distributed by Intel.
Upvotes: 0
Views: 212
Reputation: 213897
I have unistd.h included, so why do I get this error?
You don't seem to understand the significance of this error (which is none). This error is safe to ignore, and doesn't affect your program's execution in any way.
The reason GDB displays this error is that GDB can't show you the source (because GDB doesn't know where that source is).
Chances are, you don't actually want to see this source at all.
I found source for lockf.c at https://code.woboq.org/userspace/glibc/io/lockf.c.html
Good. If you really want to see what locf
does, you can look there.
perhaps I can link this into my executable
The function defined in lockf.c
is already linked into your executable (you'd get a link error if it wasn't). You can't link source into your executable any more than you can link your kitchen sink into it.
What you can do is install libc6-dbg
package, which includes source for all of GLIBC, and allows GDB to find the sources automatically.
Upvotes: 1