{"id":299856,"date":"2020-03-08T15:00:20","date_gmt":"2020-03-08T15:00:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=299856"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=299856","title":{"rendered":"\u041a\u0440\u0430\u0442\u043a\u0438\u0439 \u0433\u0430\u0439\u0434 \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e GDB"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/491534\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sb\/ds\/fi\/sbdsfiwgiqbdpcyynt17wgvjf_s.png\"><\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u0440\u0438\u0451\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 GDB, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e (\u0438 \u043d\u0443\u0436\u043d\u043e) \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043a \u043e\u0442\u043b\u0430\u0434\u043a\u0435 \u0434\u043b\u044f GDB.<\/p>\n<p>  <\/p>\n<p>GDB \u2014 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u044b\u0439 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0430 GNU, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 UNIX-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0438 \u0443\u043c\u0435\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u043c\u043d\u043e\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0421\u0438, C++, Free Pascal, FreeBASIC, Ada, \u0424\u043e\u0440\u0442\u0440\u0430\u043d, Python3, Swift, NASM \u0438 Rust.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h1 id=\"gdb\">GDB<\/h1>\n<p>  <\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e <strong>GDB<\/strong>? \u0412\u0441\u0451 \u043b\u0435\u0433\u043a\u043e, \u043e\u043d \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043d\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 UNIX-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, \u043b\u0451\u0433\u043e\u043a \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u043e\u0432. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043d\u0438\u043c \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043b\u0451\u0433\u043a\u043e\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a VSCode \u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430\u043c \u043a\u043e\u0434\u0430 (<em>\u0412\u043a\u043b\u044e\u0447\u0430\u044f Vim, NeoVim (\u044f\u0441\u043d\u043e\u0435 \u0434\u0435\u043b\u043e), Emacs, Atom \u0438 \u0434\u0430\u043b\u0435\u0435<\/em>)<\/p>\n<p>  <\/p>\n<h2 id=\"podgotovka-faylov\">\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0444\u0430\u0439\u043b\u044b <em>.cpp<\/em> \u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u043d\u0438\u043c \u0432\u0434\u043e\u043b\u044c \u0438 \u043f\u043e\u043f\u0435\u0440\u0451\u043a.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043c \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u0442\u0430\u043a\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e G++ \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u043b\u0430\u0433\u0430 <strong>-g<\/strong> (\u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0430\u0436\u043d\u043e, \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u0444\u043b\u0430\u0433\u0430, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 GDB).<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">g++ -g file_name.cpp -o output_name gdb output_name<\/code><\/pre>\n<p>  <\/p>\n<p>Python-\u0444\u0430\u0439\u043b \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0434\u0435\u0431\u0430\u0436\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">gdb -ex r --args python program_name.py &lt;arguments&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f Java \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c jdb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u0438\u0434\u0451\u0442 \u0432 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u0435 c JDK.<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0451 \u0440\u0443\u0447\u043a\u0430\u043c\u0438, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u0439\u0442 <a href=\"https:\/\/www.onlinegdb.com\/\" rel=\"nofollow\">OnlineGDB<\/a>, \u0442\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0438 \u043d\u0430\u0436\u0430\u0442\u044c debug, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u043d\u0438\u0437\u0443 \u043e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u044c, \u0433\u0434\u0435 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n<p>  <\/p>\n<h2 id=\"ispolzovanie-gdb\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 GDB<\/h2>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u0437\u0430\u0448\u043b\u0438 \u0432 GDB \u043d\u0430\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later &lt;http:\/\/gnu.org\/licenses\/gpl.html&gt; This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.  Type &quot;show copying&quot; and &quot;show warranty&quot; for details. This GDB was configured as &quot;x86_64-linux-gnu&quot;. Type &quot;show configuration&quot; for configuration details. For bug reporting instructions, please see: &lt;http:\/\/www.gnu.org\/software\/gdb\/bugs\/&gt;. Find the GDB manual and other documentation resources online at: &lt;http:\/\/www.gnu.org\/software\/gdb\/documentation\/&gt;.  For help, type &quot;help&quot;. Type &quot;apropos word&quot; to search for commands related to &quot;word&quot;... Reading symbols from 3_Hero's_Inventory.cpp...done.<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0441\u044f \u0444\u0430\u0439\u043b.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0433\u0434\u0435 \u0432 \u043d\u0430\u0448\u0435\u043c \u0444\u0430\u0439\u043b\u0435 <strong>\u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f<\/strong> (<em>\u0441\u0442\u0440\u043e\u043a\u0430, \u043e\u0442\u043a\u0443\u0434\u0430 \u043d\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443<\/em>), \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 cpp \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <code>main()<\/code>. \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 c \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>list<\/code> \u0438 \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c, \u043a\u0430\u043a\u0430\u044f \u043e\u043d\u0430 \u0438\u0434\u0451\u0442 \u043f\u043e \u0441\u0447\u0451\u0442\u0443 \u0441 \u0431\u0443\u043a\u0432\u043e\u0439 <code>b<\/code> (<em>\u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>b main<\/code> \u0442\u043e\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/em>):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) list 1   #include &lt;iostream&gt; 2   #include &lt;string&gt; 3    4   using namespace std; 5    6   int main(int argc, char *argv[]) 7   { 8       \/\/ Hero's Inventory - \u0441\u043a\u0440\u0438\u043f\u0442, \u0433\u0434\u0435 \u043c\u044b \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u043d\u0432\u0435\u043d\u0442\u0430\u0440\u044c \u0438\u0433\u0440\u043e\u043a\u0430 9    10      const int MAX_ITEMS = 10; \/\/ \u0417\u0430\u0434\u0430\u0451\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443, \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043f\u043e \u0438\u043d\u0432\u0435\u043d\u0442\u0430\u0440\u044e \u0438\u0433\u0440\u043e\u043a\u0430<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) b 6 Breakpoint 1 at 0xcb5: file .\/3_Hero's_Inventory.cpp, line 6.<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u043c\u0430\u043d\u0434\u044b <code>r<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) r Starting program: \/home\/username77177\/gitprojects\/learning\/cpp\/build_folder\/3_Hero's_Inventory.cpp   Breakpoint 1, main (argc=1, argv=0x7fffffffdd18) at .\/3_Hero's_Inventory.cpp:7 7   {<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u043e\u0439 \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u0441\u0442\u0440\u043e\u043a\u0435, \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>f<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) f #0  main (argc=1, argv=0x7fffffffdd18) at .\/3_Hero's_Inventory.cpp:14 14      items[itemnum++] = &quot;Sword&quot;;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0448\u0430\u0433, \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u044c <code>n<\/code> (\u043e\u0442 \u0441\u043b\u043e\u0432\u0430 next):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) n 10      const int MAX_ITEMS = 10; \/\/ \u0417\u0430\u0434\u0430\u0451\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443, \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043f\u043e \u0438\u043d\u0432\u0435\u043d\u0442\u0430\u0440\u044e \u0438\u0433\u0440\u043e\u043a\u0430<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c GDB \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u0443\u0441\u0442\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 (\u0438\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438) \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435.<br \/>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 <code>n<\/code> \u043d\u0430\u0448 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a <strong>\u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043d\u0435 \u0437\u0430\u0445\u043e\u0434\u044f \u0432 \u043d\u0435\u0451<\/strong>, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0439\u0442\u0438 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c &quot;\u0448\u0430\u0433 \u0432\u043d\u0443\u0442\u0440\u044c&quot; (step-in) \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043b\u0430\u0432\u0438\u0448\u0430 <code>s<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) s 11      string items[MAX_ITEMS]; \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a c 10 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438<\/code><\/pre>\n<p>  <\/p>\n<p>(<em>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u0448\u0430\u0433 step-in \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0441 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438, \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438 \u0438 \u0446\u0438\u043a\u043b\u0430\u043c\u0438<\/em>)<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 (\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435) \u0441\u0435\u0439\u0447\u0430\u0441 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u043c\u043c\u0430\u043d\u0434\u0443 <code>info locals<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) info locals MAX_ITEMS = 10 items = {&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;} itemnum = 0 game = 247<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>print \u0438\u043c\u044f_\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) print MAX_ITEMS  $1 = 10<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>set<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) set x = 77177 (gdb) print x $1 = 77177<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u0430\u043a\u0436\u0435 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>watch<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">watch x<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0445 (<code>info registers<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) info registers  rax            0x7fffffffdc00   140737488346112 rbx            0xffffffffffffffff   -1 rcx            0xa0 160 rdx            0x7fffffffdd28   140737488346408 rsi            0x7fffffffdd18   140737488346392 rdi            0x7fffffffdbf0   140737488346096 rbp            0x7fffffffdc30   0x7fffffffdc30 rsp            0x7fffffffdab0   0x7fffffffdab0 r8             0x7ffff782fd80   140737345944960 r9             0x0  0 r10            0x6  6 r11            0x7ffff7b77020   140737349382176 r12            0x7fffffffdc10   140737488346128 r13            0x7fffffffdd10   140737488346384 r14            0x0  0 r15            0x0  0 rip            0x555555554cfe   0x555555554cfe &lt;main(int, char**)+100&gt; eflags         0x286    [ PF SF IF ] cs             0x33 51 ss             0x2b 43 ds             0x0  0 es             0x0  0 fs             0x0  0 gs             0x0  0<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a\u0438\u0435 \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0435\u0441\u0442\u044c breakpoints (\u0442\u043e\u0447\u043a\u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430) \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>info breakpoints<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) info breakpoints  Num     Type           Disp Enb Address            What 1       breakpoint     keep y   0x0000555555554cb5 in main(int, char**)                                                     at .\/3_Hero's_Inventory.cpp:6     breakpoint already hit 1 time 2       breakpoint     keep y   0x0000555555554cfe in main(int, char**)                                                     at .\/3_Hero's_Inventory.cpp:14<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0442\u043e\u0447\u043a\u0443 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430 <code>del breakpoint_num<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) info breakpoints  Num     Type           Disp Enb Address            What 1       breakpoint     keep y   0x0000555555554cb5 in main(int, char**)                                                     at .\/3_Hero's_Inventory.cpp:6     breakpoint already hit 1 time 2       breakpoint     keep y   0x0000555555554cfe in main(int, char**)                                                     at .\/3_Hero's_Inventory.cpp:14  (gdb) del 1  (gdb) info breakpoints  Num     Type           Disp Enb Address            What 2       breakpoint     keep y   0x0000555555554cfe in main(int, char**)                                                     at .\/3_Hero's_Inventory.cpp:14 <\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u044b\u0433\u043d\u0443\u0442\u044c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u044c <code>c<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) r Starting program: \/home\/username77177\/gitprojects\/learning\/cpp\/build_folder\/3_Hero's_Inventory.cpp   Breakpoint 3, main (argc=1, argv=0x7fffffffdd18) at .\/3_Hero's_Inventory.cpp:7 7   { (gdb) c Continuing.  Breakpoint 2, main (argc=1, argv=0x7fffffffdd18) at .\/3_Hero's_Inventory.cpp:14 14      items[itemnum++] = &quot;Sword&quot;;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b (\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>call<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) call MyFunction()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0430 (\u0444\u0443\u043d\u043a\u0446\u0438\u044f) \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>finish<\/code> \u0438\u043b\u0438 <code>fin<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) fin<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u0443\u0442\u043e\u0447\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>finish<\/code> \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>kill<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) kill Kill the program being debugged? (y or n) y<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>help<\/code> \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u0440\u0430\u0442\u043a\u0443\u044e \u0441\u043f\u0440\u0430\u0432\u043a\u0443, \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u043e\u043c<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">(gdb) help List of classes of commands:  aliases -- Aliases of other commands breakpoints -- Making program stop at certain points data -- Examining data files -- Specifying and examining files internals -- Maintenance commands obscure -- Obscure features running -- Running the program stack -- Examining the stack status -- Status inquiries support -- Support facilities tracepoints -- Tracing of program execution without stopping the program user-defined -- User-defined commands  Type &quot;help&quot; followed by a class name for a list of commands in that class. Type &quot;help all&quot; for the list of all commands. Type &quot;help&quot; followed by command name for full documentation. Type &quot;apropos word&quot; to search for commands related to &quot;word&quot;. Command name abbreviations are allowed if unambiguous.<\/code><\/pre>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/491534\/\"> https:\/\/habr.com\/ru\/post\/491534\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/491534\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sb\/ds\/fi\/sbdsfiwgiqbdpcyynt17wgvjf_s.png\"><\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u0440\u0438\u0451\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 GDB, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e (\u0438 \u043d\u0443\u0436\u043d\u043e) \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043a \u043e\u0442\u043b\u0430\u0434\u043a\u0435 \u0434\u043b\u044f GDB.<\/p>\n<p>  <\/p>\n<p>GDB \u2014 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u044b\u0439 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0430 GNU, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 UNIX-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0438 \u0443\u043c\u0435\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u043c\u043d\u043e\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0421\u0438, C++, Free Pascal, FreeBASIC, Ada, \u0424\u043e\u0440\u0442\u0440\u0430\u043d, Python3, Swift, NASM \u0438 Rust.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-299856","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=299856"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299856\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}