Code::Blocks

User forums => Using Code::Blocks => Topic started by: Дмитро on June 22, 2016, 12:41:37 am

Title: Debugging code Help
Post by: Дмитро on June 22, 2016, 12:41:37 am
Good night!
I decided to try establishing a kodeblok.
Nastromyv I couple of breakpoints.
And I ran across a couple of breakpoints.
Do not stop them!
No, do not stop passing by.
The function performed approximately three times or more,
only then stops on that delete [] Ves_masyv [J];
zhovtenkyy drawing a triangle.
How would a breakpoint that good?
I did not know how.
Title: Re: Debugging code Help
Post by: BlueHazzard on June 22, 2016, 01:04:11 am
have you enabled the debugging symbols, and disabled any optimization? If optimization is turned on, it could be that your break point code is optimized out... (check for -O flags in the project build options and turn them off)
Title: Re: Debugging code Help
Post by: Дмитро on June 22, 2016, 01:16:34 am
Thank you, BlueHazzard!
I did not set any flags.
Now I'll check.



There is only one flag, -g, no more
no.
Title: Re: Debugging code Help
Post by: Дмитро on June 22, 2016, 01:43:26 am
Look no screen required.
Especially important is nothing.




(http://www.imageup.ru/img198/thumb/nezupinivs32464108.jpg) (http://www.imageup.ru/img198/2464108/nezupinivs3.bmp.html)


(http://www.imageup.ru/img198/thumb/nezupinivs22464103.jpg) (http://www.imageup.ru/img198/2464103/nezupinivs2.jpg.html)
Title: Re: Debugging code Help
Post by: Дмитро on June 22, 2016, 11:51:36 am
(http://www.imageup.ru/img176/thumb/nezupinivs42464497.jpg) (http://www.imageup.ru/img176/2464497/nezupinivs4.bmp.html)



So what? Maybe I'm on the wrong button, shake, or something wrong done? Or what?



That compiler flags - only one flag is no more at all.
Title: Re: Debugging code Help
Post by: BlueHazzard on June 22, 2016, 02:55:34 pm
Hi, sory i am on my phone, so the answer may be not 100% correct, but you will get the idea.
1) the settings about optimization is under
Project->build options->compiler settings
Make sure you have selected "debug" on the left side.
Make sure you use the debug target for using the debugger:
Select "debug" in the dropdown menu near the build button

2) you put the breakpoint in a decleration line. The compiler may ignore this line, try to place the breakpoint ine line 161 instead...

3) the debugger stops at the delete, because your application crashes there, probably you delete some wrong\incorrect pointer...
I have no idea, why you get a sigtrap at the delete.... If you delete a corupt pointer you get a sig segfault...

Greetings
Title: Re: Debugging code Help
Post by: Дмитро on June 23, 2016, 12:40:25 am
Thank you! So I'm kind of doing so.
It is already late, the second half of the night, or the day after tomorrow I will think carefully.

More. I'm not sure I understand.
Select "debug" in the dropdown menu near the build button


I put a lot of break points in various locations and functions.

Title: Re: Debugging code Help
Post by: BlueHazzard on June 23, 2016, 12:51:38 am
Quote
I put a lot of break points in various locations and functions.
And none worked?
Title: Re: Debugging code Help
Post by: Дмитро on June 23, 2016, 10:29:32 am

    The same. Really nobody worked.

I actually started to ask in the forum, after pyat or six hours tried to do something on their own.
Title: Re: Debugging code Help
Post by: BlueHazzard on June 23, 2016, 11:46:33 pm
strange,

can you please post a full rebuild log (Build->Rebuild) and copy and post it here. Don't use a image, but post the actual "BUILD LOG"

then please start the debugger and post the debug log (the content of the log window from your screenshot) here.

To post this logs please paste it inside code tags (the # symbol in the new post editor)

greetings
Title: Re: Debugging code Help
Post by: Дмитро on June 24, 2016, 05:34:38 pm

Code: [Select]
-------------- Clean: default in Pars1 (compiler: GNU GCC Compiler)---------------

Cleaned "Pars1 - default"

-------------- Build: default in Pars1 (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -g -g -fpermissive  -c "C:\Копия PISDETS-22\NOW\Pars_utf8.cpp" -o .objs\Pars_utf8.o
C:\Копия PISDETS-22\NOW\Pars_utf8.cpp: В функции «void print_symbols(in_iterator, in_iterator, std::ofstream&, char***, int*, spilna_pamyat*)»:
C:\Копия PISDETS-22\NOW\Pars_utf8.cpp:120:55: предупреждение: «nakopychuvach» не имеет аргументов, зависящих от параметра-шаблона, поэтому должна быть доступна декларация «nakopychuvach» [-fpermissive]
  nakopychuvach(Symbol, Ves_masyv, ZastarivPamjatay, Ps);
                                                       ^
C:\Копия PISDETS-22\NOW\Pars_utf8.cpp: В функции «void nakopychuvach(char*, char***, int*, spilna_pamyat*)»:
C:\Копия PISDETS-22\NOW\Pars_utf8.cpp:263:40: предупреждение: некорректное преобразование из «char*» в «char» [-fpermissive]
      dokument[NUMRYADOK][ NUMZNAK ][0] = Symbol;
                                        ^
mingw32-g++.exe  -o Pars1.exe .objs\Pars_utf8.o  -static-libgcc 
Output file is Pars1.exe with size 164,87 KB
Process terminated with status 0 (0 minute(s), 19 second(s))
2 error(s), 0 warning(s) (0 minute(s), 20 second(s))
 



I think it's probably 90%, I make a mistake.
Nevertheless, I can not understand where I am wrong.
I apologize in advance.

Please log here restructuring.


This is what you asked? I understood correctly?


I also attach the debugger.
I do not know, maybe it does not matter.
However, I will do.

Code: [Select]
Building to ensure sources are up-to-date
Selecting target:
default
Adding source dir: C:\Копия PISDETS-22\NOW\
Adding source dir: C:\Копия PISDETS-22\NOW\
Adding file: C:\Копия PISDETS-22\NOW\Pars1.exe
Changing directory to: C:/PISDET~2/NOW/.
Set variable: PATH=.;C:\MinGW\bin;C:\MinGW;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;C:\Program Files\TortoiseSVN\bin;C:\Strawberry_Perl\c\bin;C:\Strawberry_Perl\perl\site\bin;C:\Strawberry_Perl\perl\bin
Starting debugger: C:\MinGW\bin\gdb.exe -nx -fullname  -quiet  -args C:/PISDET~2/NOW/Pars1.exe
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.6.1
Child process PID: 1656
Program received signal SIGTRAP, Trace/breakpoint trap.
In ntdll!DbgBreakPoint () (C:\WINDOWS\system32\ntdll.dll)
#11 0x00401c8c in _fu9___ZSt4cout () at C:\Копия PISDETS-22\NOW\Pars_utf8.cpp:280
C:\Копия PISDETS-22\NOW\Pars_utf8.cpp:280:6111:beg:0x401c8c
At C:\Копия PISDETS-22\NOW\Pars_utf8.cpp:280
Title: Re: Debugging code Help
Post by: oBFusCATed on June 24, 2016, 07:44:47 pm
Don't use paths with spaces, other strange characters, Cyrillic characters and so on. Using such characters is known to fail.

Read this also: http://wiki.codeblocks.org/index.php/Debugging_with_Code::Blocks
Title: Re: Debugging code Help
Post by: Дмитро on June 25, 2016, 06:35:55 pm

Thank you!
Please, please specify how reliable that is going version - debuh version or release version? which of them exactly?

And sure created debug version? What evidence, testimony signs?
What do kodebloke regulation should apply, I usually can get confused and not know it, and probably it is, because I'm only mastering this Wednesday.

How to change version? Maybe it's my inability chi bug associated with the not the version?
Title: Re: Debugging code Help
Post by: Дмитро on June 25, 2016, 09:34:06 pm
Blurted out! It works as it should.
You know, I do not understand what has changed.
I tried to change the way the compiler to use the other ... He returned to the still. Like all the same.
Trinket work!

Building to ensure sources are up-to-date
Selecting target:
default
Adding source dir: C:\S22\NOW\
Adding source dir: C:\S22\NOW\
Adding file: C:\S22\NOW\Pars1.exe
Changing directory to: C:/S22/NOW/.
Set variable: PATH=.;C:\MinGW\bin;C:\MinGW;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;C:\Program Files\TortoiseSVN\bin;C:\Strawberry_Perl\c\bin;C:\Strawberry_Perl\perl\site\bin;C:\Strawberry_Perl\perl\bin
Starting debugger: C:\MinGW\bin\gdb.exe -nx -fullname  -quiet  -args C:/S22/NOW/Pars1.exe
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.6.1
Child process PID: 1636
At C:\S22\NOW\Pars_utf8.cpp:148
Title: Re: Debugging code Help
Post by: Дмитро on June 28, 2016, 11:36:04 pm
Code: [Select]
if(Ves_masyv!=NULL){

 for( int i = 0; i <= NUMRYADOK+1; ++i )
  {
        for( int J = 0; J <= ZastarivPamjatay[NUMRYADOK]+1; ++J )
   {

        delete[] Ves_masyv[ i ][J];

   }


  }

Debugger, itself stops here on this site.

I was not completely satisfied. Debugged program is better, so that it falls at once, and sometimes passing this place for the fortieth time or more. Cycle itself also remove more than the larger.
How to make the program go straight to the collapse of the space? What would stop took place exactly on the line when she fell program own catching collapse.
Title: Re: Debugging code Help
Post by: Дмитро on June 29, 2016, 02:06:44 pm
Again. I did not set a breakpoint. I just want to go through the code. Why debugger stops YOURSELF ??? How to avoid this?
Title: Re: Debugging code Help
Post by: BlueHazzard on June 29, 2016, 11:23:36 pm
What is the cause of the stop? There should pop up a yellow window with something wtitten in it, like SIGTRAP or SIGSEGV, this should also be written in the debugger log...

If the cause is SIGSEGV then your program deletes or accesses an invalid pointer at the point where the debugger stoped
if the cause is SIGTRAP: http://stackoverflow.com/questions/3475262/what-causes-a-sigtrap-in-a-debug-session http://stackoverflow.com/questions/11790321/gdb-debugging-application-termintes-with-sigtrap ecc..

i did not understand your other posts... Does debugging work now? Where the cyrillic letters/ white spaces the problem?

greetings
Title: Re: Debugging code Help
Post by: Дмитро on June 30, 2016, 11:27:37 am
Thank you!!

Yes, it works well in general. I do see it work!

... But some of the problem is .. The disadvantage of causing a large .. Now write glue and screens.


(http://www.imageup.ru/img98/2471030/zupinka1.bmp) (http://www.imageup.ru/img98/2471030/zupinka1.bmp.html)




Before it does, I've seen - a record for an array boundary. Mistakes are the former, I corrected. I quickly saw them and quickly corrected. Debugging is a great help, friendly nice tool!

But now I do not see any errors. The present circumstances.

They have a right good code, properly removed, the code is written correctly!

Stop should not be. No signs, I do not see and do not understand why all of a sudden stops here.
Title: Re: Debugging code Help
Post by: Дмитро on June 30, 2016, 01:40:02 pm
I think it is actually the same!

https://stackoverflow.com/questions/1621059/breakpoints-out-of-nowhere-when-debugging-with-gdb-inside-ntdll
Title: Re: Debugging code Help
Post by: BlueHazzard on June 30, 2016, 02:40:15 pm
you can use this http://stackoverflow.com/a/1691025 in Settings->Debugger->GDB debugger->Default->Debugger initialization commands

greetings
Title: Re: Debugging code Help
Post by: Дмитро on June 30, 2016, 09:59:04 pm
The problem is not solved. I am angry.
I researched the code, writing a text log the address of the new allocation of dynamic memory and delete it.
I opened the program in the debugger debugger ally.
The function is called a large number of times.
Four hours later I explored this strange place, and I was going through a lot in the debuggers, and I was writing additional code to reference a text log.

All is well removed. No problem. The memory is removed well, and there is no problem. Very good.

A program crashes badly. And it falls elsewhere. Some kind of unknown cause problems falls.
And I can not explore the falls. It would be best in a debugger here kodeblok that would adjust well.
Because I can not press F8 30 * 30 = Over 900 times !!!
What to do? How to solve it?

       BlueHazzard :
you can use this http://stackoverflow.com/a/1691025 in Settings->Debugger->GDB debugger->Default->Debugger initialization commands

greetings

----   Thank you! Well it gives us good hope.

What words should I write in this window? What kind of command should I put?


(http://www.imageup.ru/img98/thumb/komand2471598.jpg) (http://www.imageup.ru/img98/2471598/komand.bmp.html)
Title: Re: Debugging code Help
Post by: BlueHazzard on June 30, 2016, 11:19:29 pm
what is posted in the link:
Code: [Select]
handle SIGTRAP nostopthis will prevent that gdb stops at SIGTRAP
Title: Re: Debugging code Help
Post by: papagym on July 01, 2016, 04:51:51 pm
I hate to point this out, but the code::blocks wiki materials is so outdates none if us new CB users can figure out how to use the debugger.  I've read it a halve dozen times and it doesn't make much sense. It shows really old dialog box material in there, that doesn't pertain to or look like CB 13.12 or 16.01 for that matter.


Amntpo... try setting the settting using the FILE MENU ==>Project==>Build Options.  I think they are trying to point this out to you.
Good luck!
Title: Re: Debugging code Help
Post by: BlueHazzard on July 01, 2016, 10:46:58 pm
I hate to point this out, but the code::blocks wiki materials is so outdates none if us new CB users can figure out how to use the debugger.  I've read it a halve dozen times and it doesn't make much sense. It shows really old dialog box material in there, that doesn't pertain to or look like CB 13.12 or 16.01 for that matter.
You can help to improve it. Every help (especially at the wiki) is welcome. I think the forum login is also the wiki login. (what page is outdated, can you please post the link? )

Amntpo... try setting the settting using the FILE MENU ==>Project==>Build Options.  I think they are trying to point this out to you.
Good luck!
NO! The settings i mentioned are for the debugger (Settings-->Debugger-->GDB debugger-->Default-->Debugger initialization commands) !! Build options have nothing to do with the debugger!!!
You can enter the
Code: [Select]
handle SIGTRAP nostopalso in the gdb command line: During debugging select the "Debugger" tab and enter "handle SIGTRAP nostop" in the "Command" field at the bottom and press enter

greetings