Об отладке программ МО ВВС ИВМ и МГ СО РАН Городничев Максим Александрович.

Презентация:



Advertisements
Похожие презентации
© 2005 Cisco Systems, Inc. All rights reserved.INTRO v Module Summary The Cisco Discovery Protocol is an information-gathering tool used by network.
Advertisements

Copyright CCNA 2 Chapter 12 Configuring a Router By Your Name.
BUSINESS LETTER TRUE OR FALSE TEST. Are the following statements True or False? TRUE FALSE.
Citizens of Russia have the right for education which is guaranteed by the Constitution. The public educational system in our country incorporates pre-
1/30 Chapter 8: Dynamic Binding And Abstract classes.
a) free treatment only in hospitals b) private treatment c) free treatment in hospitals and outside.
Object-Oriented Programming Ramzi Saifan Program Control Slides adapted from Steven Roehrig.
Business Letter Basics QUESTIONS. October 18, October 2002.
Выполнил Обучающийся 11 класса Харламов Кирилл. In a welfare state, medical insurance is organized by the Government and is compulsory.
Linux Daemons. Agenda What is a daemon What is a daemon What Is It Going To Do? What Is It Going To Do? How much interaction How much interaction Basic.
© 2006 Avaya Inc. All rights reserved. System alarms.
My room There is a window in my room. ` My room There is a bed near the wall.
© 2006 Cisco Systems, Inc. All rights reserved. HIPS v Using CSA Analysis.
WHAT IS THE SCHOOL?. ? WHAT IS THE MAIN AIM OF OUR LESSON.
© 2006 Cisco Systems, Inc. All rights reserved. MPLS v MPLS VPN Implementation Configuring an MP-BGP Session Between PE Routers.
Jesus Heals a Centurions Servant Featuring the Art of Henry Martin.
Multiples Michael Marchenko. Definition In mathematics, a multiple is the product of any quantity and an integer. in other words, for the quantities a.
THE SECRET OF SUCCESS. Tim Smit and other creators of the Eden Project see the site as much more than a collection of plants.
How to write a story First you have to….. Decide who the characters are. Who is going to be in the story? What sort of characters are they?
Using Dreamweaver MX Slide 1 Window menu Manage Sites… Window menu Manage Sites… 2 2 Open Dreamweaver 1 1 Set up a website folder (1). Click New…
Транксрипт:

Об отладке программ МО ВВС ИВМ и МГ СО РАН Городничев Максим Александрович

Отладочный вывод Буферизованный вывод printf(Программа пришла сюда\n); std::cout

Отладочный вывод Очистка буфера: Cprintf(Text\n); fflush(stdout); C++std::cout

Отладка в gdb. Пример ошибочной программы. #include int f() { int* p = 0; *p = 100; return *p; } void g() { printf("%d", f()); } int main() { g(); } tests]$./a.out Segmentation fault

Отладка в gdb. Компиляция. tests]$ gcc –g3 segfault.c

Отладка в gdb. Запуск программы в отладчике. tests]$ gdb./a.out GNU gdb 6.6 Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-suse-linux"... Using host libthread_db library "/lib/libthread_db.so.1". (gdb) run

Отладка программы в gdb. Анализ ошибки Starting program: /home/maxim/work/tests/a.out Program received signal SIGSEGV, Segmentation fault. 0x in f () at segfault.c:5 5 *p = 100; (gdb) backtrace #0 0x in f () at segfault.c:5 #1 0x c in g () at segfault.c:11 #2 0x080483a4 in main () at segfault.c:16 (gdb) print p $1 = (int *) 0x0 (gdb) quit The program is running. Exit anyway? (y or n) y

Отладка в gdb. Пошаговое выполнение. (gdb) break g Breakpoint 1 at 0x : file segfault.c, line 11. (gdb) run Starting program: /home/maxim/work/tests/a.out warning:.dynamic section for "/lib/libc.so.6" is not at the expected address warning: difference appears to be caused by prelink, adjusting expectations Breakpoint 1, g () at segfault.c:11 11 printf("%d", f()); (gdb) next Program received signal SIGSEGV, Segmentation fault. 0x in f () at segfault.c:5 5 *p = 100;

Отладка в gdb. Пошаговое выполнение. (gdb) step f () at segfault.c:4 4 int* p = 0; (gdb) list 1 #include 2 int f() 3 { 4 int* p = 0; 5 *p = 100; 6 return *p; 7 } 8 9 void g() 10{ (gdb) continue

Вопросы?