From ec7d924df2bda081b40cd7eeed853e12e1632ff8 Mon Sep 17 00:00:00 2001
From: Sri Krishna Madireddy <smadired@codeaurora.org>
Date: Mon, 3 Jul 2017 14:11:46 -0700
Subject: [PATCH] Add RDP support for new dcc_parser changes

With new dcc_parser support DCC_SRAM.BIN is directtly
passed with given offset to read register information.

Change-Id: I84225fd63034a652de1ed67644251aa0e045b310
---
 dcc_parser/dcc_parser.py                  |  2 +-
 linux-ramdump-parser-v2/debug_image_v2.py | 24 +++++++++++++----------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/dcc_parser/dcc_parser.py b/dcc_parser/dcc_parser.py
index 1d23b52..4ec60ab 100644
--- a/dcc_parser/dcc_parser.py
+++ b/dcc_parser/dcc_parser.py
@@ -93,7 +93,7 @@ def read_config(config_pt):
         track_len = 4
 
     if options.config_offset is not None:
-        config_pt.seek(options.config_offset, 1)
+        config_pt.seek(int(options.config_offset, 16), 1)
 
     while True:
         word = config_pt.read(4)
diff --git a/linux-ramdump-parser-v2/debug_image_v2.py b/linux-ramdump-parser-v2/debug_image_v2.py
index b603209..bce5843 100644
--- a/linux-ramdump-parser-v2/debug_image_v2.py
+++ b/linux-ramdump-parser-v2/debug_image_v2.py
@@ -458,9 +458,10 @@ class DebugImage_v2():
         subprocess.call('{0} -c {1} exit'.format(qtf_path, port))
         server_proc.communicate('quit')
 
-    def parse_dcc(self, ram_dump):
+    def parse_dcc(self, ram_dump, config_offset):
         out_dir = ram_dump.outdir
-
+        bin_dir = ram_dump.ram_addr
+        bin_dir="\\".join(bin_dir[0][0].split('\\')[:-1])
         dcc_parser_path = os.path.join(os.path.dirname(__file__), '..', 'dcc_parser', 'dcc_parser.py')
 
         if dcc_parser_path is None:
@@ -471,16 +472,17 @@ class DebugImage_v2():
             print_out_str("!!! dcc_parser_path {0} does not exist! Check your settings!".format(dcc_parser_path))
             return
 
-        if os.path.getsize(os.path.join(out_dir, 'sram.bin')) > 0:
+        if os.path.isfile(os.path.join(out_dir, 'sram.bin')) > 0:
             sram_file = os.path.join(out_dir, 'sram.bin')
+        elif os.path.isfile(os.path.join(bin_dir, 'DCC_SRAM.BIN')):
+            sram_file = os.path.join(bin_dir, 'DCC_SRAM.BIN')
         else:
             return
-        bin_dir = ram_dump.ram_addr
-        bin_dir="\\".join(bin_dir[0][0].split('\\')[:-1])
-        if (os.path.isfile(os.path.join(bin_dir, 'DCC_SRAM.BIN'))):
-            p = subprocess.Popen([sys.executable, dcc_parser_path, '-s', sram_file, '--out-dir', out_dir, '--v2'],
-                    stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-        else:
+
+        if (os.path.isfile(os.path.join(bin_dir, 'DCC_SRAM.BIN'))) and (config_offset != None):
+            cmd = ["-s ", sram_file, " --out-dir ", out_dir, " --config-offset ", str(config_offset), " --v2"]
+            p = subprocess.Popen([sys.executable, dcc_parser_path, cmd], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+        elif config_offset == None:
             p = subprocess.Popen([sys.executable, dcc_parser_path, '-s', sram_file, '--out-dir', out_dir],
                     stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 
@@ -806,7 +808,9 @@ class DebugImage_v2():
                                 self, 20, client_entry,
                                 client_end, client_id, ram_dump)
         if ram_dump.dcc:
-            self.parse_dcc(ram_dump)
+            self.parse_dcc(ram_dump, config_offset = None)
+        else:
+            self.parse_dcc(ram_dump, config_offset = "0x6000")
         if ram_dump.sysreg:
             self.parse_sysreg(ram_dump)
         self.qdss.dump_standard(ram_dump)
-- 
GitLab