mirror of
https://github.com/clearlinux/clr-debug-info.git
synced 2026-09-06 13:51:38 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be74f893e6 | ||
|
|
7a5e4a9acd | ||
|
|
07a4c3d305 | ||
|
|
ab0e59628f | ||
|
|
af4a3f64f0 | ||
|
|
8c65e96479 | ||
|
|
7ea9a50b19 | ||
|
|
e16ab76926 | ||
|
|
090cb27a34 | ||
|
|
cbaf943fca | ||
|
|
32ae400e7d | ||
|
|
82f03f8e22 | ||
|
|
c1f45d9f3c | ||
|
|
bcff8fae39 | ||
|
|
66bab25bcd | ||
|
|
49ac392f01 | ||
|
|
71f4e789c4 | ||
|
|
f776162882 | ||
|
|
a2abd8d2a9 | ||
|
|
8844b0b0e1 |
@@ -4,10 +4,12 @@ clr_debug_fuse
|
|||||||
clr_debug_daemon
|
clr_debug_daemon
|
||||||
clr_debug_prepare
|
clr_debug_prepare
|
||||||
.deps/
|
.deps/
|
||||||
|
.dirstamp
|
||||||
Makefile
|
Makefile
|
||||||
Makefile.in
|
Makefile.in
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
autom4te.cache/
|
autom4te.cache/
|
||||||
|
compile
|
||||||
config.h
|
config.h
|
||||||
config.h.in
|
config.h.in
|
||||||
config.log
|
config.log
|
||||||
@@ -18,3 +20,5 @@ install-sh
|
|||||||
missing
|
missing
|
||||||
stamp-h1
|
stamp-h1
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
|
tags
|
||||||
|
cscope.*
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
EXTRA_DIST = COPYING clr_debug_fuse.service clr_debug_daemon.service debuginfo.conf
|
EXTRA_DIST = COPYING clr_debug_fuse.service clr_debug_daemon.service debuginfo.conf
|
||||||
|
|
||||||
|
DISTCHECK_CONFIGURE_FLAGS = \
|
||||||
|
--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) \
|
||||||
|
--with-systemdtmpfilesdir=$$dc_install_base/$(tmpfilesdir)
|
||||||
|
|
||||||
bin_PROGRAMS = clr_debug_fuse clr_debug_daemon clr_debug_prepare
|
bin_PROGRAMS = clr_debug_fuse clr_debug_daemon clr_debug_prepare
|
||||||
|
|
||||||
clr_debug_fuse_SOURCES = src/fuse.c src/client.c
|
clr_debug_fuse_SOURCES = src/fuse.c src/client.c
|
||||||
|
|||||||
+13
-5
@@ -2,7 +2,7 @@
|
|||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ([2.66])
|
AC_PREREQ([2.66])
|
||||||
AC_INIT(clr-debug-info, 11, arjan@linux.intel.com)
|
AC_INIT(clr-debug-info, 23, arjan@linux.intel.com)
|
||||||
AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects])
|
AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects])
|
||||||
AM_SILENT_RULES([yes])
|
AM_SILENT_RULES([yes])
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
@@ -13,11 +13,19 @@ PKG_CHECK_MODULES([curl], [libcurl])
|
|||||||
PKG_CHECK_MODULES([fuse], [fuse])
|
PKG_CHECK_MODULES([fuse], [fuse])
|
||||||
PKG_CHECK_MODULES([SYSTEMD], [systemd])
|
PKG_CHECK_MODULES([SYSTEMD], [systemd])
|
||||||
|
|
||||||
tmpfilesdir=`pkg-config --variable tmpfilesdir systemd`
|
dir=""
|
||||||
AC_SUBST(tmpfilesdir)
|
AC_ARG_WITH([systemdsystemunitdir], AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
|
||||||
|
[path to systemd system service dir @<:@default=/usr/lib/systemd/system@:>@]), [dir=${withval}],
|
||||||
|
[dir="$($PKG_CONFIG --variable=systemdsystemunitdir systemd)"])
|
||||||
|
test -z "${dir}" && dir=/usr/lib/systemd/system
|
||||||
|
AC_SUBST(systemdsystemunitdir, [${dir}])
|
||||||
|
|
||||||
systemdsystemunitdir=`pkg-config --variable systemdsystemunitdir systemd`
|
dir=""
|
||||||
AC_SUBST(systemdsystemunitdir)
|
AC_ARG_WITH([systemdtmpfilesdir], AS_HELP_STRING([--with-systemdtmpfilesdir=DIR],
|
||||||
|
[path to systemd tmpfiles dir @<:@default=/usr/lib/tmpfiles.d@:>@]), [dir=${withval}],
|
||||||
|
[dir="$($PKG_CONFIG --variable=tmpfilesdir systemd)"])
|
||||||
|
test -z "${dir}" && dir=/usr/lib/tmpfiles.d
|
||||||
|
AC_SUBST(tmpfilesdir, [${dir}])
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile])
|
AC_CONFIG_FILES([Makefile])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ Original copyright notice follows:
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <fuse.h>
|
#include <fuse.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|||||||
+45
-9
@@ -36,11 +36,15 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
GStaticMutex dupes_mutex = G_STATIC_MUTEX_INIT;
|
static GMutex dupes_mutex;
|
||||||
|
|
||||||
|
char *urls[2] = {"https://debuginfo.clearlinux.org/debuginfo/", "http://debuginfo.fenrus.org/debuginfo/" };
|
||||||
|
int urlcounter = 1;
|
||||||
|
|
||||||
|
|
||||||
static GHashTable *hash;
|
static GHashTable *hash;
|
||||||
@@ -49,7 +53,7 @@ static int avoid_dupes(const char *url)
|
|||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
void *value;
|
void *value;
|
||||||
g_static_mutex_lock(&dupes_mutex);
|
g_mutex_lock(&dupes_mutex);
|
||||||
|
|
||||||
if (hash == NULL)
|
if (hash == NULL)
|
||||||
hash = g_hash_table_new(g_str_hash, g_str_equal);
|
hash = g_hash_table_new(g_str_hash, g_str_equal);
|
||||||
@@ -67,7 +71,7 @@ static int avoid_dupes(const char *url)
|
|||||||
g_hash_table_replace(hash, strdup(url), data);
|
g_hash_table_replace(hash, strdup(url), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_static_mutex_unlock(&dupes_mutex);
|
g_mutex_unlock(&dupes_mutex);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +122,15 @@ static int curl_get_file(const char *url, const char *prefix, time_t timestamp)
|
|||||||
fflush(file);
|
fflush(file);
|
||||||
// printf("HTTP return code is %i\n", ret);
|
// printf("HTTP return code is %i\n", ret);
|
||||||
|
|
||||||
|
/* HTTP 304 is returned if (a) the cached debuginfo has the same
|
||||||
|
* timestamp or is newer than that on the server and (b) we haven't
|
||||||
|
* already added the URL to the hash table. So, the first crash for a
|
||||||
|
* boot may result in a 304 if the debuginfo had been downloaded in a
|
||||||
|
* previous boot.
|
||||||
|
*/
|
||||||
|
if (ret != 200 && ret != 404 && ret != 304)
|
||||||
|
urlcounter++;
|
||||||
|
|
||||||
if (ret == 200) {
|
if (ret == 200) {
|
||||||
char *command = NULL;
|
char *command = NULL;
|
||||||
// printf("Filename is %s\n", filename);
|
// printf("Filename is %s\n", filename);
|
||||||
@@ -184,8 +197,16 @@ static void *server_thread(void *arg)
|
|||||||
*path = 0;
|
*path = 0;
|
||||||
path++;
|
path++;
|
||||||
|
|
||||||
|
/* GDB and elfutils both stat /usr/lib/debug directly when looking up
|
||||||
|
* debuginfo, so avoid the download for "/.tar"; the associated cache
|
||||||
|
* directories already exist by this point.
|
||||||
|
*/
|
||||||
|
if (strlen(path) == 1 && strcmp(path, "/") == 0) {
|
||||||
|
close(fd);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (strstr(path, "..") || strstr(prefix, "..")) {
|
if (strstr(path, "..") || strstr(prefix, "..") || strstr(path, "'") || strstr(path, ";")) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -196,7 +217,7 @@ static void *server_thread(void *arg)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
url = NULL;
|
url = NULL;
|
||||||
if (asprintf(&url, "http://debuginfo.clearlinux.org/debuginfo/%s%s.tar", prefix, path) < 0) {
|
if (asprintf(&url, "%s%s%s.tar", urls[urlcounter % 2], prefix, path) < 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -204,14 +225,28 @@ static void *server_thread(void *arg)
|
|||||||
// printf("Getting url %s %i:%06i\n", url, before.tv_sec, before.tv_usec);
|
// printf("Getting url %s %i:%06i\n", url, before.tv_sec, before.tv_usec);
|
||||||
ret = curl_get_file(url, prefix, timestamp);
|
ret = curl_get_file(url, prefix, timestamp);
|
||||||
|
|
||||||
/* tell the other side we're done with the download */
|
switch (ret) {
|
||||||
write(fd, "ok", 3);
|
case 200:
|
||||||
close(fd);
|
case 300:
|
||||||
|
case 304:
|
||||||
|
case 404:
|
||||||
|
// ignore these error codes
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("Request for %s resulted in error %i\n", url, ret);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
gettimeofday(&after, NULL);
|
gettimeofday(&after, NULL);
|
||||||
if (timedelta(before, after) > 0.6)
|
if (timedelta(before, after) > 0.6)
|
||||||
printf("Request for %s took %5.2f seconds (%i - %i)\n", url,
|
printf("Request for %s took %5.2f seconds (%i - %i)\n", url,
|
||||||
after.tv_sec - before.tv_sec + (1.0*after.tv_usec - before.tv_usec) / 1000000.0, ret, (int)timestamp);
|
after.tv_sec - before.tv_sec + (1.0*after.tv_usec - before.tv_usec) / 1000000.0, ret, (int)timestamp);
|
||||||
|
|
||||||
|
/* tell the other side we're done with the download */
|
||||||
|
write(fd, "ok", 3);
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
|
||||||
free(url);
|
free(url);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -259,8 +294,9 @@ int main(int argc, char **argv)
|
|||||||
int clientsock;
|
int clientsock;
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
|
|
||||||
|
malloc_trim(0);
|
||||||
clientsock = accept(sockfd, NULL, NULL);
|
clientsock = accept(sockfd, NULL, NULL);
|
||||||
|
|
||||||
if (!curl_done) {
|
if (!curl_done) {
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
curl_done = 1;
|
curl_done = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user