Even more and better debugging stuff.

This commit is contained in:
Moritz Bunkus 2003-05-26 21:49:11 +00:00
parent 690dd7de77
commit f936c2176a
6 changed files with 47 additions and 49 deletions

View File

@ -13,7 +13,7 @@
/*!
\file
\version \$Id: cluster_helper.cpp,v 1.19 2003/05/21 22:17:33 mosu Exp $
\version \$Id: cluster_helper.cpp,v 1.20 2003/05/26 21:49:11 mosu Exp $
\brief cluster helper
\author Moritz Bunkus <moritz@bunkus.org>
*/
@ -283,12 +283,10 @@ void cluster_helper_c::check_clusters(int num) {
if (p->bref == -1)
continue;
clstr = find_packet_cluster(p->bref);
if (clstr == NULL) {
fprintf(stderr, "Error: backward refenrece could not be resolved "
"(%lld -> %lld). Called from line %d.\n",
p->timecode, p->bref, num);
die("internal error");
}
if (clstr == NULL)
die("Error: backward refenrece could not be resolved "
"(%lld -> %lld). Called from line %d.\n",
p->timecode, p->bref, num);
}
}
}
@ -328,11 +326,9 @@ int cluster_helper_c::free_clusters() {
if (p->bref == -1)
continue;
clstr = find_packet_cluster(p->bref);
if (clstr == NULL) {
fprintf(stderr, "Error: backward refenrece could not be resolved "
"(%lld).\n", p->bref);
die("internal error");
}
if (clstr == NULL)
die("Error: backward refenrece could not be resolved "
"(%lld).\n", p->bref);
clstr->is_referenced = 1;
}
}

View File

