From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org
Subject: [PATCH] Factor out dwz_with_low_mem
Date: Tue, 23 Mar 2021 09:52:21 +0100 [thread overview]
Message-ID: <20210323085220.GA3361@delia> (raw)
Hi,
Factor out new function dwz_with_low_mem out of dwz_one_file/dwz_files.
Any comments?
Thanks,
- Tom
Factor out dwz_with_low_mem
2021-03-23 Tom de Vries <tdevries@suse.de>
* dwz.c (dwz_with_low_mem): New function, factored out of ...
(dwz_one_file): ... here, and ...
(dwz_files): here.
---
dwz.c | 56 +++++++++++++++++++++++++++++++++-----------------------
1 file changed, 33 insertions(+), 23 deletions(-)
diff --git a/dwz.c b/dwz.c
index a7aa23b..4fc1e7d 100644
--- a/dwz.c
+++ b/dwz.c
@@ -16256,32 +16256,49 @@ make_temp_file (const char *name)
return fd;
}
-/* Dwarf-compress FILE. If OUTFILE, write to result to OUTFILE, otherwise
- modify FILE. */
+/* As dwz, but retry with MULTIFILE_MODE_LOW_MEM if the low_mem_die_limit
+ is hit. */
static int
-dwz_one_file (const char *file, const char *outfile)
+dwz_with_low_mem (const char *file, const char *outfile,
+ struct file_result *res, struct file_result *resa,
+ char **files, bool *low_mem_p)
{
- int ret = 0;
- struct file_result res;
-
- if (stats_p)
- init_stats (file);
+ int ret;
- res.die_count = 0;
+ if (low_mem_p)
+ *low_mem_p = false;
ret = (low_mem_die_limit == 0
? 2
- : dwz (file, outfile, &res, NULL, NULL));
+ : dwz (file, outfile, res, resa, files));
if (ret == 2)
{
multifile_mode = MULTIFILE_MODE_LOW_MEM;
- ret = dwz (file, outfile, &res, NULL, NULL);
+ if (low_mem_p)
+ *low_mem_p = true;
+
+ ret = dwz (file, outfile, res, resa, files);
}
return ret;
}
+/* Dwarf-compress FILE. If OUTFILE, write to result to OUTFILE, otherwise
+ modify FILE. */
+static int
+dwz_one_file (const char *file, const char *outfile)
+{
+ struct file_result res;
+
+ if (stats_p)
+ init_stats (file);
+
+ res.die_count = 0;
+
+ return dwz_with_low_mem (file, outfile, &res, NULL, NULL, NULL);
+}
+
/* Dwarf-compress FILES. If HARDLINK, detect if some files are hardlinks and
if so, dwarf-compress just one, and relink the others. */
static int
@@ -16324,19 +16341,12 @@ dwz_files (int nr_files, char *files[], bool hardlink)
file = files[i];
if (stats_p)
init_stats (file);
- thisret = (low_mem_die_limit == 0
- ? 2
- : dwz (file, NULL, &resa[i],
- hardlinks ? resa : NULL, files));
- if (thisret == 2)
- {
- multifile_mode = MULTIFILE_MODE_LOW_MEM;
- thisret = dwz (file, NULL, &resa[i],
- hardlinks ? resa : NULL, files);
- }
- else if (thisret == 1)
+ bool low_mem_p;
+ thisret = dwz_with_low_mem (file, NULL, &resa[i],
+ hardlinks ? resa : NULL, files, &low_mem_p);
+ if (thisret == 1)
ret = 1;
- else if (resa[i].res >= 0)
+ else if (!low_mem_p && resa[i].res >= 0)
successcount++;
if (hardlink
&& resa[i].res >= 0
reply other threads:[~2021-03-23 8:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210323085220.GA3361@delia \
--to=tdevries@suse.de \
--cc=dwz@sourceware.org \
--cc=jakub@redhat.com \
--cc=mark@klomp.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).