diff options
author | josh.macdonald <jmacd@users.noreply.github.com> | 2009-10-26 03:44:43 +0000 |
---|---|---|
committer | josh.macdonald <jmacd@users.noreply.github.com> | 2009-10-26 03:44:43 +0000 |
commit | d8237539476e01980ae977163cb078968bd071cc (patch) | |
tree | 3f6861a133283db1441bbf71e8e8c9991c432ae2 | |
parent | 6731dfb89d79d9a9a890e67ba235e2aac7ee015f (diff) |
Debugging: add a big TODO!
-rw-r--r-- | xdelta3/xdelta3-main.h | 82 |
1 files changed, 50 insertions, 32 deletions
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index 648ae1d..bfb9ba6 100644 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h | |||
@@ -225,6 +225,7 @@ struct _main_file | |||
225 | xoff_t nwrite; /* for output position */ | 225 | xoff_t nwrite; /* for output position */ |
226 | uint8_t *snprintf_buf; /* internal snprintf() use */ | 226 | uint8_t *snprintf_buf; /* internal snprintf() use */ |
227 | xoff_t source_position; /* for avoiding seek in getblk_func */ | 227 | xoff_t source_position; /* for avoiding seek in getblk_func */ |
228 | int seek_failed; /* after seek fails once */ | ||
228 | }; | 229 | }; |
229 | 230 | ||
230 | /* Various strings and magic values used to detect and call external | 231 | /* Various strings and magic values used to detect and call external |
@@ -1069,7 +1070,8 @@ main_file_seek (main_file *xfile, xoff_t pos) | |||
1069 | 1070 | ||
1070 | if (ret) | 1071 | if (ret) |
1071 | { | 1072 | { |
1072 | XPR(NT "seek failed: %s: %s\n", xfile->filename, xd3_mainerror (ret)); | 1073 | XPR(NT "seek to %"Q"u failed: %s: %s\n", |
1074 | pos, xfile->filename, xd3_mainerror (ret)); | ||
1073 | } | 1075 | } |
1074 | 1076 | ||
1075 | return ret; | 1077 | return ret; |
@@ -2792,20 +2794,10 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd, | |||
2792 | if (stat_val == 0) | 2794 | if (stat_val == 0) |
2793 | { | 2795 | { |
2794 | source_size_known = 1; | 2796 | source_size_known = 1; |
2795 | |||
2796 | if (option_verbose > 1) | ||
2797 | { | ||
2798 | XPR(NT "source file size: %"Q"u\n", source_size); | ||
2799 | } | ||
2800 | } | 2797 | } |
2801 | else | 2798 | else |
2802 | { | 2799 | { |
2803 | source_size_known = 0; | 2800 | source_size_known = 0; |
2804 | |||
2805 | if (option_verbose > 1) | ||
2806 | { | ||
2807 | XPR(NT "source not seekable: %s\n", xd3_mainerror (stat_val)); | ||
2808 | } | ||
2809 | } | 2801 | } |
2810 | } | 2802 | } |
2811 | 2803 | ||
@@ -2855,14 +2847,21 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd, | |||
2855 | if (option_verbose) | 2847 | if (option_verbose) |
2856 | { | 2848 | { |
2857 | static char buf[32]; | 2849 | static char buf[32]; |
2850 | static char sizebuf[32]; | ||
2851 | if (source_size_known) | ||
2852 | { | ||
2853 | sprintf(sizebuf, " size %"Q"u", source_size); | ||
2854 | } | ||
2855 | else | ||
2856 | { | ||
2857 | strcpy(sizebuf, " not seekable"); | ||
2858 | } | ||
2858 | 2859 | ||
2859 | XPR(NT "source %s: winsize %s\n", | 2860 | XPR(NT "source %s winsize %s blksize %u%s\n", |
2860 | sfile->filename, main_format_bcnt(option_srcwinsz, buf)); | 2861 | sfile->filename, |
2861 | } | 2862 | main_format_bcnt(option_srcwinsz, buf), |
2862 | 2863 | source->blksize, | |
2863 | if (option_verbose > 1) | 2864 | sizebuf); |
2864 | { | ||
2865 | XPR(NT "source block size: %u\n", source->blksize); | ||
2866 | } | 2865 | } |
2867 | 2866 | ||
2868 | if ((lru = (main_blklru*) | 2867 | if ((lru = (main_blklru*) |
@@ -2940,13 +2939,15 @@ main_getblk_func (xd3_stream *stream, | |||
2940 | xd3_source *source, | 2939 | xd3_source *source, |
2941 | xoff_t blkno) | 2940 | xoff_t blkno) |
2942 | { | 2941 | { |
2943 | int ret; | 2942 | int ret = 0; |
2944 | xoff_t pos = blkno * source->blksize; | 2943 | xoff_t pos = blkno * source->blksize; |
2945 | main_file *sfile = (main_file*) source->ioh; | 2944 | main_file *sfile = (main_file*) source->ioh; |
2946 | main_blklru *blru = NULL; | 2945 | main_blklru *blru = NULL; |
2947 | usize_t nread = 0; | 2946 | usize_t nread = 0; |
2948 | usize_t i; | 2947 | usize_t i; |
2949 | 2948 | ||
2949 | // TODO! The skip logic has to fill cache, duh! | ||
2950 | |||
2950 | if (allow_fake_source) | 2951 | if (allow_fake_source) |
2951 | { | 2952 | { |
2952 | source->curblkno = blkno; | 2953 | source->curblkno = blkno; |
@@ -3020,26 +3021,33 @@ main_getblk_func (xd3_stream *stream, | |||
3020 | /* Only try to seek when the position is wrong. This means the | 3021 | /* Only try to seek when the position is wrong. This means the |
3021 | * decoder will fail when the source buffer is too small, but | 3022 | * decoder will fail when the source buffer is too small, but |
3022 | * only when the input is non-seekable. */ | 3023 | * only when the input is non-seekable. */ |
3023 | ret = main_file_seek (sfile, pos); | 3024 | if (!sfile->seek_failed) |
3024 | 3025 | { | |
3025 | if (ret != 0) | 3026 | ret = main_file_seek (sfile, pos); |
3027 | } | ||
3028 | |||
3029 | if (ret != 0 || sfile->seek_failed) | ||
3026 | { | 3030 | { |
3031 | sfile->seek_failed = 1; | ||
3032 | |||
3027 | /* For an unseekable file (or other seek error, does it | 3033 | /* For an unseekable file (or other seek error, does it |
3028 | * matter?) */ | 3034 | * matter?) */ |
3029 | if (option_verbose && | ||
3030 | sfile->source_position == 0) | ||
3031 | { | ||
3032 | XPR(NT "unseekable source, skipping past unused input"); | ||
3033 | } | ||
3034 | |||
3035 | if (sfile->source_position > pos) | 3035 | if (sfile->source_position > pos) |
3036 | { | 3036 | { |
3037 | /* Should assert !IS_ENCODE(), this shouldn't happen | 3037 | /* Could assert !IS_ENCODE(), this shouldn't happen |
3038 | * because of do_not_lru during encode. */ | 3038 | * because of do_not_lru during encode. */ |
3039 | IF_DEBUG1 (DP(RINT "cannot seek backwards\n")); | ||
3039 | stream->msg = "non-seekable source: copy is too far back (try raising -B)"; | 3040 | stream->msg = "non-seekable source: copy is too far back (try raising -B)"; |
3040 | return XD3_TOOFARBACK; | 3041 | return XD3_TOOFARBACK; |
3041 | } | 3042 | } |
3042 | 3043 | ||
3044 | if (option_verbose && | ||
3045 | sfile->source_position == 0 && | ||
3046 | !sfile->seek_failed) | ||
3047 | { | ||
3048 | XPR(NT "unseekable source: skipping past unused input\n"); | ||
3049 | } | ||
3050 | |||
3043 | while (sfile->source_position < pos) | 3051 | while (sfile->source_position < pos) |
3044 | { | 3052 | { |
3045 | /* Read past unused data */ | 3053 | /* Read past unused data */ |
@@ -3055,16 +3063,26 @@ main_getblk_func (xd3_stream *stream, | |||
3055 | } | 3063 | } |
3056 | 3064 | ||
3057 | sfile->source_position += nread; | 3065 | sfile->source_position += nread; |
3066 | |||
3067 | if (option_verbose > 1) | ||
3068 | { | ||
3069 | XPR(NT "skip 1 source block\n"); | ||
3070 | } | ||
3058 | 3071 | ||
3059 | if (nread != source->blksize) | 3072 | if (nread != source->blksize) |
3060 | { | 3073 | { |
3074 | IF_DEBUG1 (DP(RINT "short skip block nread = %u\n", nread)); | ||
3061 | stream->msg = "non-seekable input is short"; | 3075 | stream->msg = "non-seekable input is short"; |
3062 | return XD3_INVALID_INPUT; | 3076 | return XD3_INVALID_INPUT; |
3063 | } | 3077 | } |
3078 | |||
3079 | XD3_ASSERT (sfile->source_position <= pos); | ||
3064 | } | 3080 | } |
3065 | } | 3081 | } |
3066 | } | 3082 | } |
3067 | 3083 | ||
3084 | XD3_ASSERT (sfile->source_position == pos); | ||
3085 | |||
3068 | if ((ret = main_read_primary_input (sfile, | 3086 | if ((ret = main_read_primary_input (sfile, |
3069 | (uint8_t*) blru->blk, | 3087 | (uint8_t*) blru->blk, |
3070 | source->blksize, | 3088 | source->blksize, |
@@ -3079,7 +3097,7 @@ main_getblk_func (xd3_stream *stream, | |||
3079 | 3097 | ||
3080 | main_blklru_list_push_back (& lru_list, blru); | 3098 | main_blklru_list_push_back (& lru_list, blru); |
3081 | 3099 | ||
3082 | if (option_verbose > 2) | 3100 | if (option_verbose > 3) |
3083 | { | 3101 | { |
3084 | if (blru->blkno != (xoff_t)-1) | 3102 | if (blru->blkno != (xoff_t)-1) |
3085 | { | 3103 | { |
@@ -3100,8 +3118,8 @@ main_getblk_func (xd3_stream *stream, | |||
3100 | source->onblk = nread; | 3118 | source->onblk = nread; |
3101 | blru->size = nread; | 3119 | blru->size = nread; |
3102 | 3120 | ||
3103 | IF_DEBUG1 (DP(RINT "[main_getblk] blkno %"Q"u onblk %u\n", | 3121 | IF_DEBUG1 (DP(RINT "[main_getblk] blkno %"Q"u onblk %u srcpos %"Q"u\n", |
3104 | blkno, nread)); | 3122 | blkno, nread, pos, sfile->source_position)); |
3105 | 3123 | ||
3106 | return 0; | 3124 | return 0; |
3107 | } | 3125 | } |