@ -13,7 +13,7 @@
/*!
\file
\version \$Id: common.cpp,v 1.26 2003/05/25 15:35:39 mosu Exp $
\version \$Id: common.cpp,v 1.27 2003/05/26 21:49:11 mosu Exp $
\brief helper functions, common variables
\author Moritz Bunkus <moritz@bunkus.org>
*/
@ -27,6 +27,7 @@
#endif
#include <locale.h>
#include <malloc.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -39,8 +40,17 @@
int verbose = 1;
void _die(const char *s, const char *file, int line) {
fprintf(stderr, "die @ %s/%d : %s\n", file, line, s);
void _die(const char *fmt, const char *file, int line, ...) {
va_list ap;
fprintf(stderr, "die @ %s/%d : ", file, line);
va_start(ap, line);
vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, "\n");
#ifdef DEBUG
debug_c::dump_info();
#endif
exit(1);
}
@ -212,7 +222,7 @@ char *to_utf8(int handle, char *local) {
}
if (handle >= num_mkv_convs)
die("Invalid conversion handle.");
die("Invalid conversion handle %d (num: %d).", handle, num_mkv_convs);
return convert_charset(mkv_convs[handle].ict_to_utf8, local);
}
@ -226,7 +236,7 @@ char *from_utf8(int handle, char *utf8) {
}
if (handle >= num_mkv_convs)
die("Invalid conversion handle.");
die("Invalid conversion handle %d (num: %d).", handle, num_mkv_convs);
return convert_charset(mkv_convs[handle].ict_from_utf8, utf8);
}
@ -282,8 +292,8 @@ char *_safestrdup(const char *s, const char *file, int line) {
copy = strdup(s);
if (copy == NULL) {
fprintf(stderr, "die @ %s/%d : in safestrdup: strdup == NULL\n", file,
line);
fprintf(stderr, "die @ %s/%d : in safestrdup: strdup == NULL (%s)\n", file,
line, s);
exit(1);
}
@ -299,8 +309,8 @@ unsigned char *_safestrdup(const unsigned char *s, const char *file,
copy = strdup((const char *)s);
if (copy == NULL) {
fprintf(stderr, "die @ %s/%d : in safestrdup: strdup == NULL\n", file,
line);
fprintf(stderr, "die @ %s/%d : in safestrdup: strdup == NULL (%s)\n", file,
line, s);
exit(1);
}
@ -315,8 +325,8 @@ void *_safememdup(const void *s, size_t size, const char *file, int line) {
copy = malloc(size);
if (copy == NULL) {
fprintf(stderr, "die @ %s/%d : in safememdup: malloc == NULL\n", file,
line);
fprintf(stderr, "die @ %s/%d : in safememdup: malloc == NULL (%d)\n", file,
line, size);
exit(1);
}
memcpy(copy, s, size);
@ -329,8 +339,8 @@ void *_safemalloc(size_t size, const char *file, int line) {
mem = malloc(size);
if (mem == NULL) {
fprintf(stderr, "die @ %s/%d : in safemalloc: malloc == NULL\n", file,
line);
fprintf(stderr, "die @ %s/%d : in safemalloc: malloc == NULL (%d)\n", file,
line, size);
exit(1);
}
@ -340,8 +350,8 @@ void *_safemalloc(size_t size, const char *file, int line) {
void *_saferealloc(void *mem, size_t size, const char *file, int line) {
mem = realloc(mem, size);
if (mem == NULL) {
fprintf(stderr, "die @ %s/%d : in safemalloc: realloc == NULL\n", file,
line);
fprintf(stderr, "die @ %s/%d : in safemalloc: realloc == NULL (%d)\n",
file, line, size);
exit(1);
}
@ -444,11 +454,8 @@ void debug_c::leave(const char *label) {
break;
}
if ((entry == NULL) || (entry->entered_at == 0)) {
string s("leave without enter: ");
s += label;
die(s.c_str());
}
if ((entry == NULL) || (entry->entered_at == 0))
die("leave without enter: %s", label);
entry->number_of_calls++;
entry->elapsed_time += (uint64_t)tv.tv_sec * (uint64_t)1000000 +

View File

@ -13,7 +13,7 @@
/*!
\file
\version \$Id: common.h,v 1.31 2003/05/25 15:35:39 mosu Exp $
\version \$Id: common.h,v 1.32 2003/05/26 21:49:11 mosu Exp $
\brief definitions used in all programs, helper functions
\author Moritz Bunkus <moritz@bunkus.org>
*/
@ -79,8 +79,8 @@ using namespace std;
#define TIMECODE_SCALE 1000000
#define die(s) _die(s, __FILE__, __LINE__)
void _die(const char *s, const char *file, int line);
#define die(fmt, args...) _die(fmt, __FILE__, __LINE__, ## args)
void _die(const char *fmt, const char *file, int line, ...);
#define trace() _trace(__func__, __FILE__, __LINE__)
void _trace(const char *func, const char *file, int line);

View File

@ -13,7 +13,7 @@
/*!
\file
\version \$Id: p_aac.cpp,v 1.7 2003/05/25 15:35:39 mosu Exp $
\version \$Id: p_aac.cpp,v 1.8 2003/05/26 21:49:11 mosu Exp $
\brief AAC output module
\author Moritz Bunkus <moritz@bunkus.org>
*/
@ -179,7 +179,7 @@ void aac_packetizer_c::set_headers() {
else if (profile == AAC_PROFILE_LTP)
set_codec_id(MKV_A_AAC_4LTP);
else
die("aac_packetizer: Unknown AAC MPEG-4 object type...");
die("aac_packetizer: Unknown AAC MPEG-4 object type %d.", profile);
} else {
if (profile == AAC_PROFILE_MAIN)
set_codec_id(MKV_A_AAC_2MAIN);
@ -188,7 +188,7 @@ void aac_packetizer_c::set_headers() {
else if (profile == AAC_PROFILE_SSR)
set_codec_id(MKV_A_AAC_2SSR);
else
die("aac_packetizer: Unknown AAC MPEG-2 profile...");
die("aac_packetizer: Unknown AAC MPEG-2 profile %d.", profile);
}
set_audio_sampling_freq((float)samples_per_sec);
set_audio_channels(channels);

View File

@ -13,7 +13,7 @@
/*!
\file
\version \$Id: pr_generic.cpp,v 1.46 2003/05/25 15:35:39 mosu Exp $
\version \$Id: pr_generic.cpp,v 1.47 2003/05/26 21:49:11 mosu Exp $
\brief functions common for all readers/packetizers
\author Moritz Bunkus <moritz@bunkus.org>
*/
@ -180,7 +180,7 @@ void generic_packetizer_c::set_as_default_track(int type) {
else if (type == track_subtitle)
idx = 2;
else
die("Unknown track type");
die("Unknown track type %d.", type);
if (default_tracks[idx] == 0)
default_tracks[idx] = -1 * hserialno;
@ -196,7 +196,7 @@ void generic_packetizer_c::force_default_track(int type) {
else if (type == track_subtitle)
idx = 2;
else
die("Unknown track type");
die("Unknown track type %d.", type);
if (default_tracks[idx] > 0)
fprintf(stdout, "Warning: Another default track for %s tracks has already "
@ -336,7 +336,7 @@ void generic_packetizer_c::add_packet(unsigned char *data, int length,
if (data == NULL)
return;
if (timecode < 0)
die("timecode < 0");
die("timecode < 0 (%lld)", timecode);
pack = (packet_t *)safemalloc(sizeof(packet_t));
memset(pack, 0, sizeof(packet_t));

View File

@ -13,7 +13,7 @@
/*!
\file
\version \$Id: r_matroska.cpp,v 1.40 2003/05/25 15:35:39 mosu Exp $
\version \$Id: r_matroska.cpp,v 1.41 2003/05/26 21:49:11 mosu Exp $
\brief Matroska reader
\author Moritz Bunkus <moritz@bunkus.org>
*/
@ -416,12 +416,7 @@ int mkv_reader_c::read_headers() {
// Create the interface between MPlayer's IO system and
// libmatroska's IO system.
in = new StdIOCallback(ti->fname, MODE_READ);
if (in == NULL)
die("new");
es = new EbmlStream(*in);
if (es == NULL)
die("new");
// Find the EbmlHead element. Must be the first one.
l0 = es->FindNextID(EbmlHead::ClassInfos, 0xFFFFFFFFL);
@ -1150,7 +1145,7 @@ int mkv_reader_c::demuxing_requested(mkv_track_t *t) {
else if (t->type == 's')
tracks = ti->stracks;
else
die("internal bug - unknown stream type");
die("internal bug - unknown stream type %d", t->type);
if (tracks == NULL)
return 1;