From f95604c922c8a6638125efdb955eee1897f02740 Mon Sep 17 00:00:00 2001
From: Kai Liu <kaliu@codeaurora.org>
Date: Thu, 26 Jul 2018 19:42:36 +0800
Subject: [PATCH] lrdp_v2: Remove parameter --32-bit and --64-bit

Use elf header to decide vmlinux is 32 or 64 bits instead of parameter

Change-Id: Id2f68fc58160e259a011247b6cbfd4efa9dab5e4
---
 linux-ramdump-parser-v2/ramparse.py | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/linux-ramdump-parser-v2/ramparse.py b/linux-ramdump-parser-v2/ramparse.py
index ef9f967..7864502 100644
--- a/linux-ramdump-parser-v2/ramparse.py
+++ b/linux-ramdump-parser-v2/ramparse.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python2
 
-# Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+# Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License version 2 and
@@ -122,10 +122,6 @@ if __name__ == '__main__':
         help='Force the hardware detection to a specific hardware version')
     parser.add_option('', '--parse-qdss', action='store_true',
                       dest='qdss', help='Parse QDSS (deprecated)')
-    parser.add_option('', '--64-bit', action='store_true', dest='arm64',
-                      help='Parse dumps as 64-bit dumps (default)')
-    parser.add_option('', '--32-bit', action='store_true', dest='arm32',
-                      help='Parse dumps as 32-bit dumps')
     parser.add_option('', '--shell', action='store_true',
                       help='Run an interactive python interpreter with the ramdump loaded')
     parser.add_option('', '--classic-shell', action='store_true',
@@ -248,6 +244,14 @@ if __name__ == '__main__':
                     'Ram file {0} does not exist. Exiting...'.format(a[0]))
                 sys.exit(1)
 
+    # offset 4 of vmlinux indcates it's 32 or 64 bits
+    # for 64 bits it is 0x2, for 32 bits it is 0x1
+    vm_file = open(options.vmlinux)
+    vm_file.seek(4, 0)
+    bin_bits = vm_file.read(1)
+    vm_file.close()
+    options.arm64 = ord(bin_bits) == 0x02
+
     if options.wlan is None:
         options.wlan = "INTEGRATED"
     else:
@@ -260,12 +264,6 @@ if __name__ == '__main__':
     nm_path = options.nm
     objdump_path = options.objdump
 
-    if options.arm64:
-        print_out_str('--64-bit is deprecated. Dumps are assumed to be 64-bit by default.')
-        print_out_str('For 32-bit dumps, use --32-bit.')
-    else:
-        options.arm64 = not options.arm32
-
     try:
         import local_settings
         try:
-- 
GitLab