libpkgconf: pkg: add some trace points

feature/tap-sh
William Pitcock 2017-02-04 20:35:49 -06:00
parent 16ecf82fd7
commit b0c36cd128
1 changed files with 21 additions and 0 deletions

View File

@ -262,6 +262,8 @@ pkgconf_pkg_new_from_file(const pkgconf_client_t *client, const char *filename,
lineno++; lineno++;
PKGCONF_TRACE(client, "%s:%zu > [%s]", filename, lineno, readbuf);
p = readbuf; p = readbuf;
while (*p && (isalpha((unsigned int)*p) || isdigit((unsigned int)*p) || *p == '_' || *p == '.')) while (*p && (isalpha((unsigned int)*p) || isdigit((unsigned int)*p) || *p == '_' || *p == '.'))
p++; p++;
@ -441,16 +443,22 @@ pkgconf_pkg_try_specific_path(const pkgconf_client_t *client, const char *path,
char locbuf[PKG_CONFIG_PATH_SZ]; char locbuf[PKG_CONFIG_PATH_SZ];
char uninst_locbuf[PKG_CONFIG_PATH_SZ]; char uninst_locbuf[PKG_CONFIG_PATH_SZ];
PKGCONF_TRACE(client, "trying path: %s for %s", path, name);
snprintf(locbuf, sizeof locbuf, "%s/%s" PKG_CONFIG_EXT, path, name); snprintf(locbuf, sizeof locbuf, "%s/%s" PKG_CONFIG_EXT, path, name);
snprintf(uninst_locbuf, sizeof uninst_locbuf, "%s/%s-uninstalled" PKG_CONFIG_EXT, path, name); snprintf(uninst_locbuf, sizeof uninst_locbuf, "%s/%s-uninstalled" PKG_CONFIG_EXT, path, name);
if (!(client->flags & PKGCONF_PKG_PKGF_NO_UNINSTALLED) && (f = fopen(uninst_locbuf, "r")) != NULL) if (!(client->flags & PKGCONF_PKG_PKGF_NO_UNINSTALLED) && (f = fopen(uninst_locbuf, "r")) != NULL)
{ {
PKGCONF_TRACE(client, "found: %s", uninst_locbuf);
pkg = pkgconf_pkg_new_from_file(client, uninst_locbuf, f); pkg = pkgconf_pkg_new_from_file(client, uninst_locbuf, f);
pkg->flags |= PKGCONF_PKG_PROPF_UNINSTALLED; pkg->flags |= PKGCONF_PKG_PROPF_UNINSTALLED;
} }
else if ((f = fopen(locbuf, "r")) != NULL) else if ((f = fopen(locbuf, "r")) != NULL)
{
PKGCONF_TRACE(client, "found: %s", locbuf);
pkg = pkgconf_pkg_new_from_file(client, locbuf, f); pkg = pkgconf_pkg_new_from_file(client, locbuf, f);
}
return pkg; return pkg;
} }
@ -466,6 +474,8 @@ pkgconf_pkg_scan_dir(pkgconf_client_t *client, const char *path, void *data, pkg
if (dir == NULL) if (dir == NULL)
return NULL; return NULL;
PKGCONF_TRACE(client, "scanning dir [%s]", path);
for (dirent = readdir(dir); dirent != NULL; dirent = readdir(dir)) for (dirent = readdir(dir); dirent != NULL; dirent = readdir(dir))
{ {
static char filebuf[PKGCONF_BUFSIZE]; static char filebuf[PKGCONF_BUFSIZE];
@ -479,6 +489,8 @@ pkgconf_pkg_scan_dir(pkgconf_client_t *client, const char *path, void *data, pkg
if (!str_has_suffix(filebuf, PKG_CONFIG_EXT)) if (!str_has_suffix(filebuf, PKG_CONFIG_EXT))
continue; continue;
PKGCONF_TRACE(client, "trying file [%s]", filebuf);
f = fopen(filebuf, "r"); f = fopen(filebuf, "r");
if (f == NULL) if (f == NULL)
continue; continue;
@ -590,6 +602,8 @@ pkgconf_pkg_find(pkgconf_client_t *client, const char *name)
pkgconf_node_t *n; pkgconf_node_t *n;
FILE *f; FILE *f;
PKGCONF_TRACE(client, "looking for: %s", name);
/* name might actually be a filename. */ /* name might actually be a filename. */
if (str_has_suffix(name, PKG_CONFIG_EXT)) if (str_has_suffix(name, PKG_CONFIG_EXT))
{ {
@ -597,6 +611,8 @@ pkgconf_pkg_find(pkgconf_client_t *client, const char *name)
{ {
pkgconf_pkg_t *pkg; pkgconf_pkg_t *pkg;
PKGCONF_TRACE(client, "%s is a file", name);
pkg = pkgconf_pkg_new_from_file(client, name, f); pkg = pkgconf_pkg_new_from_file(client, name, f);
pkgconf_path_add(pkg_get_parent_dir(pkg), &client->dir_list, true); pkgconf_path_add(pkg_get_parent_dir(pkg), &client->dir_list, true);
@ -606,13 +622,18 @@ pkgconf_pkg_find(pkgconf_client_t *client, const char *name)
/* check builtins */ /* check builtins */
if ((pkg = pkgconf_builtin_pkg_get(name)) != NULL) if ((pkg = pkgconf_builtin_pkg_get(name)) != NULL)
{
PKGCONF_TRACE(client, "%s is a builtin", name);
return pkg; return pkg;
}
/* check cache */ /* check cache */
if (!(client->flags & PKGCONF_PKG_PKGF_NO_CACHE)) if (!(client->flags & PKGCONF_PKG_PKGF_NO_CACHE))
{ {
if ((pkg = pkgconf_cache_lookup(client, name)) != NULL) if ((pkg = pkgconf_cache_lookup(client, name)) != NULL)
{ {
PKGCONF_TRACE(client, "%s is cached", name);
pkg->flags |= PKGCONF_PKG_PROPF_CACHED; pkg->flags |= PKGCONF_PKG_PROPF_CACHED;
return pkg; return pkg;
} }