[RFC dwarves 3/6] pahole: Add btf_encode to conf_load

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This will allow us to take BTF encoding-specific actions in
the btf_loader.

Signed-off-by: Alan Maguire <alan.maguire@xxxxxxxxxx>
---
 dwarves.h |  1 +
 pahole.c  | 15 +++++++--------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/dwarves.h b/dwarves.h
index 21d4166..feb7402 100644
--- a/dwarves.h
+++ b/dwarves.h
@@ -87,6 +87,7 @@ struct conf_load {
 	bool			ignore_inline_expansions;
 	bool			ignore_labels;
 	bool			ptr_table_stats;
+	bool			btf_encode;
 	bool			skip_encoding_btf_decl_tag;
 	bool			skip_missing;
 	bool			skip_encoding_btf_type_tag;
diff --git a/pahole.c b/pahole.c
index ef01e58..96c748b 100644
--- a/pahole.c
+++ b/pahole.c
@@ -32,7 +32,6 @@
 static struct btf_encoder *btf_encoder;
 static char *detached_btf_filename;
 struct cus *cus;
-static bool btf_encode;
 static bool ctf_encode;
 static bool sort_output;
 static bool need_resort;
@@ -1864,7 +1863,7 @@ static error_t pahole__options_parser(int key, char *arg,
 							break;
 	case ARGP_btf_encode_detached:
 		  detached_btf_filename = arg; // fallthru
-	case 'J': btf_encode = 1;
+	case 'J': conf_load.btf_encode = true;
 		  conf_load.get_addr_info = true;
 		  conf_load.ignore_alignment_attr = true;
 		  // XXX for now, test this more thoroughly
@@ -3217,7 +3216,7 @@ static enum load_steal_kind pahole_stealer(struct cu *cu, struct conf_load *conf
 	    print_enumeration_with_enumerator(cu, enumerator_name))
 		return LSK__DELETE; // Maybe we can find this in several CUs, so don't stop it
 
-	if (btf_encode) {
+	if (conf_load->btf_encode) {
 		return pahole_stealer__btf_encode(cu, conf_load);
 	}
 #if 0
@@ -3530,7 +3529,7 @@ int main(int argc, char *argv[])
 	// and as this is at this point unintended, avoid that.
 	// Next we need to just skip object files that don't have the format we
 	// expect as the source for BTF encoding, i.e. no DWARF, no BTF, no problema.
-	if (btf_encode && conf_load.format_path == NULL)
+	if (conf_load.btf_encode && conf_load.format_path == NULL)
 		conf_load.format_path = "dwarf";
 
 	if (show_running_kernel_vmlinux) {
@@ -3593,7 +3592,7 @@ int main(int argc, char *argv[])
 				base_btf_file, libbpf_get_error(conf_load.base_btf));
 			goto out;
 		}
-		if (!btf_encode && !ctf_encode) {
+		if (!conf_load.btf_encode && !ctf_encode) {
 			// Force "btf" since a btf_base is being informed
 			conf_load.format_path = "btf";
 		}
@@ -3641,7 +3640,7 @@ try_sole_arg_as_class_names:
 
 	err = cus__load_files(cus, &conf_load, argv + remaining);
 	if (err != 0) {
-		if (class_name == NULL && !btf_encode && !ctf_encode) {
+		if (class_name == NULL && !conf_load.btf_encode && !ctf_encode) {
 			class_name = argv[remaining];
 
 			if (class_name == NULL) {
@@ -3658,7 +3657,7 @@ try_sole_arg_as_class_names:
 			goto try_sole_arg_as_class_names;
 		}
 
-		if (btf_encode || ctf_encode) {
+		if (conf_load.btf_encode || ctf_encode) {
 			// If encoding is asked for and there is no DEBUG info to encode from,
 			// there are no errors, continue...
 			goto out_ok;
@@ -3717,7 +3716,7 @@ try_sole_arg_as_class_names:
 	type_instance__delete(header);
 	header = NULL;
 
-	if (btf_encode && btf_encoder) { // maybe all CUs were filtered out and thus we don't have an encoder?
+	if (conf_load.btf_encode && btf_encoder) { // maybe all CUs were filtered out and thus we don't have an encoder?
 		err = btf_encoder__encode(btf_encoder, &conf_load);
 		btf_encoder__delete(btf_encoder);
 		if (err) {
-- 
2.43.5





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux