mirror of
https://gitlab.com/skmp/dca3-game.git
synced 2025-01-31 13:01:43 +01:00
Git, Build and CI ids, show them on crash screens; stash a copy of the source in the cdi on repack
This commit is contained in:
parent
5a7dd57720
commit
9a91660f50
2
.gitignore
vendored
2
.gitignore
vendored
@ -387,4 +387,6 @@ dreamcast/aud2adpcm*
|
||||
dreamcast/repack-data
|
||||
dreamcast/output.map
|
||||
dreamcast/dca3.ds.iso
|
||||
dreamcast/git-version.h
|
||||
dreamcast/git-version.tmp
|
||||
.DS_Store
|
||||
|
@ -6,6 +6,8 @@
|
||||
# Put the filename of the output binary here
|
||||
PROJECT_NAME = dca3
|
||||
TARGET ?= dca3.elf
|
||||
GIT_VERSION := $(shell git describe --always --tags --long --dirty 2>/dev/null || echo "NO_GIT")
|
||||
CI_JOB_ID ?= NO_CI
|
||||
|
||||
HAVE_CDI4DC := $(shell which cdi4dc > /dev/null 2>&1 && echo "yes" || echo "no")
|
||||
IS_MAC := $(shell uname -s | grep -i "darwin" > /dev/null && echo "yes" || echo "no")
|
||||
@ -100,6 +102,25 @@ OBJS_NO_FAST_MATH = \
|
||||
KOS_CPPFLAGS += -fbuiltin -ffast-math -ffp-contract=fast \
|
||||
-mfsrra -mfsca
|
||||
|
||||
git-version.tmp:
|
||||
@echo "Generating git-version.tmp with GIT_VERSION = \"$(GIT_VERSION)\""
|
||||
@echo "#pragma once" > git-version.tmp
|
||||
@echo "#ifndef VERSION_H" >> git-version.tmp
|
||||
@echo "#define VERSION_H" >> git-version.tmp
|
||||
@echo "#define GIT_VERSION \"$(GIT_VERSION)\"" >> git-version.tmp
|
||||
@echo "#define CI_JOB_ID \"$(CI_JOB_ID)\"" >> git-version.tmp
|
||||
@echo "#endif // VERSION_H" >> git-version.tmp
|
||||
|
||||
git-version.h: git-version.tmp
|
||||
@if [ ! -f git-version.h ] || ! cmp -s git-version.tmp git-version.h; then \
|
||||
echo "Updating git-version.h"; \
|
||||
cp git-version.tmp git-version.h; \
|
||||
else \
|
||||
echo "git-version.h is up to date. No change."; \
|
||||
fi
|
||||
|
||||
../src/skel/dc/dc.cpp: git-version.h
|
||||
|
||||
# The rm-elf step is to remove the target before building, to force the
|
||||
# re-creation of the rom disk.
|
||||
all: $(TARGET)
|
||||
@ -157,7 +178,7 @@ $(OBJS_NO_FAST_MATH): %.o: %.cpp
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
kos-c++ -o $(TARGET) $(OBJS) -Wl,--gc-sections -Wl,--as-needed -Wl,-Map,output.map \
|
||||
-flto=auto $(if $(WITH_IDE),-lkosfat) $(if $(WITH_SD),-lkosfat)
|
||||
-flto=auto $(if $(WITH_IDE),-lkosfat) $(if $(WITH_SD),-lkosfat) -Wl,--build-id=sha1
|
||||
@echo && echo && echo "*** Build Completed Successfully ***" && echo && echo
|
||||
|
||||
run: $(TARGET)
|
||||
@ -173,7 +194,7 @@ $(REPACK_GTA_DIR)/GTA3SF8.b: GTA3SF8.b
|
||||
kos-objcopy -R .stack -O binary $(TARGET) $(TARGET).bin
|
||||
$(KOS_BASE)/utils/scramble/scramble $(TARGET).bin 1ST_READ.BIN
|
||||
|
||||
.PHONY: pvrtex
|
||||
.PHONY: pvrtex git-version.tmp
|
||||
|
||||
pvrtex:
|
||||
$(MAKE) -C ./pvrtex
|
||||
@ -355,6 +376,7 @@ STREAM_WAV_DECODED = $(addprefix $(REPACK_STREAM_DECODED_DIR)/, $(STREAM_WAV))
|
||||
|
||||
$(REPACK_DIR)/repacked: $(REPACK_GTA_DIR)/models/gta3.img $(REPACK_GTA_DIR)/models/gta3.dir $(LOOSE_FILES_DC) $(STREAM_ADPCM_DC) $(SFX_DC_RAW) $(SFX_DC_DSC)
|
||||
mkdir -p $(@D)
|
||||
@git archive --format zip --output "$(REPACK_GTA_DIR)/DCA3-$(GIT_VERSION).zip" HEAD
|
||||
@touch $@
|
||||
@echo && echo && echo "*** Repack Completed Successfully ***" && echo && echo
|
||||
|
||||
|
@ -1196,8 +1196,8 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con
|
||||
stacktrace();
|
||||
dbgio_dev_select("fb");
|
||||
sleep(1);
|
||||
dbgio_printf("RE3 ASSERT FAILED\n\tFile: %s\n\tLine: %d\n\tFunction: %s\n\tExpression: %s\n",filename,lineno,func,expr);
|
||||
dbgio_printf("POSIX error (may not be relevant): %s\n", strerror(errno));
|
||||
dbglog(DBG_CRITICAL, "RE3 ASSERT FAILED\n\tFile: %s\n\tLine: %d\n\tFunction: %s\n\tExpression: %s\n",filename,lineno,func,expr);
|
||||
dbglog(DBG_CRITICAL, "POSIX error (may not be relevant): %s\n", strerror(errno));
|
||||
stacktrace();
|
||||
dbgio_flush();
|
||||
abort();
|
||||
|
@ -62,6 +62,8 @@ long _dwOperatingSystemVersion;
|
||||
#include "AnimViewer.h"
|
||||
#include "Font.h"
|
||||
#include "MemoryMgr.h"
|
||||
#include "../../dreamcast/git-version.h"
|
||||
#include "dc.h"
|
||||
|
||||
// This is defined on project-level, via premake5 or cmake
|
||||
#ifdef GET_KEYBOARD_INPUT_FROM_X11
|
||||
@ -1977,13 +1979,14 @@ __attribute__((noinline)) void stacktrace() {
|
||||
: "+r" (sp), "+r" (pr)
|
||||
:
|
||||
: );
|
||||
dbgio_printf("Stack trace: %p ", (void*)pr);
|
||||
dbglog(DBG_CRITICAL, "DCA3: %s\n", getExecutableTag());
|
||||
dbglog(DBG_CRITICAL, "Stack trace: %p ", (void*)pr);
|
||||
int found = 0;
|
||||
if(!(sp & 3) && sp > 0x8c000000 && sp < _arch_mem_top) {
|
||||
char** sp_ptr = (char**)sp;
|
||||
for (int so = 0; so < 16384; so++) {
|
||||
if (uintptr_t(&sp_ptr[so]) >= _arch_mem_top) {
|
||||
dbgio_printf("(@@%p) ", &sp_ptr[so]);
|
||||
dbglog(DBG_CRITICAL, "(@@%p) ", &sp_ptr[so]);
|
||||
break;
|
||||
}
|
||||
if (sp_ptr[so] > (char*)0x8c000000 && sp_ptr[so] < etext) {
|
||||
@ -1999,9 +2002,9 @@ __attribute__((noinline)) void stacktrace() {
|
||||
uint16_t instr = instrp[-2];
|
||||
// BSR or BSRF or JSR @Rn ?
|
||||
if (((instr & 0xf000) == 0xB000) || ((instr & 0xf0ff) == 0x0003) || ((instr & 0xf0ff) == 0x400B)) {
|
||||
dbgio_printf("%p ", instrp);
|
||||
dbglog(DBG_CRITICAL, "%p ", instrp);
|
||||
if (found++ > 24) {
|
||||
dbgio_printf("(@%p) ", &sp_ptr[so]);
|
||||
dbglog(DBG_CRITICAL, "(@%p) ", &sp_ptr[so]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@ -2011,15 +2014,83 @@ __attribute__((noinline)) void stacktrace() {
|
||||
// dbglog(DBG_CRITICAL, "Stack trace: %p (@%p): out of range\n", (void*)sp_ptr[so], &sp_ptr[so]);
|
||||
}
|
||||
}
|
||||
dbgio_printf("end\n");
|
||||
dbglog(DBG_CRITICAL, "end\n");
|
||||
} else {
|
||||
dbgio_printf("(@%p)\n", (void*)sp);
|
||||
dbglog(DBG_CRITICAL, "(@%p)\n", (void*)sp);
|
||||
}
|
||||
}
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
extern "C" {
|
||||
extern const unsigned char _build_id_start[];
|
||||
extern const unsigned char _build_id_end[];
|
||||
}
|
||||
|
||||
std::string getBuildId()
|
||||
{
|
||||
// Pointer to the start of the .note.gnu.build-id section
|
||||
const unsigned char *p = _build_id_start;
|
||||
|
||||
// Parse the ELF note header
|
||||
struct NoteHeader {
|
||||
uint32_t n_namesz;
|
||||
uint32_t n_descsz;
|
||||
uint32_t n_type;
|
||||
};
|
||||
|
||||
// Read header fields (be careful with endianness if needed)
|
||||
const auto* note = reinterpret_cast<const NoteHeader*>(p);
|
||||
|
||||
// Move p beyond the note header
|
||||
p += sizeof(NoteHeader);
|
||||
|
||||
// Skip the "name" field + alignment (e.g. "GNU\0")
|
||||
// name is note->n_namesz bytes, then align up to 4 bytes
|
||||
auto nameBytes = (note->n_namesz + 3u) & ~3u;
|
||||
p += nameBytes;
|
||||
|
||||
// Now p should point to the actual build-id bytes, which are note->n_descsz in length.
|
||||
const unsigned char* buildId = p;
|
||||
auto buildIdSize = note->n_descsz;
|
||||
|
||||
// Convert it to a hex string
|
||||
std::ostringstream oss;
|
||||
oss << std::hex << std::setfill('0');
|
||||
for (uint32_t i = 0; i < buildIdSize; i++) {
|
||||
oss << std::setw(2) << static_cast<unsigned>(buildId[i]);
|
||||
}
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
#else
|
||||
std::string getBuildId() {
|
||||
return "non-dreamcast-build";
|
||||
}
|
||||
#endif
|
||||
|
||||
const char* getSourceId() {
|
||||
return GIT_VERSION;
|
||||
}
|
||||
|
||||
const char* getCIJobId() {
|
||||
return CI_JOB_ID;
|
||||
}
|
||||
|
||||
static std::string executableTag = getBuildId() + ":" + getSourceId() + ":" + getCIJobId();
|
||||
|
||||
const char* getExecutableTag() {
|
||||
return executableTag.c_str();
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
dbglog(DBG_CRITICAL, "DCA3: %s\n", getExecutableTag());
|
||||
#if !defined(DC_SIM)
|
||||
std::set_terminate([]() {
|
||||
fflush(stdout);
|
||||
@ -2029,8 +2100,8 @@ main(int argc, char *argv[])
|
||||
stacktrace();
|
||||
dbgio_dev_select("fb");
|
||||
sleep(1);
|
||||
dbgio_printf("std::terminate() called\n");
|
||||
dbgio_printf("POSIX error (may not be relevant): %s\n", strerror(errno));
|
||||
dbglog(DBG_CRITICAL, "std::terminate() called\n");
|
||||
dbglog(DBG_CRITICAL, "POSIX error (may not be relevant): %s\n", strerror(errno));
|
||||
stacktrace();
|
||||
dbgio_flush();
|
||||
|
||||
|
7
src/skel/dc/dc.h
Normal file
7
src/skel/dc/dc.h
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
std::string getBuildId();
|
||||
const char* getSourceId();
|
||||
const char* getCIJobId();
|
||||
const char* getExecutableTag();
|
2
vendor/dca3-kos
vendored
2
vendor/dca3-kos
vendored
@ -1 +1 @@
|
||||
Subproject commit 0b2de9228be7debb7f5d37ecf6341a9a78bbf3af
|
||||
Subproject commit 397acb31b1bdd702344081caccd0865fec21332b
|
Loading…
x
Reference in New Issue
Block a user