🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.programming
5 messages
5 total messages Started by RM Wed, 15 Apr 2020 17:53
problem z if przy debugowaniu w VSCode
#216898
Author: RM
Date: Wed, 15 Apr 2020 17:53
14 lines
1237 bytes
Mam problemik przy debugowaniu w VSCode pod Linuxem.
Mam taki kod w C++:

if (m + 1 < matches2.size() - 1) {
   next_start = strstr(next.c_str(), matches2.str(m + 1).c_str()) - 
next.c_str();
} else {
   next_start = next.length();
}

i mimo że m = 1 oraz matches2.size() == 5 to debuger wchodzi mi do 
gałęzi else. (Zmienna m jest typu unsigned int a zmienna matches2 typu 
smatch.)
Jak to możliwe?
Re: problem z if przy debugowaniu w VSCode
#216899
Author: RM
Date: Wed, 15 Apr 2020 18:32
1 lines
963 bytes
Dodam że używam debugera: gdb, kompilatora: gcc, standardu języka: C++17.
Re: problem z if przy debugowaniu w VSCode
#216900
Author: RM
Date: Thu, 16 Apr 2020 04:36
7 lines
1113 bytes
Mam jeszcze jedno pytanie: dlaczego pod debugerem VSCode dla:
old_line=="function str_split($string, $len = 1) {"
oraz:
next=="$string, $len = 1) {"
mam:
old_line.find(next)
Error: Index was outside the bounds of the array.
Re: problem z if przy debugowaniu w VSCode
#216901
Author: RM
Date: Thu, 16 Apr 2020 13:50
20 lines
1601 bytes
W dniu 15.04.2020 o 19:53, RM pisze:
> Mam problemik przy debugowaniu w VSCode pod Linuxem.
> Mam taki kod w C++:
> 
> if (m + 1 < matches2.size() - 1) {
>    next_start = strstr(next.c_str(), matches2.str(m + 1).c_str()) - 
> next.c_str();
> } else {
>    next_start = next.length();
> }
> 
> i mimo że m = 1 oraz matches2.size() == 5 to debuger wchodzi mi do 
> gałęzi else. (Zmienna m jest typu unsigned int a zmienna matches2 typu 
> smatch.)
> Jak to możliwe?

Chyba już wiem o co chodziło. W Debug Console znalazłem:
Warning: Source file 
'/home/robert/dirtyphp/dirtyphp_cpp/src/obfuscator.cpp' is newer than 
module file '/home/robert/dirtyphp/dirtyphp_cpp/build/apps/dirtyphp'.
Re: problem z if przy debugowaniu w VSCode
#216902
Author: Queequeg
Date: Fri, 15 May 2020 08:16
35 lines
1781 bytes
RM <robert_magdziarz@wp.pl> wrote:

> i mimo że m = 1 oraz matches2.size() == 5 to debuger wchodzi mi do 
> gałęzi else. (Zmienna m jest typu unsigned int a zmienna matches2 typu 
> smatch.)
> Jak to możliwe?

W gdb jest dobrze. Sprawdź z takim programem.

(gdb) l
1       #include <stdio.h>
2
3       int main(void)
4       {
5               int m = 1, ms = 5;
6               if (m + 1 < ms - 1)
7                       printf("tak\n");
8               else
9                       printf("nie\n");
10              return 0;
(gdb) b 5
Breakpoint 1 at 0x10414: file a.c, line 5.
(gdb) r
Starting program: /tmp/a

Breakpoint 1, main () at a.c:5
5               int m = 1, ms = 5;
(gdb) s
6               if (m + 1 < ms - 1)
(gdb) s
7                       printf("tak\n");
(gdb)

-- 
https://www.youtube.com/watch?v=9lSzL1DqQn0
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads