qemu-log: fix x86 and user logging
5726c27fa913296aafab9f50b912cea5b3709271 broke x86 specific options and user emulation specific stdio buffering. Always enable all log items. They may not be useful for non-x86 targets, but there's no harm either. Fix user emulation buffering by passing around a flag. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
		
							parent
							
								
									39a4ef1be6
								
							
						
					
					
						commit
						3437e54585
					
				
							
								
								
									
										24
									
								
								qemu-log.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								qemu-log.c
									
									
									
									
									
								
							@ -52,7 +52,7 @@ void qemu_log_mask(int mask, const char *fmt, ...)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* enable or disable low levels log */
 | 
					/* enable or disable low levels log */
 | 
				
			||||||
void cpu_set_log(int log_flags)
 | 
					void qemu_set_log(int log_flags, bool use_own_buffers)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    qemu_loglevel = log_flags;
 | 
					    qemu_loglevel = log_flags;
 | 
				
			||||||
    if (qemu_loglevel && !qemu_logfile) {
 | 
					    if (qemu_loglevel && !qemu_logfile) {
 | 
				
			||||||
@ -61,13 +61,13 @@ void cpu_set_log(int log_flags)
 | 
				
			|||||||
            perror(logfilename);
 | 
					            perror(logfilename);
 | 
				
			||||||
            _exit(1);
 | 
					            _exit(1);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
#if !defined(CONFIG_SOFTMMU)
 | 
					 | 
				
			||||||
        /* must avoid mmap() usage of glibc by setting a buffer "by hand" */
 | 
					        /* must avoid mmap() usage of glibc by setting a buffer "by hand" */
 | 
				
			||||||
        {
 | 
					        if (use_own_buffers) {
 | 
				
			||||||
            static char logfile_buf[4096];
 | 
					            static char logfile_buf[4096];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            setvbuf(qemu_logfile, logfile_buf, _IOLBF, sizeof(logfile_buf));
 | 
					            setvbuf(qemu_logfile, logfile_buf, _IOLBF, sizeof(logfile_buf));
 | 
				
			||||||
        }
 | 
					        } else {
 | 
				
			||||||
#elif defined(_WIN32)
 | 
					#if defined(_WIN32)
 | 
				
			||||||
            /* Win32 doesn't support line-buffering, so use unbuffered output. */
 | 
					            /* Win32 doesn't support line-buffering, so use unbuffered output. */
 | 
				
			||||||
            setvbuf(qemu_logfile, NULL, _IONBF, 0);
 | 
					            setvbuf(qemu_logfile, NULL, _IONBF, 0);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
@ -75,6 +75,7 @@ void cpu_set_log(int log_flags)
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
            log_append = 1;
 | 
					            log_append = 1;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if (!qemu_loglevel && qemu_logfile) {
 | 
					    if (!qemu_loglevel && qemu_logfile) {
 | 
				
			||||||
        fclose(qemu_logfile);
 | 
					        fclose(qemu_logfile);
 | 
				
			||||||
        qemu_logfile = NULL;
 | 
					        qemu_logfile = NULL;
 | 
				
			||||||
@ -99,10 +100,7 @@ const CPULogItem cpu_log_items[] = {
 | 
				
			|||||||
    { CPU_LOG_TB_OP, "op",
 | 
					    { CPU_LOG_TB_OP, "op",
 | 
				
			||||||
      "show micro ops for each compiled TB" },
 | 
					      "show micro ops for each compiled TB" },
 | 
				
			||||||
    { CPU_LOG_TB_OP_OPT, "op_opt",
 | 
					    { CPU_LOG_TB_OP_OPT, "op_opt",
 | 
				
			||||||
      "show micro ops "
 | 
					      "show micro ops (x86 only: before eflags optimization) and\n"
 | 
				
			||||||
#ifdef TARGET_I386
 | 
					 | 
				
			||||||
      "before eflags optimization and "
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
      "after liveness analysis" },
 | 
					      "after liveness analysis" },
 | 
				
			||||||
    { CPU_LOG_INT, "int",
 | 
					    { CPU_LOG_INT, "int",
 | 
				
			||||||
      "show interrupts/exceptions in short format" },
 | 
					      "show interrupts/exceptions in short format" },
 | 
				
			||||||
@ -110,16 +108,12 @@ const CPULogItem cpu_log_items[] = {
 | 
				
			|||||||
      "show trace before each executed TB (lots of logs)" },
 | 
					      "show trace before each executed TB (lots of logs)" },
 | 
				
			||||||
    { CPU_LOG_TB_CPU, "cpu",
 | 
					    { CPU_LOG_TB_CPU, "cpu",
 | 
				
			||||||
      "show CPU state before block translation" },
 | 
					      "show CPU state before block translation" },
 | 
				
			||||||
#ifdef TARGET_I386
 | 
					 | 
				
			||||||
    { CPU_LOG_PCALL, "pcall",
 | 
					    { CPU_LOG_PCALL, "pcall",
 | 
				
			||||||
      "show protected mode far calls/returns/exceptions" },
 | 
					      "x86 only: show protected mode far calls/returns/exceptions" },
 | 
				
			||||||
    { CPU_LOG_RESET, "cpu_reset",
 | 
					    { CPU_LOG_RESET, "cpu_reset",
 | 
				
			||||||
      "show CPU state before CPU resets" },
 | 
					      "x86 only: show CPU state before CPU resets" },
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef DEBUG_IOPORT
 | 
					 | 
				
			||||||
    { CPU_LOG_IOPORT, "ioport",
 | 
					    { CPU_LOG_IOPORT, "ioport",
 | 
				
			||||||
      "show all i/o ports accesses" },
 | 
					      "show all i/o ports accesses" },
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    { LOG_UNIMP, "unimp",
 | 
					    { LOG_UNIMP, "unimp",
 | 
				
			||||||
      "log unimplemented functionality" },
 | 
					      "log unimplemented functionality" },
 | 
				
			||||||
    { 0, NULL, NULL },
 | 
					    { 0, NULL, NULL },
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										12
									
								
								qemu-log.h
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								qemu-log.h
									
									
									
									
									
								
							@ -142,7 +142,17 @@ typedef struct CPULogItem {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
extern const CPULogItem cpu_log_items[];
 | 
					extern const CPULogItem cpu_log_items[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cpu_set_log(int log_flags);
 | 
					void qemu_set_log(int log_flags, bool use_own_buffers);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline void cpu_set_log(int log_flags)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#ifdef CONFIG_USER_ONLY
 | 
				
			||||||
 | 
					    qemu_set_log(log_flags, true);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    qemu_set_log(log_flags, false);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void cpu_set_log_filename(const char *filename);
 | 
					void cpu_set_log_filename(const char *filename);
 | 
				
			||||||
int cpu_str_to_log_mask(const char *str);
 | 
					int cpu_str_to_log_mask(const char *str);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user