Core dump presentation
Upcoming SlideShare
Loading in...5
×
 

Core dump presentation

on

  • 2,465 views

Presentation to the class on how to use and create core dump files. also superficially covers the differences.

Presentation to the class on how to use and create core dump files. also superficially covers the differences.

Statistics

Views

Total Views
2,465
Views on SlideShare
2,465
Embed Views
0

Actions

Likes
1
Downloads
34
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Core dump presentation Core dump presentation Presentation Transcript

    • Core dumpHow to: Generate and Use a CoreFileLinux vs Solaris ExampleStacy Watts10/24/2012CS 201 Fall 2012Portland State University
    • About these slidesThese slides are geared towards the students inCS 201 at Portland State University.For folks outside our class I am assuming you: Have some programming experience Havent yet explored the idea of a core dump in detail.My habit for filenames is camelCase as you willsee in these slides. Your habitmight_be_different.
    • coredump vs segfaultProgramming we get to see both of thesemessages. segfault is an access violation. You went somewhere in memory you didnt have permission to go! coredump refers both to the action of taking a complete snapshot of the memory and registers, and the file generated by that action.
    • What is a core dump?“A core dump consists of the recorded state of theworking memory of a computer program at a specifictime, generally when the program has terminatedabnormally (crashed).[1] In practice, other key pieces ofprogram state are usually dumped at the same time,including the processor registers, which may includethe program counter and stack pointer, memorymanagement information, and other processor andoperating system flags and information. The namecomes from the once-standard core memory technology.Core dumps are often used to diagnose or debug errorsin computer programs.” http://wiki.answers.com/Q/What_is_a_core_dump
    • How can you get one? (…and why would I want one?)You can get a core dump fairly easily by doingsomething programmatically you arent allowed todo.All you need are one of the following conditions: Is the memory youre trying to change yours? Am I expecting an explicit type conversion? Did I do something horribly wrong?You also need the command-line value of “ulimit –c”to not be 0A value greater than 0 will generate a corefile
    • On multi-user systems like the linux or unix systemson campus you are not guaranteed a file isgenerated. ulimit –c is often set to 0.To remove the corefile size limit: ulimit –c unlimited On Ubuntu, even with this set, if you are not root, you may not get a core file. It is easiest to generate it through gdb.You are now ready to generate a core file. That filecan be read by gdb provided you compiled it on thesame machine.to read in an existing file use: gdb program corefile where program is your compiled program and corefile is the file that was dumped. We can get all sorts of information back out.
    • When a program dumps core, the entire imprint ofwhat was happening at that point in programexecution is sent to a file. This includes: recorded memory state processor registers program counter stack pointer memory management information any other flags and information that system includes
    • Identical source program code: linux left, solaris rightGenerated using gcc –s fileName.c
    • Linux vs Solaris exampleNot apples to apples – different machines meansdifferent arch, also different gcc versions.Commands we will use: gdb executableName coreFile Starts gdb with the corefile loaded info locals print info args list backtrace
    • Show Linux example using gcc –g file gdb file gdb commands backtrace, etcShow Solaris example gcc –g file a.out gdb commands backtrace, etc.Show differences in even the machine code.
    • Running process example: Core File Creation gdb has a “generate-core-file” command to create a core file(this example is off a running process): gdb -q – 1597 Generates a core file of the currently running program. This is great for infinite loops Also great for hung programs (due to infinite loops or not)
    • Using a core fileTo use a core file once generated, these slideswill use gdbTo start gdb with a core file, issue the systemspecific command from the shell: gdb eg1 core gdb eg1 -c coreFileGdb will load up the core file, eg1s programlisting, show how the program terminated andpresent a message very much like weve just runthe program under gdb:
    • ...Core was generated by `./eg1.Program terminated with signal 8, Floating pointexception....#0 0x80483ea in wib (no1=8, no2=8) at eg1.c:77 result = no1 / diff;
    • While we see there are differences linux to unixon the details of the corefile generated, once weare using gdb as our interface to that file, wewon’t notice the differences in our basic usage ofthe corefile.Gdb does the symbol parsing and interpretationfor us, making it a very handy tool.The file on its own passed to a system it wasn’tcompiled on won’t do you much good. You won’thave the references to the symbols used in theprogram.Thus, a corefile on its own is interesting, but notas useful as a corefile passed in with theprogram you compiled.
    • Questions?
    • References list: http://www.ibm.com/developerworks/library/l-gdb/ http://prefetch.net/blog/index.php/2006/12/21/generati ng-core-files-from-gdb/ http://docs.oracle.com/cd/E23823_01/html/816- 5174/core-4.html http://stackoverflow.com/questions/17965/generate-a- core-dump-in-linux http://docs.oracle.com/cd/E23823_01/html/816- 5165/gcore-1.html#REFMAN1gcore-1 http://wiki.answers.com/Q/What_is_a_core_dump