do delayed path resolving of files containing symbols

we still need to teach this to locate debug dirs relative to the
process paths.
This commit is contained in:
Christian Hergert
2021-09-15 17:52:58 -07:00
parent 3e7e677419
commit 5f352abc86
3 changed files with 265 additions and 51 deletions

View File

@ -20,6 +20,7 @@
#include "config.h"
#include "sysprof-platform.h"
#include "sysprof-symbol-resolver.h"
G_DEFINE_INTERFACE (SysprofSymbolResolver, sysprof_symbol_resolver, G_TYPE_OBJECT)
@ -125,11 +126,11 @@ sysprof_symbol_resolver_resolve (SysprofSymbolResolver *self,
*/
gchar *
sysprof_symbol_resolver_resolve_with_context (SysprofSymbolResolver *self,
guint64 time,
GPid pid,
SysprofAddressContext context,
SysprofCaptureAddress address,
GQuark *tag)
guint64 time,
GPid pid,
SysprofAddressContext context,
SysprofCaptureAddress address,
GQuark *tag)
{
GQuark dummy;
@ -142,3 +143,45 @@ sysprof_symbol_resolver_resolve_with_context (SysprofSymbolResolver *self,
return SYSPROF_SYMBOL_RESOLVER_GET_IFACE (self)->resolve_with_context (self, time, pid, context, address, tag);
}
char *
_sysprof_symbol_resolver_load_file (SysprofCaptureReader *reader,
const char *path)
{
g_autofree char *data = NULL;
goffset len;
goffset pos = 0;
int fd;
g_assert (reader != NULL);
g_assert (path != NULL);
sysprof_capture_reader_reset (reader);
if (-1 == (fd = sysprof_memfd_create ("")) ||
!sysprof_capture_reader_read_file_fd (reader, path, fd))
{
if (fd != -1)
close (fd);
return NULL;
}
len = lseek (fd, 0L, SEEK_CUR);
data = g_malloc (len + 1);
lseek (fd, 0L, SEEK_SET);
while (pos < len)
{
gssize n_read = read (fd, data + pos, len - pos);
if (n_read < 0)
return NULL;
pos += n_read;
}
data[len] = 0;
close (fd);
return g_steal_pointer (&data);
}