Commit 61e35be1 authored by Gaurav Kukreja's avatar Gaurav Kukreja

Change to gdb_info.py to avoid GDB errors from stopping the tool.

Signed-off-by: Gaurav Kukreja's avatarGaurav Kukreja <gaurav@gauravk.in>
parent ac90b256
......@@ -25,6 +25,8 @@ BITXOR_OP = Literal("^")
BITOR_OP = Literal("|")
BITAND_OP = Literal("&")
CONSTANT_EXP = CONSTANT + Literal("e") + (ADD_OP|SUB_OP) + CONSTANT
EQ_OP = Literal("==")
NE_OP = Literal("!=")
GT_OP = Literal(">")
......@@ -223,6 +225,7 @@ def act_lparen_expression(tokens):
expression = Forward()
primary_expression = ( IDENTIFIER.setParseAction(act_identifier)
^ CONSTANT
^ CONSTANT_EXP
^ STRING_LITERAL
^ ((LPAREN.setParseAction(act_lparen_expression) + expression + RPAREN.setParseAction(act_rparen_expression)))
)
......@@ -271,7 +274,7 @@ def act_array_index_lbrace(tokens):
# Removing Left Recursion
postfix_expression_1 = Forward()
postfix_expression_1 << ( (Literal("[").setParseAction(act_array_index_lbrace) + Combine(expression).setParseAction(act_array_index_expression) + Literal("]").setParseAction(act_array_index_rbrace))
postfix_expression_1 << ( (Literal("[").setParseAction(act_array_index_lbrace) + Combine(expression).setParseAction(act_array_index_expression) + Literal("]").setParseAction(act_array_index_rbrace) + postfix_expression_1)
| (PTR_OP + IDENTIFIER + postfix_expression_1)
| (Literal(".") + IDENTIFIER + postfix_expression_1)
| Empty()
......
......@@ -53,6 +53,15 @@ def debugListVariables(listVariables):
print ""
def gdbxFilePrefix(file):
file.write("python\n")
file.write("def exe(arg):\n")
file.write("\ttry:\n")
file.write("\t\tgdb.execute (arg)\n")
file.write("\texcept:\n")
file.write("\t\tpass\n")
file.write("\tpass\n")
# class GlobalVariable:
# def __init__(self):
# self.name = ""
......@@ -229,6 +238,7 @@ def getLocalVariablesForAllFunc(listBinaryFileNames, listFunctionsObj):
gdbOFileName = "/tmp/" + func.functionName + ".lVarName.gdbo"
gdbXFile = open(gdbXFileName, 'w')
# gdbxFilePrefix(gdbXFile)
gdbXFile.write("target sim\n")
gdbXFile.write("load\n")
gdbXFile.write("b %s\n" % func.functionName)
......@@ -276,6 +286,7 @@ def getLocalVariablesForAllFunc(listBinaryFileNames, listFunctionsObj):
gdbOFile.close()
gdbXFile = open(gdbXFileName, 'w')
# gdbxFilePrefix(gdbXFile)
gdbXFile.write("target sim\n")
gdbXFile.write("load\n")
gdbXFile.write("info scope %s\n" % func.functionName)
......@@ -303,20 +314,21 @@ def getLocalVariablesForAllFunc(listBinaryFileNames, listFunctionsObj):
gdbOFile.close()
gdbXFile = open(gdbXFileName, 'w')
gdbXFile.write("target sim\n")
gdbXFile.write("load\n")
gdbXFile.write("b %s\n" % func.functionName)
gdbXFile.write("commands\n")
gdbXFile.write("\tprintf \"SP = %s\\n\", %s\n" % ("%x", "$sp"))
gdbxFilePrefix(gdbXFile)
gdbXFile.write('exe("target sim")\n')
gdbXFile.write('exe("load")\n')
gdbXFile.write('exe("b %s")\n' % func.functionName)
# gdbXFile.write('exe("commands")\n')
gdbXFile.write('exe("\tprintf \\"SP = %s\\\\n\\", %s")\n' % ("%x", "$sp"))
for varName in listLocalVarNames:
gdbXFile.write("\tprintf \"LocalVar: %s\\n\"\n" % (varName))
gdbXFile.write("\tprintf \"address = 0x%s\\n\", &%s\n" % ("%x", varName))
gdbXFile.write("\tptype %s\n" % varName)
gdbXFile.write("\tprintf \"size = %s\\n\", sizeof(%s)\n" % ("%d", varName))
gdbXFile.write('exe(\'printf "LocalVar: %s\\\\n"\')\n' % (varName))
gdbXFile.write('exe(\'printf "address = 0x%s\\\\n", &%s\')\n' % ("%x", varName))
gdbXFile.write('exe(\'ptype %s\')\n' % varName)
gdbXFile.write('exe(\'printf "size = %s\\\\n", sizeof(%s)\')\n' % ("%d", varName))
# gdbXFile.write("\tcont\n")
gdbXFile.write("end\n")
gdbXFile.write("run\n")
gdbXFile.write("quit\n")
# gdbXFile.write('exe("end")\n')
gdbXFile.write('exe("run")\n')
gdbXFile.write('exe("quit")\n')
gdbXFile.close()
gdbOFile = open(gdbOFileName, 'w')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment