[Lldb-commits] [PATCH] D56293: Use the minidump exception record if present

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Fri Jan 4 11:10:08 PST 2019


The main goal for this minidump module was so I could load it into lldb and then run "minidump --save" to save the current process as a minidump file since I like minidump files better than core files... It just happens to work for generating very small and targeted minidump files for testing as a benefit of code reuse.

Greg


> On Jan 4, 2019, at 11:07 AM, Zachary Turner <zturner at google.com> wrote:
> 
> Waiiiiiiit a second.  Why don't we just teach obj2yaml and yaml2obj to round-trip minidumps?  This way you could run it on a minidump, then hand-edit it to customize some bits you want to change, then check in the yaml.
> 
> On Fri, Jan 4, 2019 at 10:56 AM Greg Clayton <clayborg at gmail.com <mailto:clayborg at gmail.com>> wrote:
> 
>> On Jan 4, 2019, at 9:45 AM, Leonard Mosescu <mosescu at google.com <mailto:mosescu at google.com>> wrote:
>> 
>> I have a minidump generator if you need me to make any specific minidump files for you.
>> 
>> Maybe not in this case, but it seems an interesting idea. What are the capabilities of this generator tool?
> 
> I can generate threads contexts, any of the textual directory streams, memory regions (32 and 64), module lists, and more.
> 
> Example code from my python "minidump" module that shows generation of a minidump. Not all of this goes together (example code for ARM and ARM64), but it shows what you can easily do:
> 
> system_info = minidump.SystemInfo(
>         ProcessorArchitecture=minidump.PROCESSOR_ARCHITECTURE_ARM64,
>         PlatformId=minidump.VER_PLATFORM_LINUX,
>         CSDVersion=minidump.String('15E216'))
> 
> md = minidump.Generator(system_info, ProcessId=123)
> 
> x = []
> v = []
> for i in range(32):
>     x.append(i+1 | i+2 << 32 | i+3 << 48)
> for i in range(32):
>     for j in range(16):
>         v.append(i+j)
> 
> thread = minidump.Thread(ThreadId=0x1000,
>                             Registers=minidump.ThreadContext_ARM64(
>                                 x=x, pc=0x1000, cpsr=0x11223344,
>                                 fpsr=0x55667788, fpcr=0x99AABBCC, v=v))
> 
> system_info = minidump.SystemInfo(
>         ProcessorArchitecture=minidump.PROCESSOR_ARCHITECTURE_ARM,
>         PlatformId=minidump.VER_PLATFORM_MACOSX,
>         CSDVersion=minidump.String('ABC123'))
> 
> md = minidump.Generator(system_info, ProcessId=123)
> 
> r = []
> d = []
> extra = []
> for i in range(1, 17):
>     r.append(i)
> for i in range(1, 33):
>     d.append(i | i << 8 | i << 32 | i << 48)
> for i in range(8):
>     extra.append(i | i << 16)
> 
> thread = minidump.Thread(ThreadId=0x1000,
>                             Registers=minidump.ThreadContext_ARM(
>                                 r=r, cpsr=0x11223344,
>                                 fpscr=0x55667788AABBCCDD, d=d,
>                                 extra=extra))
> md.add_thread(thread)
> md.add_thread(minidump.Thread(ThreadId=0x55667788))
> 
> md.add_module(minidump.Module(BaseOfImage=0x10000,
>                                 SizeOfImage=0x2000,
>                                 CheckSum=0,
>                                 TimeDateStamp=0,
>                                 ModuleName="/tmp/b",
>                                 VersionInfo=None,
>                                 CvRecord=None,
>                                 MiscRecord=None,
>                                 Reserved0=0,
>                                 Reserved1=0))
> 
> md.add_module(minidump.Module(BaseOfImage=0x2000,
>                                 SizeOfImage=0x1000,
>                                 CheckSum=0,
>                                 TimeDateStamp=0,
>                                 ModuleName="/tmp/a",
>                                 VersionInfo=None,
>                                 CvRecord=None,
>                                 MiscRecord=None,
>                                 Reserved0=0,
>                                 Reserved1=0))
> 
> md.add_module(minidump.Module(BaseOfImage=0x1000,
>                                 SizeOfImage=0x1000,
>                                 CheckSum=0,
>                                 TimeDateStamp=0,
>                                 ModuleName="/tmp/b",
>                                 VersionInfo=None,
>                                 CvRecord=None,
>                                 MiscRecord=None,
>                                 Reserved0=0,
>                                 Reserved1=0))
> 
> 
> md.add_module(minidump.Module(BaseOfImage=0x5000,
>                                 SizeOfImage=0x3000,
>                                 CheckSum=0,
>                                 TimeDateStamp=0,
>                                 ModuleName="/tmp/b",
>                                 VersionInfo=None,
>                                 CvRecord=None,
>                                 MiscRecord=None,
>                                 Reserved0=0,
>                                 Reserved1=0))
> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x8000,
>                                         Bytes='Hello world!'))
> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x8010,
>                                         Bytes='Goodbye moon...'))
> md.add_memory64(minidump.MemoryDescriptor64(StartOfMemoryRange=0x1000,
>                                             Bytes='1' * 16))
> md.add_memory64(minidump.MemoryDescriptor64(StartOfMemoryRange=0x2000,
>                                             Bytes='3' * 32))
> 
> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x1000,
>                                         Bytes='1' * 16))
> md.add_memory(minidump.MemoryDescriptor(StartOfMemoryRange=0x2000,
>                                         Bytes='3' * 32))
> 
> maps = '''400d9000-400db000 r-xp 00000000 b3:04 227        /system/bin/app_process
> 400db000-400dc000 r--p 00001000 b3:04 227        /system/bin/app_process
> 400dc000-400dd000 rw-p 00000000 00:00 0 
> '''
> md.add_stream_as_string(minidump.BreakpadLinuxMaps, maps)
> pad = True
> addr_size = 4
> md.save("/tmp/minidump.dmp", addr_size, pad)
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190104/cea57985/attachment-0001.html>


More information about the lldb-commits mailing list