|
@@ -34,6 +34,7 @@
|
|
|
|
|
|
#include <linux/bitops.h>
|
|
|
#include "event.h"
|
|
|
+#include "dso.h"
|
|
|
#include "debug.h"
|
|
|
#include "intlist.h"
|
|
|
#include "util.h"
|
|
@@ -89,7 +90,7 @@ error:
|
|
|
return -ENOENT;
|
|
|
}
|
|
|
|
|
|
-struct debuginfo *debuginfo__new(const char *path)
|
|
|
+static struct debuginfo *__debuginfo__new(const char *path)
|
|
|
{
|
|
|
struct debuginfo *dbg = zalloc(sizeof(*dbg));
|
|
|
if (!dbg)
|
|
@@ -97,10 +98,46 @@ struct debuginfo *debuginfo__new(const char *path)
|
|
|
|
|
|
if (debuginfo__init_offline_dwarf(dbg, path) < 0)
|
|
|
zfree(&dbg);
|
|
|
-
|
|
|
+ if (dbg)
|
|
|
+ pr_debug("Open Debuginfo file: %s\n", path);
|
|
|
return dbg;
|
|
|
}
|
|
|
|
|
|
+enum dso_binary_type distro_dwarf_types[] = {
|
|
|
+ DSO_BINARY_TYPE__FEDORA_DEBUGINFO,
|
|
|
+ DSO_BINARY_TYPE__UBUNTU_DEBUGINFO,
|
|
|
+ DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO,
|
|
|
+ DSO_BINARY_TYPE__BUILDID_DEBUGINFO,
|
|
|
+ DSO_BINARY_TYPE__NOT_FOUND,
|
|
|
+};
|
|
|
+
|
|
|
+struct debuginfo *debuginfo__new(const char *path)
|
|
|
+{
|
|
|
+ enum dso_binary_type *type;
|
|
|
+ char buf[PATH_MAX], nil = '\0';
|
|
|
+ struct dso *dso;
|
|
|
+ struct debuginfo *dinfo = NULL;
|
|
|
+
|
|
|
+ /* Try to open distro debuginfo files */
|
|
|
+ dso = dso__new(path);
|
|
|
+ if (!dso)
|
|
|
+ goto out;
|
|
|
+
|
|
|
+ for (type = distro_dwarf_types;
|
|
|
+ !dinfo && *type != DSO_BINARY_TYPE__NOT_FOUND;
|
|
|
+ type++) {
|
|
|
+ if (dso__read_binary_type_filename(dso, *type, &nil,
|
|
|
+ buf, PATH_MAX) < 0)
|
|
|
+ continue;
|
|
|
+ dinfo = __debuginfo__new(buf);
|
|
|
+ }
|
|
|
+ dso__delete(dso);
|
|
|
+
|
|
|
+out:
|
|
|
+ /* if failed to open all distro debuginfo, open given binary */
|
|
|
+ return dinfo ? : __debuginfo__new(path);
|
|
|
+}
|
|
|
+
|
|
|
void debuginfo__delete(struct debuginfo *dbg)
|
|
|
{
|
|
|
if (dbg) {
|