Spyke

Posts

My Last Resort - I Need Help Debugging my Program

I can't figure out what is going on in my program, I'm having a hard time wrapping my mind around what steps its taking to get to the wrong result.

I have this function which should make my parser ignore C-style comments, ie /* */. When I type /* * */ or any number of * in the comment my program is detecting the * characters inside the comment itself, and when it detects a * it also detects the last /:

	// Handle C-style comments
	private void HandleComment() {
		// Consume until closing characters, multi-line comments are supported
		while (Peek() != '*' && PeekAhead() != '/' && !IsAtEnd()) {
			if (Peek() == '\n') line++;
			Advance();
		}

		Advance();
		Advance();
	}

I figured I would need to Advance() twice in order to consume both the characters that denote the end of the comment.

Peek(), PeekAhead(), Advance() and IsAtEnd() are functions from the book, Crafting Interpreters, here they are:

	// Peek at the next char
	private char Peek() {
		if (IsAtEnd()) return '\0';
		return source[current];
	}

	// Peek after next char
	private char PeekAhead() {
		if (current + 1 >= source.Length) return '\0';
		return source[current+1];
	}

	private char Advance() {
		return source[current++];
	}

	private bool IsAtEnd() {
		return current >= source.Length;
	}

The source variable is just a string that contains the text contents of a file or the input from Console.ReadLine().

I based the comment logic on the string logic here:

	// Handle string lexemes
	private void HandleString() {
		// Consume until closing quote, multi-line strings are supported
		while (Peek() != '"' && !IsAtEnd()) {
			if (Peek() == '\n') line++;
			Advance();
		}

		// Handle unterminated strings
		if (IsAtEnd()) {
			DotLox.Error(line, "Unterminated string.");
			return;
		}

		// Consume
		Advance();

		// Tokenize string and store value without quotes
		string value = source[(start+1)..(current-1)];
		AddToken(TokenType.STRING, value);
	}

I almost forgot to share this crucial bit of logic here:

	private void ScanToken() {
		char c = Advance();

		// Match characters to tokens
		switch(c) {

			// Division and comments
			case '/':
				if (Match('/')) {
					// Consume comment but don't turn it into a token
					while (Peek() != '\n' && !IsAtEnd()) Advance();
				} else if (Match('*')) {
					// Handle C-style comments
					HandleComment();
				} else {
					// Turn lone slash into a token
					AddToken(TokenType.SLASH);
				}
				break;
                }
       }
View original on reddthat.com

How to Debug a C# program with LLDB?

I found few resources online which may have lead me astray, as I can't get even basic functionality out of LLDB.

I used the dotnet-sos tool to supposedly automatically load SOS into LLDB and I attached LLDB to my program's process, but I am getting errors when trying to use any command:

error: 'bpmd' is not a valid command.
error: 'clrstack' is not a valid command.

Its behaving as if SOS isn't installed, I think? I really don't know what is going on, searching for these errors gives me nothing which is insane, usually there would be GitHub issues or Stack Overflow posts. I think I'm about to never touch C# ever again.

View original on reddthat.com

Is it possible to debug a program that requires input from the terminal in VSCode/VSCodium?

Though I primarily use vim, I got VSCodium so I could use it as a debugger since its much easier to set up. I am having alot of trouble getting any use out of it though, when I run the program the IDE gives me errors if I type in the debug console, and closes the terminal if I type in the integrated terminal. I've changed the config to allow integrated terminal, but nothing has changed.

Can anyone help me figure this out, or recommend an alternative tool for debugging a C# program?

Edit: I finally found my answer: https://discuss.cachyos.org/t/debugging-c-console-apps-on-linux-with-vs-codium-readline-input-not-working/16493

Unfortunately there is no FOSS way to debug a C# application in VSCodium. Might have to see what this lldb tool is.

View original on reddthat.com

Detect unused imports in Kotlin without IntelliJ?

Is it even possible? It seems every third-party tool that did it is abandoning the feature and I can't get the deprecated but still present feature to work in Detekt or ktlint. I didn't realise the biggest challenge with Kotlin would be detecting unused import statements so I can easily remove them.

Edit: Thanks for the help everyone, but I could not get anything working so I eventually just did it manually with a little help from the android linter.

View original on reddthat.com

Can't get DNS to work on web server

I'm trying to self host my portfolio on an old laptop running Ubuntu server. I've successfully set up docker and nginx. I got a DNS subdomain from freedns.afraid.org.

The IP connected to the DNS matches my server's public IP address.

I can connect with https://mypublicip/ from outside the network, but it shows as an insecure connection and the https has lines going through it in the browser.

Any attempts to connect to the website via DNS have failed, and trying to connect via IP on port 80 fails as well. I really have no clue what is going on, let me know if you need more information, or if this is the wrong place to ask for help with this sort of thing.

Edit: Whatever problem I had before, it seems its been fixed. However my subdomain is being blocked by ISPs. Thank you for the help everyone, I'll probably have to do cloudflare tunneling instead of fully self-hosting it.

View original on reddthat.com
paradoxgames·Paradox Gamesbydr_robotBones

Whats up with .ck3 files?

Whats the deal with this non-standard file type? Has Paradox ever talked about why they created it? Does anyone know when they made this change to the file system?

Edit: I've been trying to save my edited gamestate by figuring out how to recompress it into a .ck3 file. I don't really know how to replicate the header. Its really a shame I didn't back up the original save. The file starts with SAV and then a unique set of metadata bytes and then the plaintext stuff which, it turns out, is for the main menu and the icon next to the save name, and then it has the rest of the save data compressed with the PK header, which means its in the .zip format. I can replicate all this but the save doesn't properly load due to the incorrect metadata in the header I believe.

View original on reddthat.com

You reached the end