diff options
| author | Tim Rogers <[email protected]> | 2013-02-22 21:31:31 -0800 |
|---|---|---|
| committer | Andrew Boktor <[email protected]> | 2014-08-14 13:50:05 -0700 |
| commit | 1f421f9fd3f576880d21483aed369576b08143d1 (patch) | |
| tree | 86598d0b654339632021e658e5064bc38c010306 /src/cuda-sim | |
| parent | 7a90f721b00a6f0a9bbac5f63b374932fc780b5b (diff) | |
Fixed at least one error in the valgrind build. Forgot to initial a member variable.
I thought the init() function where dynamic_warp_id is initialized was called on construction.
It is not. Added a default value in the constructor. Maybe a code review would have caught this :)
Also cleaned up some weird code I had in the ptx_instruction::to_string().
Also trimmed out tabs from our stored source line string so it is much more readable on print
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 15310]
Diffstat (limited to 'src/cuda-sim')
| -rw-r--r-- | src/cuda-sim/ptx_ir.cc | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/cuda-sim/ptx_ir.cc b/src/cuda-sim/ptx_ir.cc index 678febf..242901b 100644 --- a/src/cuda-sim/ptx_ir.cc +++ b/src/cuda-sim/ptx_ir.cc @@ -1183,6 +1183,8 @@ ptx_instruction::ptx_instruction( int opcode, m_source_file = file?file:"<unknown>"; m_source_line = line; m_source = source; + // Trim tabs + m_source.erase( std::remove( m_source.begin(), m_source.end(), '\t' ), m_source.end() ); if (opcode == CALL_OP) { const operand_info &target = func_addr(); @@ -1211,21 +1213,18 @@ void ptx_instruction::print_insn( FILE *fp ) const std::string ptx_instruction::to_string() const { - std::string result( m_source ); - unsigned semi_c_pos = result.find(";"); - assert( semi_c_pos != std::string::npos ); + char buf[ STR_SIZE ]; + unsigned used_bytes = 0; if( !is_label() ) { - char buf[ STR_SIZE ]; - buf[ STR_SIZE - 1 ] = '\0'; - snprintf( buf, STR_SIZE, " PC=0x%03x ", m_PC ); - result += std::string( buf ); - } else - result += std::string(" "); - char buf[STR_SIZE]; - buf[STR_SIZE - 1] = '\0'; - snprintf( buf, STR_SIZE, - "(%s:%d) %s", m_source_file.c_str(), m_source_line, m_source.c_str() + semi_c_pos ); - return result; + used_bytes += snprintf( buf + used_bytes, STR_SIZE - used_bytes, " PC=0x%03x ", m_PC ); + } else { + used_bytes += snprintf( buf + used_bytes, STR_SIZE - used_bytes, " " ); + } + used_bytes += snprintf( buf + used_bytes, STR_SIZE - used_bytes, + "(%s:%d) %s", + m_source_file.c_str(), m_source_line, + m_source.c_str() ); + return std::string( buf ); } unsigned function_info::sm_next_uid = 1; |
