summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2017-04-21 17:33:26 +0200
committerPanu Matilainen <pmatilai@redhat.com>2017-04-24 14:01:06 +0300
commite795899780337dea751d85db8f381eff3fe75275 (patch)
treefb2601e92b5b317b1242f28d849647781b1d4dfa /tools
parentaa5cf0c37eca494e22fbe7776e4142b4161f49e9 (diff)
downloadrpm-e795899780337dea751d85db8f381eff3fe75275.tar.gz
debugedit: Only output comp_dir under build dir (once).
The fix for rhbz#444310 (commit c1a5eb - Include empty CU current dirs) was a little greedy. It would also include comp_dirs outside the build root. Those are unnecessary and we don't have a good way to store them. Such dirs (e.g. /tmp) would then show up at the root of /usr/src/debug. Fix this by including only comp_dirs under base_dir. Also only output all dirs once (during phase zero) and don't output empty dirs (which was harmless but would produce a warning from cpio). This still includes all empty dirs from the original rhbz#444310 nodir testcase and it is an alternative fix for rhbz#641022 (commit c707ab). Both fixes are necessary in case of an unexpected mode for a directory actually in the build root that we want to include in the source list. Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/debugedit.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/tools/debugedit.c b/tools/debugedit.c
index 8444e030e..bf115136c 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -1680,30 +1680,23 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
/* Ensure the CU current directory will exist even if only empty. Source
filenames possibly located in its parent directories refer relatively to
it and the debugger (GDB) cannot safely optimize out the missing
- CU current dir subdirectories. */
- if (comp_dir && list_file_fd != -1)
+ CU current dir subdirectories. Only do this once in phase one. And
+ only do this for dirs under our build/base_dir. Don't output the
+ empty string (in case the comp_dir == base_dir). */
+ if (phase == 0 && base_dir && comp_dir && list_file_fd != -1)
{
- const char *p = NULL;
- size_t size;
-
- if (base_dir)
- {
- p = skip_dir_prefix (comp_dir, base_dir);
- if (p == NULL && dest_dir != NULL)
- p = skip_dir_prefix (comp_dir, dest_dir);
- }
-
- if (p == NULL)
- p = comp_dir;
-
- size = strlen (p) + 1;
- while (size > 0)
- {
- ssize_t ret = write (list_file_fd, p, size);
- if (ret == -1)
- break;
- size -= ret;
- p += ret;
+ const char *p = skip_dir_prefix (comp_dir, base_dir);
+ if (p != NULL && p[0] != '\0')
+ {
+ size_t size = strlen (p) + 1;
+ while (size > 0)
+ {
+ ssize_t ret = write (list_file_fd, p, size);
+ if (ret == -1)
+ break;
+ size -= ret;
+ p += ret;
+ }
}
}